Mantid
Loading...
Searching...
No Matches
LoadRKH.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//---------------------------------------------------
10// Includes
11//---------------------------------------------------
13#include "MantidDataHandling/DllConfig.h"
14#include "MantidHistogramData/Histogram.h"
17
18#include <fstream>
19
20namespace Mantid {
21namespace DataHandling {
35class MANTID_DATAHANDLING_DLL LoadRKH : public API::IFileLoader<Kernel::FileDescriptor> {
36public:
38 const std::string name() const override { return "LoadRKH"; }
40 const std::string summary() const override { return "Load a file written in the RKH format"; }
41
43 int version() const override { return (1); }
44 const std::vector<std::string> seeAlso() const override { return {"SaveRKH"}; }
46 const std::string category() const override { return "DataHandling\\Text;SANS\\DataHandling"; }
47
49 int confidence(Kernel::FileDescriptor &descriptor) const override;
50
51private:
53 std::unordered_set<std::string> m_unitKeys;
55 std::unordered_set<std::string> m_RKHKeys;
57 std::ifstream m_fileIn;
58
59 // Initialisation code
60 void init() override;
61 // Execution code
62 void exec() override;
63
64 bool is2D(const std::string &testLine);
65 const API::MatrixWorkspace_sptr read1D();
66 const API::MatrixWorkspace_sptr read2D(const std::string &firstLine);
67 API::Progress read2DHeader(const std::string &initalLine, API::MatrixWorkspace_sptr &outWrksp, MantidVec &axis0Data);
68 const std::string readUnit(const std::string &line);
69 void readNumEntrys(const int nEntries, MantidVec &output);
70 void binCenter(const MantidVec &oldBoundaries, MantidVec &toCenter) const;
71
72 // Remove lines from an input stream
73 void skipLines(std::istream &strm, int nlines);
74
76 bool hasXerror(std::ifstream &stream);
77
79 void readLinesForRKH1D(std::istream &stream, int readStart, int readEnd, HistogramData::Points &x,
80 HistogramData::Counts &y, HistogramData::CountStandardDeviations &ye,
81 HistogramData::PointStandardDeviations &xe, API::Progress &prog, bool readXError = false);
82};
83} // namespace DataHandling
84} // namespace Mantid
Defines an interface to an algorithm that loads a file so that it can take part in the automatic sele...
Definition: IFileLoader.h:19
Helper class for reporting progress from algorithms.
Definition: Progress.h:25
Loads an RKH file into a Mantid 1D workspace.
Definition: LoadRKH.h:35
std::unordered_set< std::string > m_RKHKeys
Store the units added as options for this algorithm.
Definition: LoadRKH.h:55
const std::string name() const override
Algorithm's name.
Definition: LoadRKH.h:38
const std::string category() const override
Algorithm's category for identification.
Definition: LoadRKH.h:46
std::unordered_set< std::string > m_unitKeys
Store the units known to the UnitFactory.
Definition: LoadRKH.h:53
std::ifstream m_fileIn
the input stream for the file being loaded
Definition: LoadRKH.h:57
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: LoadRKH.h:44
const std::string summary() const override
Summary of algorithms purpose.
Definition: LoadRKH.h:40
int version() const override
Algorithm's version.
Definition: LoadRKH.h:43
Defines a wrapper around an open file.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
Helper class which provides the Collimation Length for SANS instruments.
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
Definition: cow_ptr.h:172