SaveReflThreeColumnAscii.cpp 1.97 KB
Newer Older
Lottie Greenwood's avatar
Lottie Greenwood committed
1
2
#include "MantidDataHandling/SaveReflThreeColumnAscii.h"
#include "MantidDataHandling/AsciiPointBase.h"
3
#include "MantidAPI/MatrixWorkspace.h"
4
#include "MantidAPI/Run.h"
Lottie Greenwood's avatar
Lottie Greenwood committed
5
#include "MantidKernel/ArrayProperty.h"
6

Lottie Greenwood's avatar
Lottie Greenwood committed
7
8
#include <fstream>

9
10
11
12
13
14
15
16
17
18
namespace Mantid {
namespace DataHandling {
// Register the algorithm into the algorithm factory
DECLARE_ALGORITHM(SaveReflThreeColumnAscii)
using namespace Kernel;
using namespace API;

/// virtual method to set the extra properties required for this algorithm
void SaveReflThreeColumnAscii::extraProps() {
  declareProperty("Title", "", "Text to be written to the Title field");
19
  declareProperty(make_unique<ArrayProperty<std::string>>("LogList"),
20
                  "List of logs to write to file.");
21
  appendSeparatorProperty();
22
}
Lottie Greenwood's avatar
Lottie Greenwood committed
23

24
25
26
27
28
29
30
/** virtual method to add information to the file before the data
 *  @param file :: pointer to output file stream
 */
void SaveReflThreeColumnAscii::extraHeaders(std::ofstream &file) {
  auto samp = m_ws->run();
  std::string title = getProperty("Title");

31
  if (!title.empty()) // if is toggled
32
  {
33
    file << "#" << title << '\n';
34
  }
35

36
37
  const std::vector<std::string> logList = getProperty("LogList");
  /// logs
38
39
40
  for (const auto &log : logList) {
    file << boost::lexical_cast<std::string>(log) << ": "
         << boost::lexical_cast<std::string>(samp.getLogData(log)->value())
41
         << '\n';
42
43
  }
}
Lottie Greenwood's avatar
Lottie Greenwood committed
44

45
46
47
48
49
50
51
52
53
54
55
56
57
/** virtual method to add information to the file before the data
 *  @param file :: pointer to output file stream
 *  @param XData :: pointer to a std::vector<double> containing the point data
 * to be printed
 *  @param exportDeltaQ :: bool on whether deltaQ column to be printed
 * (permanantly false in this case)
 */
void SaveReflThreeColumnAscii::data(std::ofstream &file,
                                    const std::vector<double> &XData,
                                    bool exportDeltaQ) {
  exportDeltaQ = false;
  AsciiPointBase::data(file, XData, exportDeltaQ);
}
Lottie Greenwood's avatar
Lottie Greenwood committed
58

59
} // namespace DataHandling
Lottie Greenwood's avatar
Lottie Greenwood committed
60
} // namespace Mantid