24using namespace Kernel;
36 if (!descriptor.isAscii())
39 auto &file = descriptor.data();
44 std::getline(file, fileline);
45 std::istringstream is(fileline);
46 unsigned int dummy(0);
57 std::getline(file, fileline);
58 if (fileline.find(
"Phi Grid") != std::string::npos || fileline.find(
"Q Grid") != std::string::npos) {
73 "The name of the SPE file to load.");
75 "The name to use for the output workspace");
93 size_t nhist = 0, nbins = 0;
94 unsigned int nhistTemp = 0, nbinsTemp = 0;
95 int retval = fscanf(speFile,
"%8u%8u\n", &nhistTemp, &nbinsTemp);
99 nhist =
static_cast<size_t>(nhistTemp);
100 nbins =
static_cast<size_t>(nbinsTemp);
104 fgets(comment, 100, speFile);
105 if (comment[0] !=
'#')
109 auto phiAxis = std::make_unique<BinEdgeAxis>(nhist + 1);
112 if (comment[4] ==
'Q' || comment[4] ==
'q') {
115 phiAxis->unit() = std::make_shared<Units::Phi>();
119 for (
size_t i = 0; i <= nhist; ++i) {
121 retval = fscanf(speFile,
"%10le", &phi);
123 std::stringstream ss;
124 ss <<
"Reading phi value" << i;
127 phiAxis->setValue(i, phi);
130 fgets(comment, 100, speFile);
133 fgets(comment, 100, speFile);
134 if (comment[0] !=
'#')
138 std::vector<double>
X(nbins + 1);
139 for (
size_t i = 0; i <= nbins; ++i) {
140 retval = fscanf(speFile,
"%10le", &
X[i]);
142 std::stringstream ss;
143 ss <<
"Reading energy value" << i;
147 HistogramData::BinEdges XValues(std::move(
X));
150 fgets(comment, 100, speFile);
156 workspace->setYUnitLabel(
"S(Phi,Energy)");
158 workspace->replaceAxis(1, std::move(phiAxis));
162 for (
size_t j = 0; j < nhist; ++j) {
186 fgets(comment, 100, speFile);
187 if (comment[0] !=
'#')
192 const size_t nbins =
workspace->blocksize();
194 for (
size_t i = 0; i < nbins; ++i) {
195 retval = fscanf(speFile,
"%10le", &
Y[i]);
197 std::stringstream ss;
198 ss <<
"Reading data value" << i <<
" of histogram " <<
index;
204 Y[i] = std::numeric_limits<double>::quiet_NaN();
208 fgets(comment, 100, speFile);
211 fgets(comment, 100, speFile);
212 if (comment[0] !=
'#')
217 for (
size_t i = 0; i < nbins; ++i) {
218 retval = fscanf(speFile,
"%10le", &E[i]);
220 std::stringstream ss;
221 ss <<
"Reading error value" << i <<
" of histogram " <<
index;
226 fgets(comment, 100, speFile);
IPeaksWorkspace_sptr workspace
std::map< DeltaEMode::Type, std::string > index
#define DECLARE_FILELOADER_ALGORITHM(classname)
DECLARE_FILELOADER_ALGORITHM should be used in place of the standard DECLARE_ALGORITHM macro when wri...
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
@ Load
allowed here which will be passed to the algorithm
Helper class for reporting progress from algorithms.
A property class for workspaces.
Loads an SPE format file into a Mantid workspace.
void readHistogram(FILE *speFile, const API::MatrixWorkspace_sptr &workspace, size_t index)
Reads in the data corresponding to a single spectrum.
void init() override
Initialise the algorithm.
void reportFormatError(const std::string &what)
Called if the file is not formatted as expected.
std::string m_filename
The file to load.
void exec() override
Execute the algorithm.
static const double MASK_FLAG
the mask flag (=-1e30) from the SPE specification http://www.mantidproject.org/images/3/3d/Spe_file_f...
Records the filename and the description of failure.
Defines a wrapper around an open file.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void error(const std::string &msg)
Logs at error level.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
@ Output
An output workspace.