25using namespace Kernel;
27using API::MatrixWorkspace;
29using API::WorkspaceProperty;
30using DataObjects::Workspace2D;
41 "The filename of the output CSV file");
43 "The name of the workspace containing the data you want to save to\n"
46 "The separator that will go between the numbers on a line in the\n"
47 "output file (default ',')");
50 "The string to place at the end of lines (default new line\n"
54 "This option saves out the x errors if any are present. If you have x "
56 "in your workspace and you do not select this option, then the x errors\n"
57 "are not saved to the file.");
96 const std::string workspaceID = inputWorkspace->id();
99 if (workspaceID.find(
"Workspace2D") != std::string::npos) {
100 const Workspace2D_sptr localworkspace = std::dynamic_pointer_cast<Workspace2D>(inputWorkspace);
103 const size_t numberOfHist = localworkspace->getNumberHistograms();
107 auto &xValue = localworkspace->x(0);
111 for (
double j : xValue) {
118 Progress p(
this, 0.2, 1.0, 2 * numberOfHist);
119 for (
size_t i = 0; i < numberOfHist; i++) {
123 auto &xValue = localworkspace->x(i);
124 auto &xValuePrevious = localworkspace->x(i - 1);
126 if (xValue.rawData() != xValuePrevious.rawData()) {
129 for (
double j : xValue) {
139 auto &yValue = localworkspace->y(i);
143 for (
double j : yValue) {
152 outCSV_File <<
"\nERRORS\n";
154 for (
size_t i = 0; i < numberOfHist; i++) {
155 auto &eValue = localworkspace->e(i);
159 for (
double j : eValue) {
168 saveXerrors(outCSV_File, localworkspace, numberOfHist);
179 const size_t numberOfHist) {
184 Progress p(
this, 0.0, 1.0, numberOfHist);
185 stream <<
"\nXERRORS\n";
186 for (
size_t i = 0; i < numberOfHist; i++) {
193 p.
report(
"Saving x errors...");
#define DECLARE_ALGORITHM(classname)
IPeaksWorkspace_sptr workspace
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Kernel::Property * getPointerToProperty(const std::string &name) const override
Get a property by name.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
@ Save
to specify a file to write to, the file may or may not exist
Helper class for reporting progress from algorithms.
A property class for workspaces.
std::string m_lineSeparator
The line seperator for the CSV file.
SaveCSV()
Default constructor.
void exec() override
Overwrites Algorithm method.
std::string m_filename
The name of the file used for storing the workspace.
void saveXerrors(std::ofstream &stream, const Mantid::DataObjects::Workspace2D_sptr &workspace, const size_t numberOfHist)
Saves out x errors.
void init() override
Overwrites Algorithm method. Does nothing at present.
std::string m_separator
The seperator for the CSV file.
Records the filename and the description of failure.
Marks code as not implemented yet.
void debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
The concrete, templated class for properties.
void setAutoTrim(const bool &setting)
Sets if the property is set to automatically trim string unput values of whitespace.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< Workspace2D > Workspace2D_sptr
shared pointer to Mantid::DataObjects::Workspace2D
@ Input
An input workspace.