Mantid
Loading...
Searching...
No Matches
SaveGSS.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2009 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#include "MantidAPI/Run.h"
12#include "MantidDataHandling/DllConfig.h"
14
15#include <iosfwd>
16#include <memory>
17#include <string>
18#include <vector>
19
20// Forward declare
21namespace Mantid {
22namespace HistogramData {
23class Histogram;
24}
25
26namespace DataHandling {
56class MANTID_DATAHANDLING_DLL SaveGSS : public Mantid::API::SerialAlgorithm {
57public:
59 const std::string name() const override { return "SaveGSS"; }
61 const std::string summary() const override { return "Saves a focused data set into a three column GSAS format."; }
62
64 int version() const override { return (1); }
65 const std::vector<std::string> seeAlso() const override {
66 return {"LoadGSS", "SaveVulcanGSS", "SaveGSASInstrumentFile", "SaveAscii"};
67 }
69 const std::string category() const override { return "Diffraction\\DataHandling;DataHandling\\Text"; }
70
71private:
73 void init() override;
75 void exec() override;
76
78 bool areAllDetectorsValid() const;
79
81 void processUserSpecifiedHeaders();
82
84 void generateBankData(std::stringstream &outBuf, size_t specIndex, const std::string &outputFormat,
85 const std::vector<int> &slog_xye_precisions) const;
86
88 void generateBankHeader(std::stringstream &out, const API::SpectrumInfo &spectrumInfo, size_t specIndex) const;
89
91 void generateGSASBuffer(size_t numOutFiles, size_t numOutSpectra);
92
94 void generateInstrumentHeader(std::stringstream &out, double l1) const;
95
97 void generateOutFileNames(size_t numberOfOutFiles);
98
100 void getLogValue(std::stringstream &out, const API::Run &runInfo, const std::string &name,
101 const std::string &failsafeValue = "UNKNOWN") const;
102
104 bool isInstrumentValid() const;
105
107 void openFileStream(const std::string &outFilePath, std::ofstream &outStream);
108
110 void setOtherProperties(IAlgorithm *alg, const std::string &propertyName, const std::string &propertyValue,
111 int periodNum) override;
112
114 std::map<std::string, std::string> validateInputs() override;
115
117 void writeBufferToFile(size_t numOutFiles, size_t numSpectra);
118
119 // Writes the header for RALF data format to the buffer
120 void writeRALFHeader(std::stringstream &out, int bank, const HistogramData::Histogram &histo) const;
121
123 void writeRALF_ALTdata(std::stringstream &out, const int bank, const HistogramData::Histogram &histo) const;
124
126 void writeRALF_XYEdata(const int bank, const bool MultiplyByBinWidth, std::stringstream &out,
127 const HistogramData::Histogram &histo) const;
128
130 void writeSLOGdata(const size_t ws_index, const int bank, const bool MultiplyByBinWidth, std::stringstream &out,
131 const HistogramData::Histogram &histo, const std::vector<int> &xye_precision) const;
132
137 std::vector<std::unique_ptr<std::stringstream>> m_outputBuffer{};
139 std::vector<std::string> m_outFileNames{};
141 bool m_allDetectorsValid{false};
143 std::unique_ptr<API::Progress> m_progress{nullptr};
145 std::vector<std::string> m_user_specified_gsas_header;
149 std::vector<std::string> m_user_specified_bank_headers;
152};
153} // namespace DataHandling
154} // namespace Mantid
IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:45
This class stores information regarding an experimental run as a series of log entries.
Definition: Run.h:38
Base class for algorithms that can only run serially (Parallel::ExecutionMode::MasterOnly) in an MPI ...
API::SpectrumInfo is an intermediate step towards a SpectrumInfo that is part of Instrument-2....
Definition: SpectrumInfo.h:53
Saves a focused data set into a three column GSAS format containing X_i, Y_i*step,...
Definition: SaveGSS.h:56
bool m_overwrite_std_gsas_header
flag to overwrite standard GSAS header
Definition: SaveGSS.h:147
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: SaveGSS.h:65
const std::string name() const override
Algorithm's name.
Definition: SaveGSS.h:59
std::vector< std::string > m_user_specified_gsas_header
User specified header string.
Definition: SaveGSS.h:145
API::MatrixWorkspace_const_sptr m_inputWS
Workspace.
Definition: SaveGSS.h:134
const std::string summary() const override
Summary of algorithms purpose.
Definition: SaveGSS.h:61
const std::string category() const override
Algorithm's category for identification.
Definition: SaveGSS.h:69
int version() const override
Algorithm's version.
Definition: SaveGSS.h:64
std::vector< std::string > m_user_specified_bank_headers
User specified bank header.
Definition: SaveGSS.h:149
bool m_overwrite_std_bank_header
flag to overwrite standard GSAS bank header
Definition: SaveGSS.h:151
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.