-
Notifications
You must be signed in to change notification settings - Fork 122
/
LoadISISNexus2.h
162 lines (138 loc) · 6.58 KB
/
LoadISISNexus2.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
#ifndef MANTID_DATAHANDLING_LoadISISNexus22_H_
#define MANTID_DATAHANDLING_LoadISISNexus22_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/Algorithm.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidNexus/NexusClasses.h"
#include "MantidAPI/IDataFileChecker.h"
#include <climits>
//----------------------------------------------------------------------
// Forward declaration
//----------------------------------------------------------------------
namespace Mantid
{
namespace DataHandling
{
/**
Loads a file in a NeXus format and stores it in a 2D workspace. LoadISISNexus2 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 and path to the input NeXus file </LI>
<LI> OutputWorkspace - The name of the workspace in which to store the imported data
(a multiperiod file will store higher periods in workspaces called OutputWorkspace_PeriodNo)</LI>
</UL>
Optional Properties: (note that these options are not available if reading a multiperiod file)
<UL>
<LI> SpectrumMin - The starting spectrum number</LI>
<LI> SpectrumMax - The final spectrum number (inclusive)</LI>
<LI> SpectrumList - An ArrayProperty of spectra to load</LI>
</UL>
@author Roman Tolchenov, Tessella plc
Copyright © 2007-9 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
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://svn.mantidproject.org/mantid/trunk/Code/Mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport LoadISISNexus2 : public API::IDataFileChecker
{
public:
/// Default constructor
LoadISISNexus2();
/// Destructor
virtual ~LoadISISNexus2() {}
/// Algorithm's name for identification overriding a virtual method
virtual const std::string name() const { return "LoadISISNexus"; }
/// Algorithm's version for identification overriding a virtual method
virtual int version() const { return 2; }
/// Algorithm's category for identification overriding a virtual method
virtual const std::string category() const { return "DataHandling\\Nexus"; }
/// do a quick check that this file can be loaded
virtual bool quickFileCheck(const std::string& filePath,size_t nread,const file_header& header);
/// check the structure of the file and return a value between 0 and 100 of how much this file can be loaded
virtual int fileCheck(const std::string& filePath);
private:
/// Overwrites Algorithm method.
void init();
/// Overwrites Algorithm method
void exec();
// Validate the optional input properties
void checkOptionalProperties();
/// Run LoadInstrument as a subalgorithm
void runLoadInstrument(DataObjects::Workspace2D_sptr);
/// Load in details about the run
void loadRunDetails(DataObjects::Workspace2D_sptr local_workspace, Mantid::NeXus::NXEntry & entry);
/// Parse an ISO formatted date-time string into separate date and time strings
void parseISODateTime(const std::string & datetime_iso, std::string & date, std::string & time) const;
/// Load in details about the sample
void loadSampleData(DataObjects::Workspace2D_sptr, Mantid::NeXus::NXEntry & entry);
/// Load log data from the nexus file
void loadLogs(DataObjects::Workspace2D_sptr);
// Load a given period into the workspace
void loadPeriodData(int64_t period, Mantid::NeXus::NXEntry & entry, DataObjects::Workspace2D_sptr local_workspace);
// Load a data block
void loadBlock(Mantid::NeXus::NXDataSetTyped<int> & data, int64_t blocksize, int64_t period, int64_t start,
int64_t &hist, int64_t& spec_num, DataObjects::Workspace2D_sptr localWorkspace);
// Load period logs
void loadPeriodLogs(int64_t period, DataObjects::Workspace2D_sptr local_workspace);
/// The name and path of the input file
std::string m_filename;
/// The instrument name from Nexus
std::string m_instrument_name;
/// The sample name read from Nexus
std::string m_samplename;
/// The number of spectra
std::size_t m_numberOfSpectra;
/// The number of spectra in the raw file
std::size_t m_numberOfSpectraInFile;
/// The number of periods
std::size_t m_numberOfPeriods;
/// The number of periods in the raw file
std::size_t m_numberOfPeriodsInFile;
/// The nuber of time chanels per spectrum
std::size_t m_numberOfChannels;
/// The nuber of time chanels per spectrum in the raw file
std::size_t m_numberOfChannelsInFile;
/// Is there a detector block
bool m_have_detector;
/// The value of the SpectrumMin property
int64_t m_spec_min;
/// The value of the SpectrumMax property
int64_t m_spec_max;
/// The value of the spectrum_list property
std::vector<int64_t> m_spec_list;
/// The number of the input entry
int64_t m_entrynumber;
/// Have the spectrum_min/max properties been set?
bool m_range_supplied;
/// Time channels
boost::shared_ptr<MantidVec> m_tof_data;
/// Proton charge
double m_proton_charge;
/// Spectra numbers
boost::shared_array<int> m_spec;
/// Pointer to one-past-the-end of spectrum number array (m_spec)
const int * m_spec_end;
/// Monitors
std::map<int64_t,std::string> m_monitors;
///Progress reporting object
boost::shared_ptr<API::Progress> m_progress;
/// Personal wrapper for sqrt to allow msvs to compile
static double dblSqrt(double in);
};
} // namespace DataHandling
} // namespace Mantid
#endif /*MANTID_DATAHANDLING_LoadISISNexus2_H_*/