Mantid
Loading...
Searching...
No Matches
LoadSESANS.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2017 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
10#include "MantidDataHandling/DllConfig.h"
12
13#include <unordered_map>
14
15using Column = std::vector<double>;
16using ColumnMap = std::unordered_map<std::string, Column>;
17using AttributeMap = std::unordered_map<std::string, std::string>;
18
19namespace Mantid {
20namespace DataHandling {
21
33class MANTID_DATAHANDLING_DLL LoadSESANS : public API::IFileLoader<Kernel::FileDescriptor> {
34public:
35 const std::string name() const override;
36 const std::string summary() const override;
37 int version() const override;
38 const std::vector<std::string> seeAlso() const override { return {"SaveSESANS"}; }
39 const std::string category() const override;
40 int confidence(Kernel::FileDescriptor &descriptor) const override;
41
42private:
43 // Private constants
44 const std::string m_spinEchoLength = "SpinEchoLength";
45 const std::string m_wavelength = "Wavelength";
46 const std::string m_depolarisation = "Depolarisation";
47 const std::string m_depolarisationError = "Depolarisation_error";
48 const std::string m_beginData = "BEGIN_DATA";
49
50 const std::vector<std::string> m_mandatoryAttributes{
51 "FileFormatVersion", "DataFileTitle", "Sample", "Thickness", "Thickness_unit",
52 "Theta_zmax", "Theta_zmax_unit", "Theta_ymax", "Theta_ymax_unit", "Orientation",
53 "SpinEchoLength_unit", "Depolarisation_unit", "Wavelength_unit"};
54 const std::vector<std::string> m_mandatoryColumnHeaders{m_spinEchoLength, m_wavelength, m_depolarisation,
55 m_depolarisationError};
56 const std::vector<std::string> m_fileExtensions{".ses", ".SES", ".sesans", ".SESANS"};
57
58 // Private functions
59 void init() override;
60 void exec() override;
61
62 AttributeMap consumeHeaders(std::ifstream &infile, std::string &line, int &lineNum);
63 ColumnMap consumeData(std::ifstream &infile, std::string &line, int &lineNum);
64 std::pair<std::string, std::string> splitHeader(const std::string &line, const int &lineNum);
65
66 void checkMandatoryHeaders(const AttributeMap &attributes);
67
68 void throwFormatError(const std::string &line, const std::string &message, const int &lineNum);
69
70 API::MatrixWorkspace_sptr makeWorkspace(ColumnMap columns);
71};
72
73} // namespace DataHandling
74} // namespace Mantid
std::unordered_map< std::string, Column > ColumnMap
Definition: LoadSESANS.h:16
std::unordered_map< std::string, std::string > AttributeMap
Definition: LoadSESANS.h:17
std::vector< double > Column
Definition: LoadSESANS.h:15
Defines an interface to an algorithm that loads a file so that it can take part in the automatic sele...
Definition: IFileLoader.h:19
LoadSESANS : Load a workspace in the SESANS file format.
Definition: LoadSESANS.h:33
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: LoadSESANS.h:38
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.