Commit 6948afc9 authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Add tests for validity range in IPF

parent 4e7768ac
......@@ -11,6 +11,7 @@
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/Run.h"
#include "MantidAPI/Workspace.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidDataObjects/Workspace2D.h"
......@@ -231,6 +232,41 @@ public:
TS_ASSERT(pLoadInstrument->isExecuted());
}
void test_load_IPF_time_validity() {
auto ws = AnalysisDataService::Instance().retrieve(wsName);
Workspace2D_sptr ws2D = std::dynamic_pointer_cast<Workspace2D>(ws);
// set a date for the experiment
std::string start_time = "1900-01-01 00:00:00";
ws2D->mutableRun().addProperty("run_start", start_time);
// load in additional parameters
auto pLoaderPF = AlgorithmManager::Instance().create("LoadParameterFile");
TS_ASSERT_THROWS_NOTHING(pLoaderPF->initialize());
pLoaderPF->setPropertyValue(
"Filename",
"unit_testing/IDF_for_UNIT_TESTING2_paramFile_with_dates.xml");
pLoaderPF->setPropertyValue("Workspace", wsName);
TS_ASSERT_THROWS_NOTHING(pLoaderPF->execute());
TS_ASSERT(pLoaderPF->isExecuted());
MatrixWorkspace_sptr output;
// Get back the saved workspace
TS_ASSERT_THROWS_NOTHING(
output = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(
wsName));
const auto &paramMap = output->constInstrumentParameters();
const auto &detectorInfo = output->detectorInfo();
const auto &det = detectorInfo.detector(detectorInfo.indexOf(1008));
Parameter_sptr param = paramMap.get(&det, "date-most-recent");
TS_ASSERT_EQUALS(param->value<double>(), 1);
param = paramMap.get(&det, "date-within-bound");
TS_ASSERT_EQUALS(param->value<double>(), 1);
param = paramMap.get(&det, "date-no-bounds");
TS_ASSERT_EQUALS(param->value<double>(), 1);
}
private:
std::string inputFile;
std::string wsName;
......
<?xml version="1.0" encoding="UTF-8" ?>
<parameter-file instrument="IDF_for_UNIT_TESTING2" valid-from="blah...">
<component-link name="IDF_for_UNIT_TESTING2.xml/combined translation6" >
<parameter name="date-most-recent">
<value val="0" valid-from="1850-01-01T00:00:00" valid-to="1950-01-01T00:00:00"/>
<value val="1" valid-from="1875-01-01T00:00:00"/>
</parameter>
<parameter name="date-within-bound">
<value val="0" valid-from="1875-01-01T00:00:00" valid-to="1890-01-01T00:00:00"/>
<value val="1" valid-from="1850-01-01T00:00:00" valid-to="1950-01-01T00:00:00"/>
</parameter>
<parameter name="date-no-bounds">
<value val="0"/>
<value val="1" valid-to="2000-01-01T00:00:00"/>
</parameter>
</component-link>
</parameter-file>
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