diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadGeometry.h b/Framework/DataHandling/inc/MantidDataHandling/LoadGeometry.h index e01e4d07e460c275a3bfe4daad71dfa30347b07f..f85f517c4f6444c540c577b866682ddb44e70010 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadGeometry.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadGeometry.h @@ -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 { diff --git a/Framework/DataHandling/src/LoadInstrument.cpp b/Framework/DataHandling/src/LoadInstrument.cpp index 60dd2bf54bce1d872b9c58dabc815f7a11a57131..7e498333efe2bd7f3f98f87ec77c9070b7bca45c 100644 --- a/Framework/DataHandling/src/LoadInstrument.cpp +++ b/Framework/DataHandling/src/LoadInstrument.cpp @@ -28,7 +28,6 @@ #include <Poco/File.h> #include <Poco/Path.h> #include <fstream> -#include <iostream> #include <sstream> namespace Mantid { diff --git a/Framework/DataHandling/test/LoadInstrumentTest.h b/Framework/DataHandling/test/LoadInstrumentTest.h index fca50f95c642d8a08bac8bf798dbe90b7f66dd58..9f694d8e9a8a3453b73c99dc7328bbdcfa9b3150 100644 --- a/Framework/DataHandling/test/LoadInstrumentTest.h +++ b/Framework/DataHandling/test/LoadInstrumentTest.h @@ -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