29const std::string CHAR_PROP_NAME(
"Characterizations");
30const std::string FREQ_PROP_NAME(
"FrequencyLogNames");
31const std::string WL_PROP_NAME(
"WaveLengthLogNames");
45 return "Workflow\\Diffraction\\UsesPropertyManager";
50 return "Determines the characterizations of a workspace.";
71 return {
"frequency",
"wavelength",
"bank",
"container",
"vanadium",
"vanadium_background",
72 "empty_environment",
"empty_instrument",
"d_min",
"d_max",
"tof_min",
"tof_max",
73 "wavelength_min",
"wavelength_max"};
78 std::map<std::string, std::string> result;
82 if (!
bool(characterizations))
86 std::vector<std::string> names = characterizations->getColumnNames();
87 if (names.size() < expectedNames.size()) {
88 std::stringstream msg;
89 msg <<
"Encountered invalid number of columns in "
90 <<
"TableWorkspace. Found " << names.size() <<
" expected " << expectedNames.size();
91 result[CHAR_PROP_NAME] = msg.str();
93 for (
auto &expectedName : expectedNames) {
94 if (std::find(names.begin(), names.end(), expectedName) == names.end()) {
95 std::stringstream msg;
96 msg <<
"Failed to find column named " << expectedName;
97 result[CHAR_PROP_NAME] = msg.str();
108 "Workspace with logs to help identify frequency and wavelength");
112 "Table of characterization information");
114 declareProperty(
"ReductionProperties",
"__pd_reduction_properties",
"Property manager name for the reduction");
116 const std::string defaultMsg =
" run to use. 0 to use value in table, -1 to not use.";
121 "Normalization background" + defaultMsg);
123 "Empty sample environment" + defaultMsg);
126 std::vector<std::string> defaultFrequencyNames{
"SpeedRequest1",
"Speed1",
"frequency",
"skf1.speed"};
129 "Candidate log names for frequency");
131 std::vector<std::string> defaultWavelengthNames{
"LambdaRequest",
"lambda",
"skf12.lambda",
"BL1B:Det:TH:BL:Lambda",
134 "Candidate log names for wave length");
150 const double relativeDiff = diff * 2 / (
left +
right);
151 return relativeDiff < .05;
156 const std::string &canName) {
159 for (
size_t i = 0; i < numRows; ++i) {
166 g_log.
information() <<
"Using information from row " << i <<
" with frequency = " << rowFrequency
167 <<
" and wavelength = " << rowWavelength <<
"\n";
193 if (!canName.empty()) {
195 if (std::find(columnNames.begin(), columnNames.end(), canName) == columnNames.end()) {
196 g_log.
warning() <<
"Failed to find container name \"" << canName <<
"\" in characterizations table \""
200 g_log.
information() <<
"Updating container identifier to \"" << canRuns <<
"\"\n";
208 g_log.
warning(
"Failed to find compatible row in characterizations table");
218 std::vector<std::string> names =
getProperty(propName);
220 std::string label =
"frequency";
221 if (propName == WL_PROP_NAME)
222 label =
"wavelength";
224 std::unordered_set<std::string> validUnits;
225 if (propName == WL_PROP_NAME) {
226 validUnits.insert(
"Angstrom");
227 validUnits.insert(
"A");
229 validUnits.insert(
"Hz");
232 for (
auto &
name : names) {
236 if (validUnits.find(units) != validUnits.end()) {
239 std::stringstream msg;
240 msg <<
"'" <<
name <<
"' has a mean value of zero " << units;
243 std::stringstream msg;
244 msg <<
"Found " << label <<
" in log '" <<
name <<
"' with mean value " <<
value <<
" " << units;
249 std::stringstream msg;
250 msg <<
"When looking at " <<
name <<
" log encountered unknown units '" << units <<
"' for " << label <<
":"
258 std::stringstream msg;
259 msg <<
"Failed to determine " << label <<
" because none of the logs ";
260 for (
auto &
name : names) {
261 msg <<
"\"" <<
name <<
"\" ";
264 throw std::runtime_error(msg.str());
325 std::vector<int32_t> runnumbers = this->
getProperty(inputName);
326 if ((!runnumbers.empty()) && (runnumbers[0] != 0)) {
327 if (runnumbers[0] < 0) {
328 runnumbers.erase(runnumbers.begin(), runnumbers.end());
329 runnumbers.emplace_back(0);
351 auto run = inputWS->mutableRun();
353 double frequency =
getLogValue(run, FREQ_PROP_NAME);
355 double wavelength =
getLogValue(run, WL_PROP_NAME);
358 std::string container;
359 if (run.hasProperty(
"SampleContainer")) {
360 const auto containerProp = run.getLogData(
"SampleContainer");
364 if (containerPropSeries) {
369 container = containerProp->value();
386 for (
auto &expectedName : expectedNames) {
#define DECLARE_ALGORITHM(classname)
double value
The value of the point.
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
bool isDefault(const std::string &name) const
bool hasProperty(const std::string &name) const
Does the property exist on the object.
Kernel::Property * getProperty(const std::string &name) const
Returns the named property as a pointer.
double getLogAsSingleValue(const std::string &name, Kernel::Math::StatisticType statistic=Kernel::Math::Mean) const
This class stores information regarding an experimental run as a series of log entries.
A property class for workspaces.
PDDetermineCharacterizations.
void getInformationFromTable(const double frequency, const double wavelength, const std::string &canName)
Fill in the property manager from the correct line in the table.
const std::string category() const override
Algorithm's category for identification.
void overrideRunNumProperty(const std::string &inputName, const std::string &propName)
Set the run number in the property manager from algoritm inputs.
double getLogValue(const API::Run &run, const std::string &propName)
Get a value from one of a set of logs.
const std::string name() const override
Algorithms name for identification.
Kernel::PropertyManager_sptr m_propertyManager
std::map< std::string, std::string > validateInputs() override
More intesive input checking.
void exec() override
Execute the algorithm.
API::ITableWorkspace_sptr m_characterizations
void init() override
Initialize the algorithm's properties.
int version() const override
Algorithm's version for identification.
void setDefaultsInPropManager()
Set the default values in the property manager.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
Support for a property that holds an array of values.
void debug(const std::string &msg)
Logs at debug level.
void warning(const std::string &msg)
Logs at warning level.
void information(const std::string &msg)
Logs at information level.
The concrete, templated class for properties.
virtual const std::string & units() const
Returns the units of the property, if any, as a string.
Manage the lifetime of a class intended to be a singleton.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
A specialised Property class for holding a series of time-value pairs.
std::vector< TYPE > valuesAsVector() const
Return the time series's values (unfiltered) as a vector<TYPE>
std::shared_ptr< const ITableWorkspace > ITableWorkspace_const_sptr
shared pointer to Mantid::API::ITableWorkspace (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::vector< std::string > getColumnNames()
These should match those in LoadPDCharacterizations.
bool closeEnough(const double left, const double right)
Compare two numbers to be in agreement within 5%.
MANTID_KERNEL_DLL std::string replaceAll(const std::string &input, const std::string &charStr, const std::string &substitute)
Return a string with all occurrences of the characters in the input replaced by the replace string.
Describes the direction (within an algorithm) of a Property.
@ Input
An input workspace.