Skip to content
Snippets Groups Projects
Commit deebdcb7 authored by Neil Vaytet's avatar Neil Vaytet
Browse files

Refs #23755 : added test for Nexus instrument loading

parent 023808ef
No related branches found
No related tags found
No related merge requests found
......@@ -12,32 +12,10 @@
namespace Mantid {
namespace DataHandling {
/**
Loads an instrument definition file into a workspace, with the purpose of being
able to visualise an instrument without requiring to read in a ISIS raw datafile
first.
The name of the algorithm refers to the fact that an instrument
is loaded into a workspace but without any real data - hence the reason for
referring to
it as an 'empty' instrument.
Common methods for LoadInstrument.cpp and LoadEmptyInstrument.cpp
Required Properties:
<UL>
<LI> Filename - The name of an instrument definition file </LI>
<LI> OutputWorkspace - The name of the workspace in which to store the imported
instrument</LI>
</UL>
Optional Properties: (note that these options are not available if reading a
multiperiod file)
<UL>
<LI> detector_value - This value affect the colour of the detectorss in the
instrument display window</LI>
<LI> monitor_value - This value affect the colour of the monitors in the
instrument display window</LI>
</UL>
@author Anders Markvardsen, ISIS, RAL
@date 31/10/2008
@author Neil Vaytet, ESS
@date 01/11/2018
*/
namespace LoadGeometry {
......
......@@ -28,7 +28,6 @@
#include <Poco/File.h>
#include <Poco/Path.h>
#include <fstream>
#include <iostream>
#include <sstream>
namespace Mantid {
......
......@@ -16,6 +16,7 @@
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidGeometry/Instrument.h"
#include "MantidGeometry/Instrument/ComponentInfo.h"
#include "MantidGeometry/Instrument/DetectorInfo.h"
#include "MantidGeometry/Instrument/FitParameter.h"
#include "MantidHistogramData/LinearGenerator.h"
......@@ -293,6 +294,54 @@ public:
AnalysisDataService::Instance().remove(wsName);
}
void testExecLOKI() {
LoadInstrument loaderLOKI;
TS_ASSERT_THROWS_NOTHING(loaderLOKI.initialize());
// // create a workspace with some sample data
wsName = "LoadInstrumentTestLOKI";
Workspace_sptr ws =
WorkspaceFactory::Instance().create("Workspace2D", 1, 1, 1);
Workspace2D_sptr ws2D = boost::dynamic_pointer_cast<Workspace2D>(ws);
// put this workspace in the data service
TS_ASSERT_THROWS_NOTHING(AnalysisDataService::Instance().add(wsName, ws2D));
const std::string definitionFile = "LOKI_Definition.hdf5";
loaderLOKI.setPropertyValue("Filename", definitionFile);
loaderLOKI.setPropertyValue("Workspace", wsName);
loaderLOKI.setProperty("RewriteSpectraMap", OptionalBool(true));
inputFile = loaderLOKI.getPropertyValue("Filename");
std::string result;
TS_ASSERT_THROWS_NOTHING(result =
loaderLOKI.getPropertyValue("Filename"));
TS_ASSERT(!result.compare(inputFile));
TS_ASSERT_THROWS_NOTHING(result =
loaderLOKI.getPropertyValue("Workspace"));
TS_ASSERT(!result.compare(wsName));
TS_ASSERT_THROWS_NOTHING(loaderLOKI.execute());
TS_ASSERT(loaderLOKI.isExecuted());
// Get back the saved workspace
MatrixWorkspace_sptr outputWs;
TS_ASSERT_THROWS_NOTHING(
outputWs = loaderLOKI.getProperty("Workspace"));
auto &componentInfo = outputWs->componentInfo();
auto &detectorInfo = outputWs->detectorInfo();
TS_ASSERT_EQUALS(componentInfo.name(componentInfo.root()), "LOKI");
TS_ASSERT_EQUALS(detectorInfo.size(), 8000);
TS_ASSERT_EQUALS(0, detectorInfo.detectorIDs()[0])
TS_ASSERT_EQUALS(1, detectorInfo.detectorIDs()[1])
}
void testExecHRP2() {
// Test Parameter file in instrument folder is used by an IDF file not in
// the instrument folder
......
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