15#include "MantidHistogramData/Histogram.h"
16#include "MantidHistogramData/HistogramBuilder.h"
26using namespace Kernel;
28using namespace DataObjects;
29using namespace HistogramData;
34 "The name of the input workspace.");
36 "The name of the output workspace.");
38 auto mustBePositive = std::make_shared<BoundedValidator<int>>();
39 mustBePositive->setLower(0);
40 declareProperty(
"WorkspaceIndex", 0, mustBePositive,
"Workspace index for smoothing");
42 std::vector<std::string> type{
"Zeroing"};
43 declareProperty(
"Filter",
"Zeroing", std::make_shared<StringListValidator>(type),
"The type of the applied filter");
54 double x0 =
m_inWS->x(spec)[0];
57 auto dn =
static_cast<int>(
m_inWS->y(0).size());
59 HistogramBuilder builder;
60 builder.setX(
m_inWS->x(0).size() + dn);
61 builder.setY(
m_inWS->y(0).size() + dn);
62 builder.setDistribution(
m_inWS->isDistribution());
65 double dx = (
m_inWS->x(spec).back() -
m_inWS->x(spec).front()) /
static_cast<double>(
m_inWS->x(spec).size() - 1);
67 auto &symX = symmWS->mutableX(0);
68 auto &symY = symmWS->mutableY(0);
70 for (
int i = 0; i < dn; i++) {
71 symX[dn + i] =
m_inWS->x(spec)[i];
72 symY[dn + i] =
m_inWS->y(spec)[i];
74 symX[dn - i] = x0 - dx * i;
75 symY[dn - i] =
m_inWS->y(spec)[i];
77 symmWS->mutableY(0).front() =
m_inWS->y(spec).back();
78 symmWS->mutableX(0).front() = x0 - dx * dn;
79 if (
m_inWS->isHistogramData())
80 symmWS->mutableX(0).back() =
m_inWS->x(spec).back();
84 fft->setProperty(
"InputWorkspace", symmWS);
85 fft->setProperty(
"WorkspaceIndex", 0);
98 if (type ==
"Zeroing") {
106 throw std::invalid_argument(
"Truncation parameter must be an integer > 1");
113 fft->setProperty(
"Transform",
"Backward");
117 g_log.
error(
"Error in inverse FFT algorithm");
123 builder.setX(
m_inWS->x(0).size());
124 builder.setY(
m_inWS->y(0).size());
125 builder.setDistribution(
m_inWS->isDistribution());
128 dn =
static_cast<int>(tmpWS->blocksize()) / 2;
130 outWS->setSharedX(0,
m_inWS->sharedX(0));
131 outWS->mutableY(0).assign(tmpWS->y(0).cbegin() + dn, tmpWS->y(0).cend());
143 double f = double(ny) / my;
148 HistogramBuilder builder;
163 yr.assign(Yr.begin(), Yr.begin() + ny);
164 yi.assign(Yi.begin(), Yi.begin() + ny);
165 xr.assign(
X.begin(),
X.begin() + nx);
166 xi.assign(
X.begin(),
X.begin() + nx);
168 using std::placeholders::_1;
169 std::transform(yr.begin(), yr.end(), yr.begin(), std::bind(std::multiplies<double>(), _1, f));
170 std::transform(yi.begin(), yi.end(), yi.begin(), std::bind(std::multiplies<double>(), _1, f));
184 HistogramBuilder builder;
#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.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
A property class for workspaces.
API::MatrixWorkspace_sptr m_inWS
The input workspace.
void zero(int n)
Smoothing by zeroing.
void exec() override
Executes the algorithm.
API::MatrixWorkspace_sptr m_filteredWS
Temporary workspace for keeping the filtered spectrum.
void truncate(int n)
Smoothing by truncation.
API::MatrixWorkspace_sptr m_unfilteredWS
Temporary workspace for keeping the unfiltered Fourier transform of the imput spectrum.
void init() override
Initialisation method. Declares properties to be used in algorithm.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void error(const std::string &msg)
Logs at error level.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
@ Input
An input workspace.
@ Output
An output workspace.