24using namespace Kernel;
26using namespace Geometry;
29 auto wsValidator = std::make_shared<CompositeValidator>();
30 wsValidator->add(std::make_shared<WorkspaceUnitValidator>(
"MomentumTransfer"));
34 "The filename of the output text file");
42 std::ofstream out_File(filename.c_str());
44 g_log.
error(
"Failed to open file:" + filename);
47 out_File <<
"Data columns Qx - Qy - I(Qx,Qy) - err(I)\r\n";
48 out_File <<
"ASCII data\r\n";
54 if (inputWS->axes() > 1 && inputWS->getAxis(1)->isNumeric()) {
55 const Axis &axis = *inputWS->getAxis(1);
56 for (
size_t i = 0; i < axis.
length() - 1; i++) {
57 const double qy = (axis(i) + axis(i + 1)) / 2.0;
58 const auto &XIn = inputWS->x(i);
59 const auto &YIn = inputWS->y(i);
60 const auto &EIn = inputWS->e(i);
62 for (
size_t j = 0; j < XIn.size() - 1; j++) {
64 if (YIn[j] == 0 && EIn[j] == 0)
67 if (YIn[j] == YIn[j]) {
68 out_File << (XIn[j] + XIn[j + 1]) / 2.0;
69 out_File <<
" " << qy;
70 out_File <<
" " << YIn[j];
71 out_File <<
" " << EIn[j] <<
"\r\n";
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
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.
Class to represent the axis of a workspace.
virtual std::size_t length() const =0
Get the length of the axis.
@ Save
to specify a file to write to, the file may or may not exist
A validator which checks that a workspace contains histogram data (the default) or point data as requ...
Helper class for reporting progress from algorithms.
A property class for workspaces.
void exec() override
Execution code.
void init() override
Initialisation code.
Records the filename and the description of failure.
void error(const std::string &msg)
Logs at error level.
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
@ Input
An input workspace.