-
Notifications
You must be signed in to change notification settings - Fork 122
/
SaveSESANS.h
66 lines (55 loc) · 2.58 KB
/
SaveSESANS.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2017 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include "MantidAPI/Algorithm.h"
#include "MantidDataHandling/DllConfig.h"
#include "MantidHistogramData/Histogram.h"
#include "MantidKernel/cow_ptr.h"
#include <map>
namespace Mantid {
namespace DataHandling {
/** SaveSESANS : Save a workspace in the SESANS file format
Require properties:
<UL>
<LI> InputWorkspace - The name of the workspace to save</LI>
<LI> Filename - The path to save the file</LI>
<LI> ThetaZMax - The angular acceptance in the encoding direction</LI>
<LI> ThetaZMazUnit - Unit for theta_znmax</LI>
<LI> ThetaYMax - The angular acceptance in the non-encoding direction</LI>
<LI> ThetaYMazUnit - Unit for theta_ymax</LI>
<LI> EchoConstant - The spin echo length, in nanometers,
probed by a 1A neutron</LI>
</UL>
@author Joseph Ramsay, ISIS
@date 19/07/2017
*/
class MANTID_DATAHANDLING_DLL SaveSESANS : public API::Algorithm {
public:
const std::string name() const override;
const std::string summary() const override;
int version() const override;
const std::vector<std::string> seeAlso() const override { return {"LoadSESANS"}; }
const std::string category() const override;
std::map<std::string, std::string> validateInputs() override;
private:
// Length of the longest attribute name in headers (+4 for readability in the
// file)
const int MAX_HDR_LENGTH = 23;
const std::vector<std::string> fileExtensions{".ses", ".SES", ".sesans", ".SESANS"};
const std::vector<std::string> mandatoryDoubleProperties{"ThetaZMax", "ThetaYMax", "EchoConstant"};
void init() override;
void exec() override;
void writeHeaders(std::ofstream &outfile, API::MatrixWorkspace_const_sptr &ws);
void writeHeader(std::ofstream &outfile, const std::string &name, const std::string &value);
std::vector<double> calculateSpinEchoLength(const HistogramData::Points &wavelength) const;
std::vector<double> calculateDepolarisation(const HistogramData::HistogramY &yValues,
const HistogramData::Points &wavelength) const;
Mantid::MantidVec calculateError(const HistogramData::HistogramE &eValues, const HistogramData::HistogramY &yValues,
const HistogramData::Points &wavelength) const;
};
} // namespace DataHandling
} // namespace Mantid