-
Notifications
You must be signed in to change notification settings - Fork 122
/
LoadNexusProcessed.h
244 lines (199 loc) · 10.1 KB
/
LoadNexusProcessed.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#ifndef MANTID_DATAHANDLING_LOADNEXUSPROCESSED_H_
#define MANTID_DATAHANDLING_LOADNEXUSPROCESSED_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/IFileLoader.h"
#include "MantidAPI/ITableWorkspace_fwd.h"
#include "MantidAPI/MatrixWorkspace_fwd.h"
#include "MantidKernel/cow_ptr.h"
#include "MantidHistogramData/BinEdges.h"
#include "MantidNexus/NexusClasses.h"
#include <map>
namespace NeXus {
class File;
}
namespace Mantid {
namespace DataHandling {
/**
Loads a workspace from a NeXus Processed entry in a NeXus file.
LoadNexusProcessed is an algorithm and as such inherits
from the Algorithm class, via DataHandlingCommand, and overrides
the init() & exec() methods.
Required Properties:
<UL>
<LI> Filename - The name of the input NeXus file (must exist) </LI>
<LI> InputWorkspace - The name of the workspace to put the data </LI>
</UL>
Copyright © 2007-8 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport LoadNexusProcessed
: public API::IFileLoader<Kernel::NexusDescriptor> {
public:
/// Default constructor
LoadNexusProcessed();
/// Destructor
~LoadNexusProcessed() override;
/// Algorithm's name for identification overriding a virtual method
const std::string name() const override { return "LoadNexusProcessed"; }
/// Summary of algorithms purpose
const std::string summary() const override {
return "The LoadNexusProcessed algorithm will read the given Nexus "
"Processed data file containing a Mantid Workspace. The data is "
"placed in the named workspace. LoadNexusProcessed may be invoked "
"by LoadNexus if it is given a Nexus file of this type.";
}
/// Algorithm's version for identification overriding a virtual method
int version() const override { return 1; };
/// Algorithm's category for identification overriding a virtual method
const std::string category() const override { return "DataHandling\\Nexus"; }
/// Returns a confidence value that this algorithm can load a file
int confidence(Kernel::NexusDescriptor &descriptor) const override;
private:
/// Validates the input Min < Max and Max < Maximum_Int
std::map<std::string, std::string> validateInputs() override;
/// Overwrites Algorithm method.
void init() override;
/// Overwrites Algorithm method
void exec() override;
/// Create the workspace name if it's part of a group workspace
std::string buildWorkspaceName(const std::string &name,
const std::string &baseName, size_t wsIndex);
/// Add an index to the name if it already exists in the workspace
void correctForWorkspaceNameClash(std::string &wsName);
/// Extract the workspace name
std::vector<std::string> extractWorkspaceNames(Mantid::NeXus::NXRoot &root,
size_t nWorkspaceEntries);
/// Load the workspace name attribute if it exists
std::string loadWorkspaceName(Mantid::NeXus::NXRoot &root,
const std::string &entry_name);
/// Load a single entry
API::Workspace_sptr loadEntry(Mantid::NeXus::NXRoot &root,
const std::string &entry_name,
const double &progressStart,
const double &progressRange);
API::Workspace_sptr loadTableEntry(Mantid::NeXus::NXEntry &entry);
/// Load a numeric column to the TableWorkspace.
template <typename ColumnType, typename NexusType>
void loadNumericColumn(const Mantid::NeXus::NXData &tableData,
const std::string &dataSetName,
const API::ITableWorkspace_sptr &tableWs,
const std::string &columnType);
/// Loads a vector column to the TableWorkspace.
template <typename Type>
void loadVectorColumn(const Mantid::NeXus::NXData &tableData,
const std::string &dataSetName,
const API::ITableWorkspace_sptr &tableWs,
const std::string &columnType);
/// Loads a V3D column to the TableWorkspace.
void loadV3DColumn(Mantid::NeXus::NXDouble &data,
const API::ITableWorkspace_sptr &tableWs);
API::Workspace_sptr loadPeaksEntry(Mantid::NeXus::NXEntry &entry);
API::MatrixWorkspace_sptr loadEventEntry(Mantid::NeXus::NXData &wksp_cls,
Mantid::NeXus::NXDouble &xbins,
const double &progressStart,
const double &progressRange);
API::MatrixWorkspace_sptr
loadNonEventEntry(Mantid::NeXus::NXData &wksp_cls,
Mantid::NeXus::NXDouble &xbins, const double &progressStart,
const double &progressRange,
const Mantid::NeXus::NXEntry &mtd_entry, const int xlength,
std::string &workspaceType);
/// Read the data from the sample group
void readSampleGroup(Mantid::NeXus::NXEntry &mtd_entry,
API::MatrixWorkspace_sptr local_workspace);
/// Add a property to the sample object
bool addSampleProperty(Mantid::NeXus::NXMainClass &sample_entry,
const std::string &entryName,
API::Sample &sampleDetails);
/// Read the spectra
void readInstrumentGroup(Mantid::NeXus::NXEntry &mtd_entry,
API::MatrixWorkspace_sptr local_workspace);
/// Splits a string of exactly three words into the separate words
void getWordsInString(const std::string &words3, std::string &w1,
std::string &w2, std::string &w3);
/// Splits a string of exactly four words into the separate words
void getWordsInString(const std::string &words4, std::string &w1,
std::string &w2, std::string &w3, std::string &w4);
/// Read the bin masking information
void readBinMasking(Mantid::NeXus::NXData &wksp_cls,
API::MatrixWorkspace_sptr local_workspace);
/// Load a block of data into the workspace where it is assumed that the x
/// bins have already been cached
void loadBlock(Mantid::NeXus::NXDataSetTyped<double> &data,
Mantid::NeXus::NXDataSetTyped<double> &errors,
Mantid::NeXus::NXDataSetTyped<double> &farea, bool hasFArea,
Mantid::NeXus::NXDouble &xErrors, bool hasXErrors,
int blocksize, int nchannels, int &hist,
API::MatrixWorkspace_sptr local_workspace);
/// Load a block of data into the workspace where it is assumed that the x
/// bins have already been cached
void loadBlock(Mantid::NeXus::NXDataSetTyped<double> &data,
Mantid::NeXus::NXDataSetTyped<double> &errors,
Mantid::NeXus::NXDataSetTyped<double> &farea, bool hasFArea,
Mantid::NeXus::NXDouble &xErrors, bool hasXErrors,
int blocksize, int nchannels, int &hist, int &wsIndex,
API::MatrixWorkspace_sptr local_workspace);
/// Load a block of data into the workspace
void loadBlock(Mantid::NeXus::NXDataSetTyped<double> &data,
Mantid::NeXus::NXDataSetTyped<double> &errors,
Mantid::NeXus::NXDataSetTyped<double> &farea, bool hasFArea,
Mantid::NeXus::NXDouble &xErrors, bool hasXErrors,
Mantid::NeXus::NXDouble &xbins, int blocksize, int nchannels,
int &hist, int &wsIndex,
API::MatrixWorkspace_sptr local_workspace);
/// Load the data from a non-spectra axis (Numeric/Text) into the workspace
void loadNonSpectraAxis(API::MatrixWorkspace_sptr local_workspace,
Mantid::NeXus::NXData &data);
/// Validates the optional 'spectra to read' properties, if they have been set
void checkOptionalProperties(const std::size_t numberofspectra);
/// calculates the workspace size
std::size_t calculateWorkspaceSize(const std::size_t numberofspectra,
bool gen_filtered_list = false);
/// Accellerated multiperiod loading
Mantid::API::Workspace_sptr doAccelleratedMultiPeriodLoading(
Mantid::NeXus::NXRoot &root, const std::string &entryName,
Mantid::API::MatrixWorkspace_sptr &tempMatrixWorkspace,
const size_t nWorkspaceEntries, const size_t p);
/// Does the current workspace have uniform binning
bool m_shared_bins;
/// The cached x binning if we have bins
HistogramData::BinEdges m_xbins;
/// Numeric values for the second axis, if applicable
MantidVec m_axis1vals;
/// Flag set if list of spectra to save is specifed
bool m_list;
/// Flag set if interval of spectra to write is set
bool m_interval;
/// The value of the spectrum_min property
int m_spec_min;
/// The value of the spectrum_max property
int m_spec_max;
/// The value of the spectrum_list property
std::vector<int> m_spec_list;
/// list of spectra filtered by min/max/list, currently
/// used only when loading data into event_workspace
std::vector<int> m_filtered_spec_idxs;
// C++ interface to the NXS file
::NeXus::File *m_cppFile;
};
/// to sort the algorithmhistory vector
bool UDlesserExecCount(Mantid::NeXus::NXClassInfo elem1,
Mantid::NeXus::NXClassInfo elem2);
} // namespace DataHandling
} // namespace Mantid
#endif /*MANTID_DATAHANDLING_LOADNEXUSPROCESSED_H_*/