Commit a71bdc65 authored by Dominik Arominski's avatar Dominik Arominski
Browse files

Added option to have TOF data in time channels or uncalibrated time

parent 53d6bb6b
......@@ -120,6 +120,11 @@ void LoadILLPolarizedDiffraction::init() {
declareProperty("TransposeMonochromatic", false,
"Transpose the 2D workspace with monochromatic data",
Direction::Input);
const std::vector<std::string> TOFUnitOptions{"UncalibratedTime",
"TimeChannels"};
declareProperty("TOFUnits", TOFUnitOptions[0],
std::make_shared<StringListValidator>(TOFUnitOptions),
"Transpose the 2D workspace with monochromatic data");
}
std::map<std::string, std::string>
......@@ -286,13 +291,20 @@ LoadILLPolarizedDiffraction::initStaticWorkspace(const NXEntry &entry) {
acquisitionMode.load();
m_acquisitionMode = acquisitionMode[0];
if (m_acquisitionMode == TOF_MODE_ON) {
workspace->getAxis(0)->unit() = UnitFactory::Instance().create("Time");
if (getPropertyValue("TOFUnits") == "TimeChannels") {
std::shared_ptr<Kernel::Units::Label> lblUnit =
std::dynamic_pointer_cast<Kernel::Units::Label>(
UnitFactory::Instance().create("Label"));
lblUnit->setLabel("Time channel", Units::Symbol::EmptyLabel);
workspace->getAxis(0)->unit() = lblUnit;
} else {
workspace->getAxis(0)->unit() = UnitFactory::Instance().create("Time");
}
} else {
workspace->getAxis(0)->unit() =
UnitFactory::Instance().create("Wavelength");
}
// Set y axis unit
workspace->setYUnit("Counts");
// check the polarization direction and set the workspace title
......@@ -413,12 +425,17 @@ LoadILLPolarizedDiffraction::prepareAxes(const NXEntry &entry) {
if (acquisitionMode[0] == TOF_MODE_ON) {
NXFloat timeOfFlightInfo = entry.openNXFloat("D7/Detector/time_of_flight");
timeOfFlightInfo.load();
auto channelWidth = static_cast<double>(timeOfFlightInfo[0]);
m_numberOfChannels = size_t(timeOfFlightInfo[1]);
auto channelWidth = static_cast<double>(timeOfFlightInfo[0]);
auto tofDelay = timeOfFlightInfo[2];
for (auto channel_no = 0;
channel_no <= static_cast<int>(m_numberOfChannels); channel_no++) {
axes.push_back(static_cast<double>(tofDelay + channel_no * channelWidth));
if (getPropertyValue("TOFUnits") == "UncalibratedTime") {
axes.push_back(
static_cast<double>(tofDelay + channel_no * channelWidth));
} else {
axes.push_back(static_cast<double>(channel_no));
}
}
} else {
m_numberOfChannels = 1;
......
......@@ -154,6 +154,8 @@ public:
std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
outputWS->getItem(0));
TS_ASSERT(workspaceEntry1)
TS_ASSERT_EQUALS(workspaceEntry1->getAxis(0)->unit()->unitID(), "Time")
TS_ASSERT_EQUALS(workspaceEntry1->getAxis(0)->unit()->caption(), "t")
TS_ASSERT_DELTA(workspaceEntry1->x(0)[0], 180.00, 0.01)
TS_ASSERT_DELTA(workspaceEntry1->x(0)[1], 186.64, 0.01)
......@@ -216,6 +218,95 @@ public:
TS_ASSERT_DELTA(workspaceEntry1->e(133)[511], 0.00, 0.01)
}
void test_D7_timeOfFlight_timechannels() {
// Tests loading TOF data for D7
LoadILLPolarizedDiffraction alg;
alg.setChild(true);
TS_ASSERT_THROWS_NOTHING(alg.initialize())
TS_ASSERT(alg.isInitialized())
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filename", "395850"))
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "_outWS"))
TS_ASSERT_THROWS_NOTHING(
alg.setPropertyValue("PositionCalibration", "None"))
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("TOFUnits", "TimeChannels"))
TS_ASSERT_THROWS_NOTHING(alg.execute())
TS_ASSERT(alg.isExecuted())
WorkspaceGroup_sptr outputWS = alg.getProperty("OutputWorkspace");
TS_ASSERT(outputWS)
TS_ASSERT(outputWS->isGroup())
TS_ASSERT_EQUALS(outputWS->getNumberOfEntries(), 2)
do_test_general_features(outputWS, "TOF");
MatrixWorkspace_sptr workspaceEntry1 =
std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
outputWS->getItem(0));
TS_ASSERT(workspaceEntry1)
TS_ASSERT_EQUALS(workspaceEntry1->getAxis(0)->unit()->unitID(), "Label")
TS_ASSERT_EQUALS(workspaceEntry1->getAxis(0)->unit()->caption(),
"Time channel")
TS_ASSERT_EQUALS(workspaceEntry1->x(0)[0], 0)
TS_ASSERT_EQUALS(workspaceEntry1->x(0)[1], 1)
TS_ASSERT_EQUALS(workspaceEntry1->y(0)[0], 0)
TS_ASSERT_DELTA(workspaceEntry1->e(0)[0], 0.00, 0.01)
TS_ASSERT_EQUALS(workspaceEntry1->x(0)[511], 511)
TS_ASSERT_EQUALS(workspaceEntry1->x(0)[512], 512)
TS_ASSERT_EQUALS(workspaceEntry1->y(0)[511], 0)
TS_ASSERT_DELTA(workspaceEntry1->e(0)[511], 0.00, 0.01)
TS_ASSERT_EQUALS(workspaceEntry1->x(1)[0], 0)
TS_ASSERT_EQUALS(workspaceEntry1->x(1)[1], 1)
TS_ASSERT_EQUALS(workspaceEntry1->y(1)[0], 0)
TS_ASSERT_DELTA(workspaceEntry1->e(1)[0], 0.00, 0.01)
TS_ASSERT_EQUALS(workspaceEntry1->x(1)[511], 511)
TS_ASSERT_EQUALS(workspaceEntry1->x(1)[512], 512)
TS_ASSERT_EQUALS(workspaceEntry1->y(1)[511], 0)
TS_ASSERT_DELTA(workspaceEntry1->e(1)[511], 0.00, 0.01)
TS_ASSERT_EQUALS(workspaceEntry1->x(130)[0], 0)
TS_ASSERT_EQUALS(workspaceEntry1->x(130)[1], 1)
TS_ASSERT_EQUALS(workspaceEntry1->y(130)[0], 0)
TS_ASSERT_DELTA(workspaceEntry1->e(130)[0], 0.00, 0.01)
TS_ASSERT_EQUALS(workspaceEntry1->x(130)[365], 365)
TS_ASSERT_EQUALS(workspaceEntry1->x(130)[366], 366)
TS_ASSERT_EQUALS(workspaceEntry1->y(130)[365], 0)
TS_ASSERT_DELTA(workspaceEntry1->e(130)[365], 0.00, 0.01)
TS_ASSERT_EQUALS(workspaceEntry1->x(131)[0], 0)
TS_ASSERT_EQUALS(workspaceEntry1->x(131)[1], 1)
TS_ASSERT_EQUALS(workspaceEntry1->y(131)[0], 0)
TS_ASSERT_DELTA(workspaceEntry1->e(131)[0], 0.00, 0.01)
TS_ASSERT_EQUALS(workspaceEntry1->x(131)[365], 365)
TS_ASSERT_EQUALS(workspaceEntry1->x(131)[366], 366)
TS_ASSERT_EQUALS(workspaceEntry1->y(131)[365], 1)
TS_ASSERT_DELTA(workspaceEntry1->e(131)[365], 1.00, 0.01)
TS_ASSERT_EQUALS(workspaceEntry1->x(132)[0], 0)
TS_ASSERT_EQUALS(workspaceEntry1->x(132)[1], 1)
TS_ASSERT_EQUALS(workspaceEntry1->y(132)[0], 5468)
TS_ASSERT_DELTA(workspaceEntry1->e(132)[0], 73.94, 0.01)
TS_ASSERT_EQUALS(workspaceEntry1->x(132)[511], 511)
TS_ASSERT_EQUALS(workspaceEntry1->x(132)[512], 512)
TS_ASSERT_EQUALS(workspaceEntry1->y(132)[511], 5394)
TS_ASSERT_DELTA(workspaceEntry1->e(132)[511], 73.44, 0.01)
TS_ASSERT_EQUALS(workspaceEntry1->x(133)[0], 0)
TS_ASSERT_EQUALS(workspaceEntry1->x(133)[1], 1)
TS_ASSERT_EQUALS(workspaceEntry1->y(133)[0], 0)
TS_ASSERT_DELTA(workspaceEntry1->e(133)[0], 0.00, 0.01)
TS_ASSERT_EQUALS(workspaceEntry1->x(133)[511], 511)
TS_ASSERT_EQUALS(workspaceEntry1->x(133)[512], 512)
TS_ASSERT_EQUALS(workspaceEntry1->y(133)[511], 0)
TS_ASSERT_DELTA(workspaceEntry1->e(133)[511], 0.00, 0.01)
}
void test_D7_multifile_sum() {
// Tests loading and adding 2 files for D7 with the generic Load on ADS
// This tests indirectly the confidence method
......@@ -625,10 +716,7 @@ public:
TS_ASSERT_EQUALS(workspaceEntry->getAxis(0)->unit()->unitID(),
"Wavelength")
} else if (measurementMode == "TOF") {
{
TS_ASSERT_EQUALS(workspaceEntry->getAxis(0)->unit()->unitID(), "Time")
TS_ASSERT_EQUALS(workspaceEntry->blocksize(), 512)
}
{ TS_ASSERT_EQUALS(workspaceEntry->blocksize(), 512) }
}
}
}
......
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