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//----------------------------------------------------------------------
15#include "MantidAPI/Sample.h"
16#include "MantidDataHandling/DllConfig.h"
17#include "MantidHistogramData/BinEdges.h"
21#include <map>
22#include <memory>
23#include <vector>
24
25namespace Mantid {
26
27namespace DataObjects {
28class SpecialWorkspace2D;
29}
30
31namespace DataHandling {
45class MANTID_DATAHANDLING_DLL LoadNexusProcessed : public API::IFileLoader<Mantid::Nexus::NexusDescriptorLazy> {
46
47public:
53 const std::string name() const override { return "LoadNexusProcessed"; }
55 const std::string summary() const override {
56 return "The LoadNexusProcessed algorithm will read the given Nexus "
57 "Processed data file containing a Mantid Workspace. The data is "
58 "placed in the named workspace. LoadNexusProcessed may be invoked "
59 "by LoadNexus if it is given a Nexus file of this type.";
60 }
61
63 int version() const override { return 1; };
64 const std::vector<std::string> seeAlso() const override { return {"LoadNexus"}; }
66 const std::string category() const override { return "DataHandling\\Nexus"; }
67
69 int confidence(Nexus::NexusDescriptorLazy &descriptor) const override;
70
71protected:
73 void readInstrumentGroup(Mantid::Nexus::NXEntry &mtd_entry, API::MatrixWorkspace &local_workspace);
74
75private:
76 virtual void readSpectraToDetectorMapping(Mantid::Nexus::NXEntry &mtd_entry, Mantid::API::MatrixWorkspace &ws);
77
79 std::map<std::string, std::string> validateInputs() override;
81 void init() override;
83 void exec() override;
84
85 void reinitSpecialWorkspace2D(std::shared_ptr<Mantid::DataObjects::SpecialWorkspace2D> specialLocalWorkspace);
86
88 std::string buildWorkspaceName(const std::string &name, const std::string &baseName, size_t wsIndex);
89
91 void correctForWorkspaceNameClash(std::string &wsName);
92
94 std::vector<std::string> extractWorkspaceNames(Mantid::Nexus::NXRoot &root, size_t nWorkspaceEntries);
95
97 std::string loadWorkspaceName(Mantid::Nexus::NXRoot &root, const std::string &entry_name);
98
100 virtual bool loadNexusGeometry(Mantid::API::Workspace & /* ws */, size_t /* entryNumber */,
101 Kernel::Logger & /* logger */,
102 const std::string & /* filePath */) { /* args not used */
103 return false; /*do nothing*/
104 }
105
107 API::Workspace_sptr loadEntry(Mantid::Nexus::NXRoot &root, const std::string &entry_name, const double &progressStart,
108 const double &progressRange);
109
110 API::Workspace_sptr loadTableEntry(const Mantid::Nexus::NXEntry &entry);
111
113 template <typename ColumnType, typename NexusType>
114 void loadNumericColumn(const Mantid::Nexus::NXData &tableData, const std::string &dataSetName,
115 const API::ITableWorkspace_sptr &tableWs, const std::string &columnType);
116
118 template <typename Type>
119 void loadVectorColumn(const Mantid::Nexus::NXData &tableData, const std::string &dataSetName,
120 const API::ITableWorkspace_sptr &tableWs, const std::string &columnType);
121
123 void loadV3DColumn(Mantid::Nexus::NXDouble &data, const API::ITableWorkspace_sptr &tableWs);
124
125 API::Workspace_sptr loadPeaksEntry(const Mantid::Nexus::NXEntry &entry);
126
127 API::Workspace_sptr loadLeanElasticPeaksEntry(const Mantid::Nexus::NXEntry &entry);
128
130 const double &progressStart, const double &progressRange);
132 const double &progressStart, const double &progressRange,
133 const Mantid::Nexus::NXEntry &mtd_entry, const int64_t xlength,
134 std::string &workspaceType);
135
139 bool addSampleProperty(Mantid::Nexus::NXClass &sample_entry, const std::string &entryName,
140 API::Sample &sampleDetails);
142 void getWordsInString(const std::string &words3, std::string &w1, std::string &w2, std::string &w3);
144 void getWordsInString(const std::string &words4, std::string &w1, std::string &w2, std::string &w3, std::string &w4);
145
147 void readBinMasking(const Mantid::Nexus::NXData &wksp_cls, const API::MatrixWorkspace_sptr &local_workspace);
148
151 void loadBlock(Mantid::Nexus::NXDouble &data, Mantid::Nexus::NXDouble &errors, Mantid::Nexus::NXDouble &farea,
152 bool hasFArea, Mantid::Nexus::NXDouble &xErrors, bool hasXErrors, int64_t blocksize, int64_t nchannels,
153 int64_t &hist, const API::MatrixWorkspace_sptr &local_workspace);
154
157 void loadBlock(Mantid::Nexus::NXDouble &data, Mantid::Nexus::NXDouble &errors, Mantid::Nexus::NXDouble &farea,
158 bool hasFArea, Mantid::Nexus::NXDouble &xErrors, bool hasXErrors, int64_t blocksize, int64_t nchannels,
159 int64_t &hist, int64_t &wsIndex, const API::MatrixWorkspace_sptr &local_workspace);
161 void loadBlock(Mantid::Nexus::NXDouble &data, Mantid::Nexus::NXDouble &errors, Mantid::Nexus::NXDouble &farea,
162 bool hasFArea, Mantid::Nexus::NXDouble &xErrors, bool hasXErrors, Mantid::Nexus::NXDouble &xbins,
163 int64_t blocksize, int64_t nchannels, int64_t &hist, int64_t &wsIndex,
164 const API::MatrixWorkspace_sptr &local_workspace);
165
167 void loadNonSpectraAxis(const API::MatrixWorkspace_sptr &local_workspace, const Mantid::Nexus::NXData &data);
168
170 void checkOptionalProperties(const std::size_t numberofspectra);
171
173 std::size_t calculateWorkspaceSize(const std::size_t numberofspectra, bool gen_filtered_list = false);
174
176 Mantid::API::Workspace_sptr doAccelleratedMultiPeriodLoading(Mantid::Nexus::NXRoot &root,
177 const std::string &entryName,
178 Mantid::API::MatrixWorkspace_sptr &tempMatrixWorkspace,
179 const size_t nWorkspaceEntries, const size_t p);
180
182 void applyLogFiltering(const Mantid::API::Workspace_sptr &local_workspace);
183
187 HistogramData::BinEdges m_xbins;
190
192 bool m_list;
195
200
202 std::vector<int> m_spec_list;
205 std::vector<int> m_filtered_spec_idxs;
206
207 // Handle to the NeXus file
208 std::unique_ptr<Nexus::File> m_nexusFile;
209};
212
213} // namespace DataHandling
214} // namespace Mantid
std::string name
Definition Run.cpp:60
Defines an interface to an algorithm that loads a file so that it can take part in the automatic sele...
Definition IFileLoader.h:19
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.