Commit 00768187 authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Store ILL run date in start_time

To be coherent in all of ILL loaders, the "run_start" parameter is
changed to "start_time".
Because it is needed before all the parameters are loaded, the start time
needs to be loaded separately. Since this would conflict with its later
add, a change is made so that it is overwritten in the parameters
loading phase.
Then, tests are modified accordingly.
parent 9c7262fb
......@@ -267,8 +267,14 @@ void LoadHelper::recurseAndAddNexusFieldsToWsRun(NXhandle nxfileID,
if (boost::algorithm::ends_with(property_name, "_time")) {
// That's a time value! Convert to Mantid standard
property_value = dateTimeInIsoFormat(property_value);
if (runDetails.hasProperty(property_name))
runDetails.getProperty(property_name)
->setValue(property_value);
else
runDetails.addProperty(property_name, property_value);
} else {
runDetails.addProperty(property_name, property_value);
}
runDetails.addProperty(property_name, property_value);
} else if ((type == NX_FLOAT32) || (type == NX_FLOAT64) ||
(type == NX_INT16) || (type == NX_INT32) ||
......
......@@ -283,7 +283,8 @@ void LoadILLDiffraction::initStaticWorkspace(const std::string &start_time) {
m_outWorkspace = WorkspaceFactory::Instance().create("Workspace2D", nSpectra,
nBins, nBins);
m_outWorkspace->mutableRun().addProperty("run_start", start_time);
// the start time is needed in the workspace when loading the parameter file
m_outWorkspace->mutableRun().addProperty("start_time", start_time);
}
/**
......@@ -808,7 +809,10 @@ LoadILLDiffraction::loadEmptyInstrument(const std::string &start_time) {
loadInst->setPropertyValue("InstrumentName", m_instName);
auto ws = WorkspaceFactory::Instance().create("Workspace2D", 1, 1, 1);
auto &run = ws->mutableRun();
run.addProperty("run_start", start_time);
// the start time is needed in the workspace when loading the parameter file
run.addProperty("start_time", start_time);
loadInst->setProperty<MatrixWorkspace_sptr>("Workspace", ws);
loadInst->setProperty("RewriteSpectraMap", OptionalBool(true));
loadInst->execute();
......
......@@ -328,9 +328,8 @@ LoadILLPolarizedDiffraction::initStaticWorkspace(const NXEntry &entry) {
void LoadILLPolarizedDiffraction::loadInstrument(
API::MatrixWorkspace_sptr workspace, std::string startTime) {
// the instrument and parameter loaders need to know the time the data was
// measured to choose the correct version
workspace->mutableRun().addProperty("run_start", startTime);
// the start time is needed in the workspace when loading the parameter file
workspace->mutableRun().addProperty("start_time", startTime);
IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument");
loadInst->setPropertyValue("Filename", m_instName + "_Definition.xml");
......
......@@ -386,7 +386,7 @@ void LoadILLReflectometry::initWorkspace(
// the start time is needed in the workspace when loading the parameter file
m_localWorkspace->mutableRun().addProperty<std::string>(
"run_start", m_startTime.toISO8601String());
"start_time", m_startTime.toISO8601String());
}
/**
......
......@@ -748,11 +748,10 @@ void LoadILLSANS::loadMetaData(const NeXus::NXEntry &entry,
const double duration = entry.getFloat("duration");
runDetails.addProperty<double>("timer", duration);
// Get the starting date of the measure, as it is needed by the instrument and
// parameter loaders later
// the start time is needed in the workspace when loading the parameter file
std::string startDate = entry.getString("start_time");
runDetails.addProperty<std::string>(
"run_start", m_loadHelper.dateTimeInIsoFormat(startDate));
"start_time", m_loadHelper.dateTimeInIsoFormat(startDate));
}
/**
......
......@@ -651,9 +651,9 @@ public:
}
void checkTimeFormat(MatrixWorkspace_const_sptr outputWS) {
TS_ASSERT(outputWS->run().hasProperty("run_start"));
TS_ASSERT(outputWS->run().hasProperty("start_time"));
TS_ASSERT(Mantid::Types::Core::DateAndTimeHelpers::stringIsISO8601(
outputWS->run().getProperty("run_start")->value()));
outputWS->run().getProperty("start_time")->value()));
}
private:
......
......@@ -57,9 +57,9 @@ private:
// sample log entry must exist
TS_ASSERT(output->run().hasProperty("reduction.line_position"))
TS_ASSERT(output->run().hasProperty("run_start"));
TS_ASSERT(output->run().hasProperty("start_time"));
TS_ASSERT(Mantid::Types::Core::DateAndTimeHelpers::stringIsISO8601(
output->run().getProperty("run_start")->value()));
output->run().getProperty("start_time")->value()));
}
static double detCounts(const MatrixWorkspace_sptr &output) {
......
......@@ -268,9 +268,9 @@ public:
}
void checkTimeFormat(MatrixWorkspace_const_sptr outputWS) {
TS_ASSERT(outputWS->run().hasProperty("run_start"));
TS_ASSERT(outputWS->run().hasProperty("start_time"));
TS_ASSERT(Mantid::Types::Core::DateAndTimeHelpers::stringIsISO8601(
outputWS->run().getProperty("run_start")->value()));
outputWS->run().getProperty("start_time")->value()));
}
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment