Mantid
Loading...
Searching...
No Matches
SaveSPE.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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//---------------------------------------------------
12#include "MantidAPI/Algorithm.h"
13#include "MantidDataHandling/DllConfig.h"
15#include <vector>
16
17namespace Mantid {
18namespace HistogramData {
19class HistogramY;
20class HistogramE;
21} // namespace HistogramData
22namespace DataHandling {
53class MANTID_DATAHANDLING_DLL SaveSPE final : public API::Algorithm {
54public:
56 SaveSPE();
58 const std::string name() const override { return "SaveSPE"; }
60 const std::string summary() const override { return "Writes a workspace into a file the spe format."; }
61
63 int version() const override { return (1); }
64 const std::vector<std::string> seeAlso() const override { return {"LoadSPE", "SavePAR", "SavePHX"}; }
66 const std::string category() const override { return "DataHandling\\SPE;Inelastic\\DataHandling"; }
67
70 static const double MASK_FLAG;
71
72private:
74 void init() override;
76 void exec() override;
77
78 void writeSPEFile(FILE *outSPEFile, const API::MatrixWorkspace_const_sptr &inputWS);
79 void writeHists(const API::MatrixWorkspace_const_sptr &WS, FILE *const outFile);
80 void writeHist(const API::MatrixWorkspace_const_sptr &WS, FILE *const outFile, const int wsIn) const;
81 void writeMaskFlags(FILE *const outFile) const;
82 void writeBins(const std::vector<double> &Vs, FILE *const outFile) const;
83 void writeValue(const double value, FILE *const outFile) const;
84 void logMissingMasked(const std::vector<int> &inds, const size_t nonMasked, const int masked) const;
85
92 size_t m_nBins;
93
97 static const double MASK_ERROR;
98
99 // temporary variable to keep verified signal values for current spectra
100 mutable std::vector<double> m_tSignal;
101 // temporary variable to keep verified error values for current spectra
102 mutable std::vector<double> m_tError;
103
104 // method verifies if a spectra contains any NaN or Inf values and replaces
105 // these values with SPE-specified constants
106 void check_and_copy_spectra(const HistogramData::HistogramY &inSignal, const HistogramData::HistogramE &inErr,
107 std::vector<double> &Signal, std::vector<double> &Error) const;
108};
109
110} // namespace DataHandling
111} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
Saves a workspace into an ASCII SPE file.
Definition: SaveSPE.h:53
std::vector< double > m_tSignal
Definition: SaveSPE.h:100
const std::string name() const override
Algorithm's name.
Definition: SaveSPE.h:58
static const double MASK_ERROR
the error value (=0.0) for spectra whose detectors are all masked, from the SPE specification http://...
Definition: SaveSPE.h:97
const std::string category() const override
Algorithm's category for identification.
Definition: SaveSPE.h:66
int m_remainder
the SPE files have a constant number of numbers written on each line, but depending on the number of ...
Definition: SaveSPE.h:89
const std::string summary() const override
Summary of algorithms purpose.
Definition: SaveSPE.h:60
static const double MASK_FLAG
the mask flag (=-1e30) from the SPE specification http://www.mantidproject.org/images/3/3d/Spe_file_f...
Definition: SaveSPE.h:70
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
Definition: SaveSPE.h:64
size_t m_nBins
the number of bins in each histogram, as the histogram must have common bins this shouldn't change
Definition: SaveSPE.h:92
std::vector< double > m_tError
Definition: SaveSPE.h:102
int version() const override
Algorithm's version.
Definition: SaveSPE.h:63
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
Helper class which provides the Collimation Length for SANS instruments.