Mantid
Loading...
Searching...
No Matches
LoadNexusProcessed.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
16#include "MantidAPI/Sample.h"
17#include "MantidDataHandling/DllConfig.h"
18#include "MantidHistogramData/BinEdges.h"
21#include <map>
22#include <vector>
23
24namespace Mantid {
25
26namespace DataHandling {
40class MANTID_DATAHANDLING_DLL LoadNexusProcessed : public API::NexusFileLoader {
41
42public:
48 const std::string name() const override { return "LoadNexusProcessed"; }
50 const std::string summary() const override {
51 return "The LoadNexusProcessed algorithm will read the given Nexus "
52 "Processed data file containing a Mantid Workspace. The data is "
53 "placed in the named workspace. LoadNexusProcessed may be invoked "
54 "by LoadNexus if it is given a Nexus file of this type.";
55 }
56
58 int version() const override { return 1; };
59 const std::vector<std::string> seeAlso() const override { return {"LoadNexus"}; }
61 const std::string category() const override { return "DataHandling\\Nexus"; }
62
64 int confidence(Nexus::NexusDescriptor &descriptor) const override;
65
66protected:
68 void readInstrumentGroup(Mantid::Nexus::NXEntry &mtd_entry, API::MatrixWorkspace &local_workspace);
69
70private:
71 virtual void readSpectraToDetectorMapping(Mantid::Nexus::NXEntry &mtd_entry, Mantid::API::MatrixWorkspace &ws);
72
74 std::map<std::string, std::string> validateInputs() override;
76 void init() override;
78 void execLoader() override;
79
81 std::string buildWorkspaceName(const std::string &name, const std::string &baseName, size_t wsIndex);
82
84 void correctForWorkspaceNameClash(std::string &wsName);
85
87 std::vector<std::string> extractWorkspaceNames(Mantid::Nexus::NXRoot &root, size_t nWorkspaceEntries);
88
90 std::string loadWorkspaceName(Mantid::Nexus::NXRoot &root, const std::string &entry_name);
91
93 virtual bool loadNexusGeometry(Mantid::API::Workspace & /* ws */, size_t /* entryNumber */,
94 Kernel::Logger & /* logger */,
95 const std::string & /* filePath */) { /* args not used */
96 return false; /*do nothing*/
97 }
98
100 API::Workspace_sptr loadEntry(Mantid::Nexus::NXRoot &root, const std::string &entry_name, const double &progressStart,
101 const double &progressRange);
102
103 API::Workspace_sptr loadTableEntry(const Mantid::Nexus::NXEntry &entry);
104
106 template <typename ColumnType, typename NexusType>
107 void loadNumericColumn(const Mantid::Nexus::NXData &tableData, const std::string &dataSetName,
108 const API::ITableWorkspace_sptr &tableWs, const std::string &columnType);
109
111 template <typename Type>
112 void loadVectorColumn(const Mantid::Nexus::NXData &tableData, const std::string &dataSetName,
113 const API::ITableWorkspace_sptr &tableWs, const std::string &columnType);
114
116 void loadV3DColumn(Mantid::Nexus::NXDouble &data, const API::ITableWorkspace_sptr &tableWs);
117
118 API::Workspace_sptr loadPeaksEntry(const Mantid::Nexus::NXEntry &entry);
119
120 API::Workspace_sptr loadLeanElasticPeaksEntry(const Mantid::Nexus::NXEntry &entry);
121
123 const double &progressStart, const double &progressRange);
125 const double &progressStart, const double &progressRange,
126 const Mantid::Nexus::NXEntry &mtd_entry, const int64_t xlength,
127 std::string &workspaceType);
128
132 bool addSampleProperty(Mantid::Nexus::NXClass &sample_entry, const std::string &entryName,
133 API::Sample &sampleDetails);
135 void getWordsInString(const std::string &words3, std::string &w1, std::string &w2, std::string &w3);
137 void getWordsInString(const std::string &words4, std::string &w1, std::string &w2, std::string &w3, std::string &w4);
138
140 void readBinMasking(const Mantid::Nexus::NXData &wksp_cls, const API::MatrixWorkspace_sptr &local_workspace);
141
144 void loadBlock(Mantid::Nexus::NXDouble &data, Mantid::Nexus::NXDouble &errors, Mantid::Nexus::NXDouble &farea,
145 bool hasFArea, Mantid::Nexus::NXDouble &xErrors, bool hasXErrors, int64_t blocksize, int64_t nchannels,
146 int64_t &hist, const API::MatrixWorkspace_sptr &local_workspace);
147
150 void loadBlock(Mantid::Nexus::NXDouble &data, Mantid::Nexus::NXDouble &errors, Mantid::Nexus::NXDouble &farea,
151 bool hasFArea, Mantid::Nexus::NXDouble &xErrors, bool hasXErrors, int64_t blocksize, int64_t nchannels,
152 int64_t &hist, int64_t &wsIndex, const API::MatrixWorkspace_sptr &local_workspace);
154 void loadBlock(Mantid::Nexus::NXDouble &data, Mantid::Nexus::NXDouble &errors, Mantid::Nexus::NXDouble &farea,
155 bool hasFArea, Mantid::Nexus::NXDouble &xErrors, bool hasXErrors, Mantid::Nexus::NXDouble &xbins,
156 int64_t blocksize, int64_t nchannels, int64_t &hist, int64_t &wsIndex,
157 const API::MatrixWorkspace_sptr &local_workspace);
158
160 void loadNonSpectraAxis(const API::MatrixWorkspace_sptr &local_workspace, const Mantid::Nexus::NXData &data);
161
163 void checkOptionalProperties(const std::size_t numberofspectra);
164
166 std::size_t calculateWorkspaceSize(const std::size_t numberofspectra, bool gen_filtered_list = false);
167
169 Mantid::API::Workspace_sptr doAccelleratedMultiPeriodLoading(Mantid::Nexus::NXRoot &root,
170 const std::string &entryName,
171 Mantid::API::MatrixWorkspace_sptr &tempMatrixWorkspace,
172 const size_t nWorkspaceEntries, const size_t p);
173
175 void applyLogFiltering(const Mantid::API::Workspace_sptr &local_workspace);
176
180 HistogramData::BinEdges m_xbins;
183
185 bool m_list;
188
193
195 std::vector<int> m_spec_list;
198 std::vector<int> m_filtered_spec_idxs;
199
200 // Handle to the NeXus file
201 std::unique_ptr<Nexus::File> m_nexusFile;
202};
205
206} // namespace DataHandling
207} // namespace Mantid
std::string name
Definition Run.cpp:60
Base MatrixWorkspace Abstract Class.
This class stores information about the sample used in particular run.
Definition Sample.h:33
Base Workspace Abstract Class.
Definition Workspace.h:29
Loads a workspace from a NeXus Processed entry in a NeXus file.
int m_spec_min
The value of the spectrum_min property.
bool m_interval
Flag set if interval of spectra to write is set.
const std::string summary() const override
Summary of algorithms purpose.
~LoadNexusProcessed() override
Destructor.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
HistogramData::BinEdges m_xbins
The cached x binning if we have bins.
virtual bool loadNexusGeometry(Mantid::API::Workspace &, size_t, Kernel::Logger &, const std::string &)
Load nexus geometry and apply to workspace.
int m_spec_max
The value of the spectrum_max property.
bool addSampleProperty(Mantid::Nexus::NXClass &sample_entry, const std::string &entryName, API::Sample &sampleDetails)
Add a property to the sample object.
bool m_list
Flag set if list of spectra to save is specifed.
void readSampleGroup(Mantid::Nexus::NXEntry &mtd_entry, API::MatrixWorkspace_sptr local_workspace)
Read the data from the sample group.
std::vector< int > m_filtered_spec_idxs
list of spectra filtered by min/max/list, currently used only when loading data into event_workspace
bool m_shared_bins
Does the current workspace have uniform binning.
std::vector< int > m_spec_list
The value of the spectrum_list property.
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
MantidVec m_axis1vals
Numeric values for the second axis, if applicable.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
int version() const override
Algorithm's version for identification overriding a virtual method.
std::unique_ptr< Nexus::File > m_nexusFile
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition Logger.h:51
The base class for a Nexus class (group).
Templated class implementation of NXDataSet.
Implements NXdata Nexus class.
Implements NXentry Nexus class.
Implements NXroot Nexus class.
void getWordsInString(const std::string &words3, std::string &w1, std::string &w2, std::string &w3)
If the first string contains exactly three words separated by spaces these words will be copied into ...
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
bool UDlesserExecCount(const Mantid::Nexus::NXClassInfo &elem1, const Mantid::Nexus::NXClassInfo &elem2)
to sort the algorithmhistory vector
Helper class which provides the Collimation Length for SANS instruments.
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
Definition cow_ptr.h:172
Information about a Nexus class.