Skip to content
Snippets Groups Projects
Commit aebe6ac3 authored by Simon Heybrock's avatar Simon Heybrock
Browse files

Re #13236 Added test that exposes the WedgeOffset bug in Q1DWeigthed.

parent cccb5d7a
No related branches found
No related tags found
No related merge requests found
......@@ -92,6 +92,112 @@ public:
}
// Test whether the WedgeOffset parameter works correctly.
void testWedgeOffset() {
// Setup is copied from testExec().
Mantid::DataHandling::LoadSpice2D loader;
loader.initialize();
loader.setPropertyValue("Filename", "BioSANS_exp61_scan0004_0001.xml");
const std::string inputWS("wav");
loader.setPropertyValue("OutputWorkspace", inputWS);
loader.execute();
// Move detector to its correct position
Mantid::DataHandling::MoveInstrumentComponent mover;
mover.initialize();
mover.setPropertyValue("Workspace", inputWS);
mover.setPropertyValue("ComponentName", "detector1");
// According to the instrument geometry, the center of the detector is
// located at N_pixel / 2 + 0.5
// X = (16-192.0/2.0+0.5)*5.15/1000.0 = -0.409425
// Y = (95-192.0/2.0+0.5)*5.15/1000.0 = -0.002575
mover.setPropertyValue("X", "0.409425");
mover.setPropertyValue("Y", "0.002575");
mover.execute();
const std::string outputWS("result");
const std::string wedgeWS1("wedge1");
const std::string wedgeWS2("wedge2");
// Test method:
// We use two wedges, which implies that they have an offset of 90 degree.
// We then call the algorithm twice, once with offset 0, once with offset
// 90. With offset 90 the wedges are thus logically "swapped", so we check
// if their values match.
if (!radial_average.isInitialized())
radial_average.initialize();
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("InputWorkspace", inputWS))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("OutputWorkspace", outputWS))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("OutputBinning", "0.01,0.001,0.11"))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("NPixelDivision", "3"))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("ErrorWeighting", "1"))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("WedgeWorkspace", wedgeWS1))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("NumberOfWedges", "2"))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("WedgeAngle", "30"))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("WedgeOffset", "0"))
TS_ASSERT_THROWS_NOTHING(radial_average.execute())
TS_ASSERT(radial_average.isExecuted())
if (!radial_average.isInitialized())
radial_average.initialize();
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("InputWorkspace", inputWS))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("OutputWorkspace", outputWS))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("OutputBinning", "0.01,0.001,0.11"))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("NPixelDivision", "3"))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("ErrorWeighting", "1"))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("WedgeWorkspace", wedgeWS2))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("NumberOfWedges", "2"))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("WedgeAngle", "30"))
TS_ASSERT_THROWS_NOTHING(
radial_average.setPropertyValue("WedgeOffset", "90"))
TS_ASSERT_THROWS_NOTHING(radial_average.execute())
TS_ASSERT(radial_average.isExecuted())
// Get wedge 0 of the result with offset 0.
auto result1 = boost::dynamic_pointer_cast<Mantid::API::WorkspaceGroup>(
Mantid::API::AnalysisDataService::Instance().retrieve(wedgeWS1));
auto wedge1 = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
result1->getItem(0));
// Get wedge 1 of the result with offset 90.
auto result2 = boost::dynamic_pointer_cast<Mantid::API::WorkspaceGroup>(
Mantid::API::AnalysisDataService::Instance().retrieve(wedgeWS2));
auto wedge2 = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
result2->getItem(1));
double tolerance = 1e-12;
// The two wedges shold be identical.
for (size_t i = 0; i < wedge1->dataY(0).size(); ++i)
TS_ASSERT_DELTA(wedge1->dataY(0)[i], wedge2->dataY(0)[i], tolerance);
Mantid::API::AnalysisDataService::Instance().remove(inputWS);
Mantid::API::AnalysisDataService::Instance().remove(outputWS);
Mantid::API::AnalysisDataService::Instance().remove(wedgeWS1);
Mantid::API::AnalysisDataService::Instance().remove(wedgeWS2);
}
private:
Mantid::Algorithms::Q1DWeighted radial_average;
std::string inputWS;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment