/
LoadDaveGrp.h
116 lines (101 loc) · 3.79 KB
/
LoadDaveGrp.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
#ifndef MANTID_DATAHANDLING_LOADDAVEGRP_H_
#define MANTID_DATAHANDLING_LOADDAVEGRP_H_
#include <fstream>
#include <string>
#include "MantidAPI/IFileLoader.h"
#include "MantidKernel/cow_ptr.h"
namespace Mantid {
namespace DataHandling {
/** @class Mantid::DataHandling::LoadDaveGrp
Reads the DAVE grouped ASCII format into a workspace.
Properties:
<UL>
<LI> OutputWorkspace - The workspace name to produce. </LI>
<LI> Filename - The filename for input </LI>
<LI> XAxisUnits - The units for the x-axis </LI>
<LI> YAxisUnits - The units for the y-axis </LI>
<LI> IsMicroEV - The original file is in micro-electron-volts </LI>
</UL>
@author Michael Reuter ISIS Rutherford Appleton Laboratory & NScD Oak Ridge
National Laboratory
@date 25/02/2011
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 LoadDaveGrp : public API::IFileLoader<Kernel::FileDescriptor> {
public:
/// Constructor
LoadDaveGrp();
/// Virtual destructor
~LoadDaveGrp() override {}
/// Algorithm's name
const std::string name() const override { return "LoadDaveGrp"; }
/// Summary of algorithms purpose
const std::string summary() const override {
return "Loads data from a DAVE grouped ASCII file and stores it in a 2D "
"workspace (Workspace2D class).";
}
/// Algorithm's version
int version() const override { return (1); }
/// Algorithm's category for identification
const std::string category() const override {
return "DataHandling\\Text;Inelastic\\DataHandling";
}
/// Returns a confidence value that this algorithm can load a file
int confidence(Kernel::FileDescriptor &descriptor) const override;
private:
/// Initialization code
void init() override;
/// Execution code
void exec() override;
/**
* Function to retrieve the lengths of the x and y axes. This function uses
* the same code for each call, but it is the order which determines the axis
* found.
*
* @param length the size of a given axis
*/
void getAxisLength(int &length);
/**
* Function to parse and store the actual axis values. Again, read order
* determines the axis.
*
* @param axis the array to store the axis values
* @param length the size of the axis
*/
void getAxisValues(MantidVec *axis, const std::size_t length);
/**
* Function to parse and store the signal and errors from the data file.
*
* @param data the array to store the signal values
* @param errs the array to store the error values
*/
void getData(std::vector<MantidVec *> &data, std::vector<MantidVec *> &errs);
/**
* Function to read a line from the data file. Makes handling comment lines
* easy.
*/
void readLine();
/// Handle for input data file
std::ifstream ifile;
/// Placeholder for file lines
std::string line;
/// The number of groups present in the data file
int nGroups;
/// The size of the x-axis in the data file
int xLength;
};
} // namespace DataHandling
} // namespace Mantid
#endif // MANTID_DATAHANDLING_LOADDAVEGRP_H_