17#include "MantidIndexing/IndexInfo.h"
21#include "MantidNexusGeometry/NexusGeometryParser.h"
27using namespace Kernel;
29using namespace Geometry;
30using namespace DataObjects;
31using namespace HistogramData;
40 const std::string &filePath = descriptor.
filename();
46 std::string::size_type stripPath = filePath.find_last_of(
"\\/");
47 if (stripPath == std::string::npos)
49 if (filePath.find(
"Definition", stripPath) != std::string::npos) {
65 "The filename (including its full or relative path) of an instrument "
66 "definition file. The file extension must either be .xml or .XML when "
67 "specifying an instrument definition file. Files can also be .hdf5 or "
68 ".nxs for usage with NeXus Geometry files. Note Filename or "
69 "InstrumentName must be specified but not both.");
71 "Name of instrument. Can be used instead of Filename to "
74 "The name of the workspace in which to store the imported instrument");
76 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
77 mustBePositive->setLower(0.0);
79 "This value affects the colour of the detectors in the instrument\n"
80 "display window (default 1)");
82 "This value affects the colour of the monitors in the instrument\n"
83 "display window (default 2)");
86 "Set to True to create an EventWorkspace (with no events) "
87 "instead of a Workspace2D.");
109 instrument = ws->getInstrument();
112 const size_t number_spectra = instrument->getNumberDetectors();
115 if (number_spectra == 0) {
116 g_log.
error(
"Instrument has no detectors, unable to create workspace for it");
120 Indexing::IndexInfo indexInfo(number_spectra);
121 bool MakeEventWorkspace =
getProperty(
"MakeEventWorkspace");
123 if (MakeEventWorkspace) {
125 create<EventWorkspace>(instrument, indexInfo, BinEdges{0.0, std::numeric_limits<double>::min()}));
127 const double detector_value =
getProperty(
"DetectorValue");
128 const double monitor_value =
getProperty(
"MonitorValue");
129 auto ws2D = create<Workspace2D>(
130 instrument, indexInfo,
131 Histogram(BinEdges{0.0, 1.0}, Counts(1, detector_value), CountStandardDeviations(1, detector_value)));
133 Counts v_monitor_y(1, monitor_value);
134 CountStandardDeviations v_monitor_e(1, monitor_value);
136 const auto &spectrumInfo = ws2D->spectrumInfo();
137 const auto size =
static_cast<int64_t
>(spectrumInfo.size());
138#pragma omp parallel for
139 for (int64_t i = 0; i < size; i++) {
140 if (spectrumInfo.isMonitor(i)) {
141 ws2D->setCounts(i, v_monitor_y);
142 ws2D->setCountStandardDeviations(i, v_monitor_e);
151 const std::string &instrumentname) {
153 loadInst->setPropertyValue(
"Filename", filename);
154 loadInst->setPropertyValue(
"InstrumentName", instrumentname);
155 loadInst->setProperty(
"RewriteSpectraMap",
OptionalBool(
true));
#define DECLARE_FILELOADER_ALGORITHM(classname)
DECLARE_FILELOADER_ALGORITHM should be used in place of the standard DECLARE_ALGORITHM macro when wri...
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.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
@ OptionalLoad
to specify a file to read but the file doesn't have to exist
Helper class for reporting progress from algorithms.
A property class for workspaces.
void init() override
Overwrites Algorithm method.
int confidence(Kernel::FileDescriptor &descriptor) const override
Returns a confidence value that this algorithm can load a file.
API::MatrixWorkspace_sptr runLoadInstrument(const std::string &filename, const std::string &instrumentname)
Run the Child Algorithm LoadInstrument (or LoadInstrumentFromRaw)
void exec() override
Overwrites Algorithm method.
Exception for errors associated with the instrument definition.
Defines a wrapper around an open file.
const std::string & filename() const
Access the filename.
static bool isAscii(const std::string &filename, const size_t nbytes=256)
Returns true if the file is considered ascii.
const std::string & extension() const
Access the file extension.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void error(const std::string &msg)
Logs at error level.
OptionalBool : Tri-state bool.
void reportIncrement(int inc, const std::string &msg="")
Sends the progress notification and increment the loop counter by more than one.
The concrete, templated class for properties.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
const std::vector< std::string > validExtensions()
List allowed file extensions for geometry.
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
@ Output
An output workspace.