From 7dd7f52c65f26f178fd936c8eb474d645cea292d Mon Sep 17 00:00:00 2001 From: Verena Reimund <reimund@ill.eu> Date: Wed, 7 Nov 2018 15:04:42 +0100 Subject: [PATCH] Generalise IPF parameter names - extend constructor in SampleLogsBehaviour: default IPF names for MergeRuns - ConjoinXRuns IPF names should start with conjoin_ + default names - new algorithms can use SampleLogsBehaviour and define own IPF names - documentation of Stitch1D mentions ConjoinXRuns for the sample log merging - documentation of ConjoinXRuns mentions IPF namimng convention (suffix is conjoin_) - FIGARO instrument IPF extended for ConjoinXRuns parameters, however, empty strings at the moment Refs #23947 --- .../SampleLogsBehaviour.h | 42 ++++++++++++------- Framework/Algorithms/src/ConjoinXRuns.cpp | 6 ++- .../SampleLogsBehaviour.cpp | 36 +++++++++------- docs/source/algorithms/ConjoinXRuns-v1.rst | 2 +- docs/source/algorithms/Stitch1D-v3.rst | 3 +- instrument/FIGARO_Parameters.xml | 19 +++++++++ 6 files changed, 73 insertions(+), 35 deletions(-) diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h b/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h index 632522a69fc..d4606d7061b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h @@ -8,7 +8,9 @@ #define MANTID_ALGORITHMS_MERGERUNS_SAMPLELOGSBEHAVIOUR_H_ #include "MantidAlgorithms/DllConfig.h" -#include <MantidAPI/MatrixWorkspace.h> +#include <MantidAPI/MatrixWorkspace_fwd.h> +#include <MantidKernel/Logger.h> +#include <MantidKernel/Property.h> namespace Mantid { namespace Algorithms { @@ -21,13 +23,13 @@ class MANTID_ALGORITHMS_DLL SampleLogsBehaviour { public: enum class MergeLogType { Sum, TimeSeries, List, Warn, Fail }; - static const std::string SUM_MERGE; - static const std::string TIME_SERIES_MERGE; - static const std::string LIST_MERGE; - static const std::string WARN_MERGE; - static const std::string FAIL_MERGE; - static const std::string WARN_MERGE_TOLERANCES; - static const std::string FAIL_MERGE_TOLERANCES; + const std::string SUM_MERGE; + const std::string TIME_SERIES_MERGE; + const std::string LIST_MERGE; + const std::string WARN_MERGE; + const std::string WARN_MERGE_TOLERANCES; + const std::string FAIL_MERGE; + const std::string FAIL_MERGE_TOLERANCES; // the names and docs of the override properties static const std::string TIME_SERIES_PROP; @@ -51,14 +53,22 @@ public: bool isNumeric; }; - SampleLogsBehaviour(API::MatrixWorkspace &ws, Kernel::Logger &logger, - const std::string &sampleLogsSum = "", - const std::string &sampleLogsTimeSeries = "", - const std::string &sampleLogsList = "", - const std::string &sampleLogsWarn = "", - const std::string &sampleLogsWarnTolerances = "", - const std::string &sampleLogsFail = "", - const std::string &sampleLogsFailTolerances = ""); + SampleLogsBehaviour( + API::MatrixWorkspace &ws, Kernel::Logger &logger, + const std::string &sampleLogsSum = "", + const std::string &sampleLogsTimeSeries = "", + const std::string &sampleLogsList = "", + const std::string &sampleLogsWarn = "", + const std::string &sampleLogsWarnTolerances = "", + const std::string &sampleLogsFail = "", + const std::string &sampleLogsFailTolerances = "", + const std::string &sum_merge = "sample_logs_sum", + const std::string &time_series_merge = "sample_logs_time_series", + const std::string &list_merge = "sample_logs_list", + const std::string &warn_merge = "sample_logs_warn", + const std::string &warn_merge_tolerances = "sample_logs_warn_tolerances", + const std::string &fail_merge = "sample_logs_fail", + const std::string &fail_merge_tolerances = "sample_logs_fail_tolerances"); /// Create and update sample logs according to instrument parameters void mergeSampleLogs(API::MatrixWorkspace &addeeWS, diff --git a/Framework/Algorithms/src/ConjoinXRuns.cpp b/Framework/Algorithms/src/ConjoinXRuns.cpp index b397f9b5075..2a29dd36232 100644 --- a/Framework/Algorithms/src/ConjoinXRuns.cpp +++ b/Framework/Algorithms/src/ConjoinXRuns.cpp @@ -360,8 +360,10 @@ void ConjoinXRuns::exec() { SampleLogsBehaviour sampleLogsBehaviour = SampleLogsBehaviour( *first, g_log, sampleLogsSum, sampleLogsTimeSeries, sampleLogsList, sampleLogsWarn, sampleLogsWarnTolerances, sampleLogsFail, - sampleLogsFailTolerances); - + sampleLogsFailTolerances, "conjoin_sample_logs_sum", + "conjoin_sample_logs_time_series", "conjoin_sample_logs_list", + "conjoin_sample_logs_warn", "conjoin_sample_logs_warn_tolerances", + "conjoin_sample_logs_fail", "conjoin_sample_logs_fail_tolerances"); auto it = m_inputWS.begin(); // Temporary workspace to carry the merged sample logs diff --git a/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp b/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp index d3f83008795..e7d376003d7 100644 --- a/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp +++ b/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp @@ -5,6 +5,7 @@ // & Institut Laue - Langevin // SPDX - License - Identifier: GPL - 3.0 + #include "MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h" +#include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" #include "MantidGeometry/Instrument.h" #include "MantidKernel/StringTokenizer.h" @@ -31,20 +32,10 @@ std::string generateDifferenceMessage(const std::string &item, return stringstream.str(); } } // namespace -const std::string SampleLogsBehaviour::SUM_MERGE = "sample_logs_sum"; -const std::string SampleLogsBehaviour::TIME_SERIES_MERGE = - "sample_logs_time_series"; -const std::string SampleLogsBehaviour::LIST_MERGE = "sample_logs_list"; -const std::string SampleLogsBehaviour::WARN_MERGE = "sample_logs_warn"; -const std::string SampleLogsBehaviour::FAIL_MERGE = "sample_logs_fail"; -const std::string SampleLogsBehaviour::WARN_MERGE_TOLERANCES = - "sample_logs_warn_tolerances"; -const std::string SampleLogsBehaviour::FAIL_MERGE_TOLERANCES = - "sample_logs_fail_tolerances"; // Names and docs from the properties allowing to override the default (IPF // controlled) merging behaviour. -// These are common between e.g. MergeRuns and JoinWorkspaces. +// These are common between e.g. MergeRuns and ConjoinXRuns. const std::string SampleLogsBehaviour::TIME_SERIES_PROP = "SampleLogsTimeSeries"; const std::string SampleLogsBehaviour::TIME_SERIES_DOC = @@ -108,6 +99,15 @@ const std::string SampleLogsBehaviour::SUM_DOC = * throwing an error when different on merging * @param sampleLogsFailTolerances a string with a single value or comma * separated list of values for the error tolerances + * @param sum_merge parameter name in IPF of logs to be summed + * @param fail_merge parameter name in IPF of logs which must be identical + * @param time_series_merge parameter name in IPF of logs for the time series + *merge + * @param list_merge parameter name in IPF of logs to be listed + * @param warn_merge parameter name in IPF of logs which log a warning if + *different + * @param warn_merge_tolerances parameter name in IPF of warning tolerances + * @param fail_merge_tolerances parameter name in IPF of failure tolerances * @return An instance of SampleLogsBehaviour initialised with the merge types * from the IPF and parent algorithm */ @@ -117,8 +117,14 @@ SampleLogsBehaviour::SampleLogsBehaviour( const std::string &sampleLogsWarn, const std::string &sampleLogsWarnTolerances, const std::string &sampleLogsFail, - const std::string &sampleLogsFailTolerances) - : m_logger(logger) { + const std::string &sampleLogsFailTolerances, const std::string &sum_merge, + const std::string &time_series_merge, const std::string &list_merge, + const std::string &warn_merge, const std::string &warn_merge_tolerances, + const std::string &fail_merge, const std::string &fail_merge_tolerances) + : SUM_MERGE(sum_merge), TIME_SERIES_MERGE(time_series_merge), + LIST_MERGE(list_merge), WARN_MERGE(warn_merge), + WARN_MERGE_TOLERANCES(warn_merge_tolerances), FAIL_MERGE(fail_merge), + FAIL_MERGE_TOLERANCES(fail_merge_tolerances), m_logger(logger) { setSampleMap(m_logMap, MergeLogType::Sum, sampleLogsSum, ws, ""); setSampleMap(m_logMap, MergeLogType::TimeSeries, sampleLogsTimeSeries, ws, ""); @@ -442,8 +448,8 @@ void SampleLogsBehaviour::mergeSampleLogs(MatrixWorkspace &addeeWS, Property *addeeWSProperty = addeeWS.getLog(logName); - double addeeWSNumericValue = 0; - double outWSNumericValue = 0; + double addeeWSNumericValue = 0.; + double outWSNumericValue = 0.; try { addeeWSNumericValue = addeeWS.getLogAsSingleValue(logName); diff --git a/docs/source/algorithms/ConjoinXRuns-v1.rst b/docs/source/algorithms/ConjoinXRuns-v1.rst index 11ffcd0a020..1d085dae1f7 100644 --- a/docs/source/algorithms/ConjoinXRuns-v1.rst +++ b/docs/source/algorithms/ConjoinXRuns-v1.rst @@ -10,7 +10,7 @@ Description ----------- -This algorithm joins the input workspaces into a single one by concatenating their spectra. The concatenation is done in the same order as in the input workspaces list. Consider using :ref:`SortXAxis <algm-SortXAxis>` afterwards, if necessary. The instrument and the units are copied from the first workspace. The sample logs are also copied from the first input, but the behaviour can be controlled by the instrument parameter file (IPF), as described in :ref:`MergeRuns <algm-MergeRuns>`. Furthermore, that behaviour can be overridden by providing input to the relevant optional properties of the algorithm. This algorithm joins Dx values, if present. +This algorithm joins the input workspaces into a single one by concatenating their spectra. The concatenation is done in the same order as in the input workspaces list. Consider using :ref:`SortXAxis <algm-SortXAxis>` afterwards, if necessary. The instrument and the units are copied from the first workspace. The sample logs are also copied from the first input, but the behaviour can be controlled by the instrument parameter file (IPF), as described in :ref:`MergeRuns <algm-MergeRuns>` but all parameter names must have the suffix `conjoin_`. Furthermore, that behaviour can be overridden by providing input to the relevant optional properties of the algorithm. This algorithm joins Dx values, if present. InputWorkspaces --------------- diff --git a/docs/source/algorithms/Stitch1D-v3.rst b/docs/source/algorithms/Stitch1D-v3.rst index f7a2ef375ba..e0b3fd6db0e 100644 --- a/docs/source/algorithms/Stitch1D-v3.rst +++ b/docs/source/algorithms/Stitch1D-v3.rst @@ -75,7 +75,8 @@ The algorithm workflow for point data is as follows: #. Alternatively, if :literal:`UseManualScaleFactor` was set to true, the scale factor is applied to the right-hand-side workspace (left-hand-side workspace if :literal:`ScaleRHSWorkspace` was set to false). -#. The output workspace will be created by joining and sorted to guarantee ascending x values. +#. The output workspace will be created by joining using :ref:`algm-ConjoinXRuns` and sorting using + :ref:`algm-SortXAxis`. Dx values will be present in the output workspace. Error propagation diff --git a/instrument/FIGARO_Parameters.xml b/instrument/FIGARO_Parameters.xml index 4d42fca9126..ddd6abc72d6 100644 --- a/instrument/FIGARO_Parameters.xml +++ b/instrument/FIGARO_Parameters.xml @@ -24,5 +24,24 @@ <parameter name="sample_logs_fail_tolerances" type="string"> <value val="0, 0, 0, 0" /> </parameter> + <!-- ConjoinXRuns behavior when merging sample logs when using Stitch1D or Stitch1DMany. --> + <parameter name="conjoin_sample_logs_sum" type="string"> + <value val="" /> + </parameter> + <parameter name="conjoin_sample_logs_time_series" type="string"> + <value val="" /> + </parameter> + <parameter name="conjoin_sample_logs_warn" type="string"> + <value val="" /> + </parameter> + <parameter name="conjoin_sample_logs_warn_tolerances" type="string"> + <value val="" /> + </parameter> + <parameter name="conjoin_sample_logs_fail" type="string"> + <value val="" /> + </parameter> + <parameter name="conjoin_sample_logs_fail_tolerances" type="string"> + <value val="" /> + </parameter> </component-link> </parameter-file> -- GitLab