37 "An output workspace.");
38 declareProperty(
"AddMinimum",
true,
"Add the minimum value of the spectrum to bring it up to zero.");
39 declareProperty(
"ResetValue", 0.,
"Reset negative values to this number (default=0)");
52 alg->executeAsChildAlg();
56 auto nHist =
static_cast<int64_t
>(minWS->getNumberHistograms());
57 bool hasNegative =
false;
58 for (int64_t i = 0; i < nHist; i++) {
59 if (minWS->y(i)[0] < 0.0) {
69 if (inputWS != outputWS) {
72 clone->executeAsChildAlg();
75 setProperty(
"OutputWorkspace", std::dynamic_pointer_cast<MatrixWorkspace>(temp));
82 std::dynamic_pointer_cast<const DataObjects::EventWorkspace>(inputWS);
86 Progress prog(
this, 0.1, 1.0, 2 * nHist);
91 for (int64_t i = 0; i < nHist; i++) {
93 const auto index =
static_cast<size_t>(i);
94 outputWS->setHistogram(
index, inputWS->histogram(
index));
114inline double fixZero(
const double value) {
return value != -0. ?
value : 0.; }
128 int64_t nHist = minWS->getNumberHistograms();
130 for (int64_t i = 0; i < nHist; i++) {
135 auto &
y = wksp->mutableY(i);
136 std::transform(
y.begin(),
y.end(),
y.begin(), [
minValue](
double value) { return fixZero(value + minValue); });
156 int64_t nHist = wksp->getNumberHistograms();
158 for (int64_t i = 0; i < nHist; i++) {
160 if (minWS->y(i)[0] <= 0.)
162 auto &
y = wksp->mutableY(i);
165 value = spectrumNegativeValues;
#define DECLARE_ALGORITHM(classname)
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
#define PARALLEL_START_INTERRUPT_REGION
Begins a block to skip processing is the algorithm has been interupted Note the end of the block if n...
#define PARALLEL_END_INTERRUPT_REGION
Ends a block to skip processing is the algorithm has been interupted Note the start of the block if n...
#define PARALLEL_FOR_IF(condition)
Empty definitions - to enable set your complier to enable openMP.
#define PARALLEL_CHECK_INTERRUPT_REGION
Adds a check after a Parallel region to see if it was interupted.
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.
Helper class for reporting progress from algorithms.
A property class for workspaces.
ResetNegatives : Reset negative values to something else.
void changeNegatives(const API::MatrixWorkspace_const_sptr &minWS, const double spectrumNegativeValues, const API::MatrixWorkspace_sptr &wksp, API::Progress &prog)
Search each spectrum for y-values that are less than zero and reset them to the supplied value.
int version() const override
function to return a version of the algorithm, must be overridden in all algorithms
void pushMinimum(const API::MatrixWorkspace_const_sptr &minWS, const API::MatrixWorkspace_sptr &wksp, API::Progress &prog)
Add -1.
void init() override
Virtual method - must be overridden by concrete algorithm.
const std::string category() const override
function to return a category of the algorithm.
void exec() override
Virtual method - must be overridden by concrete algorithm.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void setPropertySettings(const std::string &name, std::unique_ptr< IPropertySettings > settings)
void information(const std::string &msg)
Logs at information level.
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< const EventWorkspace > EventWorkspace_const_sptr
shared pointer to a const Workspace2D
std::enable_if< std::is_pointer< Arg >::value, bool >::type threadSafe(Arg workspace)
Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access.
@ Input
An input workspace.
@ Output
An output workspace.