17#include <boost/regex.hpp>
24Kernel::Logger
g_log(
"XMLInstrumentParameter");
27using namespace Kernel;
55 std::shared_ptr<Kernel::Interpolation> interpolation,
56 std::string formula, std::string formulaUnit, std::string resultUnit,
57 std::string paramName, std::string type, std::string tie,
58 std::vector<std::string> constraint, std::string &penaltyFactor,
59 std::string fitFunc, std::string extractSingleValueAs, std::string eq,
61 const std::string &description, std::string visible)
63 m_type(
std::move(type)), m_tie(
std::move(tie)), m_constraint(
std::move(constraint)),
64 m_penaltyFactor(penaltyFactor), m_fittingFunction(
std::move(fitFunc)), m_formula(
std::move(formula)),
65 m_formulaUnit(
std::move(formulaUnit)), m_resultUnit(
std::move(resultUnit)),
66 m_interpolation(
std::move(interpolation)), m_extractSingleValueAs(
std::move(extractSingleValueAs)),
67 m_eq(
std::move(eq)), m_component(comp), m_angleConvertConst(angleConvertConst), m_description(
""),
68 m_visible(
std::move(visible)) {
69 if (!description.empty()) {
70 static const boost::regex re(
"\\s+");
71 std::string desc = boost::regex_replace(description, re,
" ");
107 g_log.
error() <<
"XMLInstrumentParameter::createParamValue has been called "
108 "with a 'string' parameters.\n"
109 <<
"Return meaningless zere value.";
113 double extractedValue = 0.0;
124 using StatisticsMapType = std::map<std::string, Kernel::Math::StatisticType>;
125 StatisticsMapType statistics_types;
135 const bool bUsingStandardStatistics = statisics_choice != statistics_types.end();
139 }
else if (bUsingStandardStatistics) {
148 extractPosition >> dummy >>
position;
153 std::string(
"extract-single-value-as attribute for <parameter>") +
" element (eq=" +
m_eq +
154 ") in instrument definition file is not recognised.");
158 extractedValue = boost::lexical_cast<double>(
m_value);
159 }
catch (boost::bad_lexical_cast &) {
161 " much be set to a number,\n" +
162 "unless it is meant to be a 'string' parameter.");
169 return extractedValue;
172 std::string equationStr =
m_eq;
173 found = equationStr.find(
"value");
174 if (found == std::string::npos) {
176 std::string(
"Equation attribute for <parameter>") +
" element (eq=" +
m_eq +
177 ") in instrument definition file must contain the string: \"value\"." +
178 ". \"value\" is replaced by a value from the logfile.");
181 std::stringstream readDouble;
182 readDouble << extractedValue;
183 std::string extractedValueStr = readDouble.str();
184 equationStr.replace(found, 5, extractedValueStr);
188 while (equationStr.find(
"value") != std::string::npos) {
189 found = equationStr.find(
"value");
190 equationStr.replace(found, 5, extractedValueStr);
195 p.SetExpr(equationStr);
197 }
catch (mu::Parser::exception_type &e) {
199 std::string(
"Equation attribute for <parameter>") +
" element (eq=" +
m_eq +
200 ") 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
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)
double createParamValue(Mantid::Kernel::TimeSeriesProperty< double > *logData) const
Returns parameter value as generated using possibly equation expression 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.
A specialised Property class for holding a series of time-value pairs.
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)
Returns the mean value if the property is TimeSeriesProperty<double>
double DLLExport filterByStatistic(TimeSeriesProperty< double > const *const propertyToFilter, Kernel::Math::StatisticType statisticType)
Function filtering double TimeSeriesProperties according to the requested statistics.