Commit 6111b028 authored by Gagik Vardanyan's avatar Gagik Vardanyan
Browse files

added unit test for the new option

parent 989d7d51
......@@ -152,7 +152,7 @@ void LoadILLDiffraction::exec() {
progress.report("Setting additional sample logs");
setSampleLogs();
if (m_instName != "D2B" && m_scanType == NoScan &&
if (m_instName != "D2B" && m_scanType != DetectorScan &&
getProperty("ConvertAxisAndTranspose"))
convertAxisAndTranspose();
......@@ -912,22 +912,25 @@ void LoadILLDiffraction::computeThetaOffset() {
* Converts the spectrum axis to 2theta and transposes the workspace.
*/
void LoadILLDiffraction::convertAxisAndTranspose() {
auto extractor = createChildAlgorithm("ExtractMonitors");
auto extractor = createChildAlgorithm("ExtractSpectra");
extractor->setProperty("InputWorkspace", m_outWorkspace);
extractor->setProperty("DetectorWorkspace", "__unused");
extractor->setProperty("StartWorkspaceIndex", 1);
extractor->setProperty("OutputWorkspace", "__unused");
extractor->execute();
API::MatrixWorkspace_sptr det = extractor->getProperty("DetectorWorkspace");
API::MatrixWorkspace_sptr det = extractor->getProperty("OutputWorkspace");
auto converter = createChildAlgorithm("ConvertSpectrumAxis");
converter->setProperty("InputWorkspace", det);
converter->setProperty("OutputWorkspace", "__unused");
converter->setProperty("Target", "SignedTheta");
converter->execute();
API::MatrixWorkspace_sptr converted = converter->getProperty("OutputWorkspace");
API::MatrixWorkspace_sptr converted =
converter->getProperty("OutputWorkspace");
auto transposer = createChildAlgorithm("Transpose");
transposer->setProperty("InputWorkspace", converted);
transposer->setProperty("OutputWorkspace", "__unused");
transposer->execute();
API::MatrixWorkspace_sptr transposed = transposer->getProperty("OutputWorkspace");
API::MatrixWorkspace_sptr transposed =
transposer->getProperty("OutputWorkspace");
m_outWorkspace = transposed;
}
......
......@@ -9,6 +9,8 @@
#include <cxxtest/TestSuite.h>
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/Axis.h"
#include "MantidAPI/FrameworkManager.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAPI/Run.h"
#include "MantidDataHandling/Load.h"
......@@ -16,6 +18,7 @@
#include "MantidGeometry/Instrument/DetectorInfo.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/FacilityInfo.h"
#include "MantidKernel/Unit.h"
#include "MantidKernel/V3D.h"
using namespace Mantid::API;
......@@ -60,6 +63,29 @@ public:
TS_ASSERT(alg.isInitialized());
}
void test_D20_transposed_2theta() {
// Tests the axis conversion and transposition
// for non-detector scan D20 data from cycle 203
LoadILLDiffraction alg;
alg.setChild(true);
TS_ASSERT_THROWS_NOTHING(alg.initialize())
TS_ASSERT(alg.isInitialized())
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filename", "170607.nxs"))
TS_ASSERT_THROWS_NOTHING(
alg.setPropertyValue("OutputWorkspace", "_unused_for_child"))
TS_ASSERT_THROWS_NOTHING(
alg.setProperty("ConvertAxisAndTranspose", true))
TS_ASSERT_THROWS_NOTHING(alg.execute())
TS_ASSERT(alg.isExecuted())
MatrixWorkspace_sptr outputWS = alg.getProperty("OutputWorkspace");
TS_ASSERT(outputWS)
TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), 1)
TS_ASSERT_EQUALS(outputWS->blocksize(), 3072)
TS_ASSERT(!outputWS->isHistogramData())
TS_ASSERT(!outputWS->isDistribution())
TS_ASSERT_EQUALS(outputWS->getAxis(0)->unit()->unitID(), "Degrees")
}
void test_D20_no_scan() {
// Tests the no-scan case for D20
// Temperature ramp is not a motor scan so produces a file per T
......
b4f84fe2c4e91579bef17f1b4bf5c4a8
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