21#include "MantidNexus/NexusFile.h"
26using namespace Geometry;
27using namespace Kernel;
29using Types::Core::DateAndTime;
38 if (descriptor.isEntry(
"/entry0/IN1")) {
67 "File path of the data file to load");
69 "The output workspace.");
70 declareProperty(
"InitialEnergyOffset", 0.0,
"Offset for the initial energy (meV)");
80 progress.report(
"Loading the detector data");
83 progress.report(
"Loading the metadata");
98 H5::DataSet dataset = h5file.openDataSet(
"entry0/data_scan/detector_data/data");
108 dataset.read(dataInt.data(), dataset.getDataType());
112 H5::DataSet scanVarNames = h5file.openDataSet(
"entry0/data_scan/scanned_variables/variables_names/name");
113 H5::DataSpace scanVarNamesSpace = scanVarNames.getSpace();
115 int nDims = scanVarNamesSpace.getSimpleExtentNdims();
116 auto dimsSize = std::vector<hsize_t>(nDims);
117 scanVarNamesSpace.getSimpleExtentDims(dimsSize.data(),
nullptr);
119 std::vector<char *> rdata(dimsSize[0]);
120 scanVarNames.read(rdata.data(), scanVarNames.getDataType());
121 size_t monitorIndex = 0;
122 while (monitorIndex < rdata.size()) {
123 if (std::string(rdata[monitorIndex]) ==
"Monitor1")
127 if (monitorIndex == rdata.size())
128 throw std::runtime_error(
"Monitor count not found. Please check your nexus file.");
129 scanVarNames.vlenReclaim(rdata.data(), scanVarNames.getDataType(), scanVarNamesSpace);
130 scanVarNames.close();
133 H5::DataSet scanVar = h5file.openDataSet(
"entry0/data_scan/scanned_variables/data");
134 H5::DataSpace scanVarSpace = scanVar.getSpace();
136 nDims = scanVarSpace.getSimpleExtentNdims();
137 std::vector<double> monitorData;
138 std::vector<double> scanVariableData;
139 dimsSize.resize(nDims);
140 if (dimsSize.size() != 2) {
141 throw std::runtime_error(
"Scanned variables are not formatted properly. Check you nexus file.");
143 scanVarSpace.getSimpleExtentDims(dimsSize.data(),
nullptr);
146 throw std::runtime_error(
"Scanned variables are not formatted properly. Check you nexus file.");
148 std::vector<double> scanVarData(dimsSize[0] * dimsSize[1]);
149 scanVar.read(scanVarData.data(), scanVar.getDataType());
150 monitorData.resize(dimsSize[1]);
151 scanVariableData.resize(dimsSize[1]);
152 for (
size_t i = 0; i < monitorData.size(); i++) {
153 monitorData[i] = scanVarData[monitorIndex * dimsSize[1] + i];
154 scanVariableData[i] = scanVarData[i];
159 double energyAxisOffset =
getProperty(
"InitialEnergyOffset");
161 for (
size_t j = 0; j <
m_nScans; j++) {
162 double count = dataInt[j];
206 H5::DataSpace detectorDataspace = dataset.getSpace();
207 int nDims = detectorDataspace.getSimpleExtentNdims();
208 std::vector<hsize_t> dimsSize(nDims);
209 detectorDataspace.getSimpleExtentDims(dimsSize.data(), NULL);
215 m_outputWorkspace->getAxis(0)->unit() = UnitFactory::Instance().create(
"Energy");
std::map< DeltaEMode::Type, std::string > index
#define DECLARE_NEXUS_FILELOADER_ALGORITHM(classname)
DECLARE_NEXUS_FILELOADER_ALGORITHM should be used in place of the standard DECLARE_ALGORITHM macro wh...
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
@ Load
allowed here which will be passed to the algorithm
Defines an interface to an algorithm that loads a file so that it can take part in the automatic sele...
Helper class for reporting progress from algorithms.
A property class for workspaces.
LoadILLLagrange : Loads nexus files from ILL instrument LAGRANGE.
int version() const override
Algorithm's version for identification.
void exec() override
Executes the algorithm.
void loadMetaData()
Dumps the metadata from the file for each entry separately.
size_t m_nScans
number of scans in the file
void initWorkspace(const H5::DataSet &)
Initializes the output workspace for LAGRANGE.
API::MatrixWorkspace_sptr m_outputWorkspace
output workspace
LoadILLLagrange()
Constructor.
void loadData()
Sets up the workspace, loads the mockup instrument, the data and scanned variables for proper data la...
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
void init() override
Initialize the algorithm's properties.
const std::string name() const override
Algorithms name for identification.
const std::string category() const override
Algorithm's category for identification.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void debug(const std::string &msg)
Logs at debug level.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
A specialised Property class for holding a series of time-value pairs.
void addValue(const Types::Core::DateAndTime &time, const TYPE &value)
Add a value to the map using a DateAndTime object.
Class that provides for a standard Nexus exception.
void addNexusFieldsToWsRun(Nexus::File &filehandle, API::Run &runDetails, const std::string &entryName="", bool useFullAddress=false)
Add properties from a nexus file to the workspace run.
void loadEmptyInstrument(const API::MatrixWorkspace_sptr &ws, const std::string &instrumentName, const std::string &instrumentAddress="")
Loads empty instrument of chosen name into a provided workspace.
MANTID_NEXUS_DLL H5::FileAccPropList defaultFileAcc()
Default file access is H5F_CLOSE_STRONG.
@ Output
An output workspace.