18#include <boost/regex.hpp>
27Kernel::Logger
g_log(
"XMLInstrumentParameter");
30using namespace Kernel;
58 std::shared_ptr<Kernel::Interpolation> interpolation,
59 std::string formula, std::string formulaUnit, std::string resultUnit,
60 std::string paramName, std::string type, std::string tie,
61 std::vector<std::string> constraint, std::string &penaltyFactor,
62 std::string fitFunc, std::string extractSingleValueAs, std::string eq,
64 const std::string &description, std::string visible)
66 m_type(
std::move(type)), m_tie(
std::move(tie)), m_constraint(
std::move(constraint)),
67 m_penaltyFactor(penaltyFactor), m_fittingFunction(
std::move(fitFunc)), m_formula(
std::move(formula)),
68 m_formulaUnit(
std::move(formulaUnit)), m_resultUnit(
std::move(resultUnit)),
69 m_interpolation(
std::move(interpolation)), m_extractSingleValueAs(
std::move(extractSingleValueAs)),
70 m_eq(
std::move(eq)), m_component(comp), m_angleConvertConst(angleConvertConst), m_description(
""),
71 m_visible(
std::move(visible)) {
72 if (!description.empty()) {
73 static const boost::regex re(
"\\s+");
74 std::string desc = boost::regex_replace(description, re,
" ");
112 g_log.
error() <<
"XMLInstrumentParameter::createParamValue has been called "
113 "with a 'string' parameters.\n"
114 <<
"Return meaningless zere value.";
118 double extractedValue = 0.0;
129 using StatisticsMapType = std::map<std::string, Kernel::Math::StatisticType>;
130 StatisticsMapType statistics_types;
140 const bool bUsingStandardStatistics = statisics_choice != statistics_types.end();
144 }
else if (bUsingStandardStatistics) {
145 extractedValue = logData->
extractStatistic((*statisics_choice).second, roi);
153 extractPosition >> dummy >>
position;
158 std::string(
"extract-single-value-as attribute for <parameter>") +
" element (eq=" +
m_eq +
159 ") in instrument definition file is not recognised.");
163 extractedValue = boost::lexical_cast<double>(
m_value);
164 }
catch (boost::bad_lexical_cast &) {
166 " much be set to a number,\n" +
167 "unless it is meant to be a 'string' parameter.");
174 return extractedValue;
177 std::string equationStr =
m_eq;
178 found = equationStr.find(
"value");
179 if (found == std::string::npos) {
181 std::string(
"Equation attribute for <parameter>") +
" element (eq=" +
m_eq +
182 ") in instrument definition file must contain the string: \"value\"." +
183 ". \"value\" is replaced by a value from the logfile.");
186 std::stringstream readDouble;
187 readDouble << extractedValue;
188 std::string extractedValueStr = readDouble.str();
189 equationStr.replace(found, 5, extractedValueStr);
193 while (equationStr.find(
"value") != std::string::npos) {
194 found = equationStr.find(
"value");
195 equationStr.replace(found, 5, extractedValueStr);
200 p.SetExpr(equationStr);
202 }
catch (mu::Parser::exception_type &e) {
204 std::string(
"Equation attribute for <parameter>") +
" element (eq=" +
m_eq +
205 ") in instrument definition file cannot be parsed." +
". Muparser error message is: " + e.GetMsg());
const std::string & m_value
double value
The value of the point.
base class for Geometric IComponent
const std::string m_value
rather then extracting value from logfile,
const std::string m_paramName
specify a value directly
XMLInstrumentParameter(std::string logfileID, std::string value, std::shared_ptr< Kernel::Interpolation > interpolation, std::string formula, std::string formulaUnit, std::string resultUnit, std::string paramName, std::string type, std::string tie, std::vector< std::string > constraint, std::string &penaltyFactor, std::string fitFunc, std::string extractSingleValueAs, std::string eq, const Geometry::IComponent *comp, double angleConvertConst, const std::string &description, std::string visible)
Default constructor.
const std::string m_type
type of the data, e.g. int, double or string
const std::string m_description
if present, contains help string, describing the parameter
const std::string m_logfileID
logfile id
double createParamValue(const Mantid::Kernel::TimeSeriesProperty< double > *logData, const Kernel::TimeROI *) const
Returns parameter value as generated using possibly equation expression etc.
std::shared_ptr< Kernel::Interpolation > m_interpolation
evaluating the formula
const std::string m_formula
specify fitting function
const std::string m_eq
single value from the log file( average, first number, etc)
const std::string m_extractSingleValueAs
describes the way to extract a
Exception for errors associated with the instrument definition.
void error(const std::string &msg)
Logs at error level.
TimeROI : Object that holds information about when the time measurement was active.
A specialised Property class for holding a series of time-value pairs.
double extractStatistic(Math::StatisticType selection, const TimeROI *roi=nullptr) const override
Calculate a particular statistical quantity from the values of the time series.
virtual TYPE nthValue(int n) const
Returns n-th value of n-th interval in an incredibly inefficient way.
Mantid::Kernel::Logger g_log("Goniometer")
MANTID_KERNEL_DLL double timeMean(const Kernel::Property *p, const TimeROI *roi=nullptr)
Returns the mean value if the property is TimeSeriesProperty<double>