Mantid
Loading...
Searching...
No Matches
Stitch1D.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
12#include "MantidHistogramData/HistogramDx.h"
13#include "MantidHistogramData/HistogramE.h"
14#include "MantidHistogramData/HistogramX.h"
15#include "MantidHistogramData/HistogramY.h"
21
22#include <algorithm>
23#include <boost/format.hpp>
24#include <boost/math/special_functions.hpp>
25#include <boost/tuple/tuple.hpp>
26#include <map>
27
28using namespace Mantid::API;
29using namespace Mantid::Kernel;
30using Mantid::HistogramData::HistogramE;
31using Mantid::HistogramData::HistogramY;
32
33namespace {
36using MinMaxTuple = boost::tuple<double, double>;
37MinMaxTuple calculateXIntersection(MatrixWorkspace_const_sptr &lhsWS, MatrixWorkspace_const_sptr &rhsWS) {
38 return MinMaxTuple(rhsWS->x(0).front(), lhsWS->x(0).back());
39}
40
42bool isNonzero(double i) { return (0 != i); }
43} // namespace
44
45namespace Mantid::Algorithms {
46
52const double Stitch1D::range_tolerance = 1e-9;
53// Register the algorithm into the AlgorithmFactory
54DECLARE_ALGORITHM(Stitch1D)
55
56
61MatrixWorkspace_sptr Stitch1D::maskAllBut(int a1, int a2, MatrixWorkspace_sptr &source) {
62 MatrixWorkspace_sptr product = source->clone();
63 const auto histogramCount = static_cast<int>(source->getNumberHistograms());
64 PARALLEL_FOR_IF(Kernel::threadSafe(*source, *product))
65 for (int i = 0; i < histogramCount; ++i) {
67 // Copy over the bin boundaries
68 product->setSharedX(i, source->sharedX(i));
69 // Copy over the data
70 const auto &sourceY = source->y(i);
71 const auto &sourceE = source->e(i);
72
73 // initially zero - out the data.
74 product->mutableY(i) = HistogramY(sourceY.size(), 0);
75 product->mutableE(i) = HistogramE(sourceE.size(), 0);
76
77 auto &newY = product->mutableY(i);
78 auto &newE = product->mutableE(i);
79
80 // Copy over the non-zero stuff
81 std::copy(sourceY.begin() + a1 + 1, sourceY.begin() + a2, newY.begin() + a1 + 1);
82 std::copy(sourceE.begin() + a1 + 1, sourceE.begin() + a2, newE.begin() + a1 + 1);
83
85 }
87 return product;
88}
89
97void Stitch1D::maskInPlace(int a1, int a2, MatrixWorkspace_sptr &source) {
98 const auto histogramCount = static_cast<int>(source->getNumberHistograms());
100 for (int i = 0; i < histogramCount; ++i) {
102 // Copy over the data
103 auto &sourceY = source->mutableY(i);
104 auto &sourceE = source->mutableE(i);
105 for (int binIndex = a1; binIndex < a2; ++binIndex) {
106 sourceY[binIndex] = 0;
107 sourceE[binIndex] = 0;
108 }
109
111 }
113}
114
115//----------------------------------------------------------------------------------------------
119
120 declareProperty(std::make_unique<WorkspaceProperty<MatrixWorkspace>>("LHSWorkspace", "", Direction::Input),
121 "LHS input workspace.");
122 declareProperty(std::make_unique<WorkspaceProperty<MatrixWorkspace>>("RHSWorkspace", "", Direction::Input),
123 "RHS input workspace, must be same type as LHSWorkspace "
124 "(histogram or point data).");
125 declareProperty(std::make_unique<WorkspaceProperty<MatrixWorkspace>>("OutputWorkspace", "", Direction::Output),
126 "Output stitched workspace.");
128 "Start overlap x-value in units of x-axis.");
130 "End overlap x-value in units of x-axis.");
131 declareProperty(std::make_unique<ArrayProperty<double>>("Params", std::make_shared<RebinParamsValidator>(true)),
132 "Rebinning Parameters. See Rebin for format. If only a "
133 "single value is provided, start and end are taken from "
134 "input workspaces.");
135 declareProperty(std::make_unique<PropertyWithValue<bool>>("ScaleRHSWorkspace", true, Direction::Input),
136 "Scaling either with respect to LHS workspace or RHS workspace");
137 declareProperty(std::make_unique<PropertyWithValue<bool>>("UseManualScaleFactor", false, Direction::Input),
138 "True to use a provided value for the scale factor.");
139 auto manualScaleFactorValidator = std::make_shared<BoundedValidator<double>>();
140 manualScaleFactorValidator->setLower(0);
141 manualScaleFactorValidator->setExclusive(true);
142 declareProperty(std::make_unique<PropertyWithValue<double>>("ManualScaleFactor", 1.0, manualScaleFactorValidator,
144 "Provided value for the scale factor.");
146 "The actual used value for the scaling factor.");
147}
148
152std::map<std::string, std::string> Stitch1D::validateInputs(void) {
153 std::map<std::string, std::string> issues;
154 MatrixWorkspace_sptr lhs = getProperty("LHSWorkspace");
155 MatrixWorkspace_sptr rhs = getProperty("RHSWorkspace");
156 if (!lhs) {
157 issues["LHSWorkspace"] = "The LHSWorkspace must be a MatrixWorkspace.";
158 }
159 if (!rhs) {
160 issues["RHSWorkspace"] = "The RHSWorkspace must be a MatrixWorkspace.";
161 }
162 if (!issues.empty()) {
163 return issues;
164 }
165 RunCombinationHelper combHelper;
166 combHelper.setReferenceProperties(lhs);
167 std::string compatible = combHelper.checkCompatibility(rhs, true);
168 if (!compatible.empty()) {
169 // histograms: no recalculation of Dx implemented -> do not treat Dx
170 if (!(compatible == "spectra must have either Dx values or not; ") ||
171 (rhs->isHistogramData())) // Issue only for point data
172 issues["RHSWorkspace"] = "Workspace " + rhs->getName() + " is not compatible: " + compatible + "\n";
173 }
174 return issues;
175}
176
184double Stitch1D::getStartOverlap(const double intesectionMin, const double intesectionMax) const {
185 Property *startOverlapProp = this->getProperty("StartOverlap");
186 double startOverlapVal = this->getProperty("StartOverlap");
187 startOverlapVal -= this->range_tolerance;
188 const bool startOverlapBeyondRange = (startOverlapVal < intesectionMin) || (startOverlapVal > intesectionMax);
189 if (startOverlapProp->isDefault() || startOverlapBeyondRange) {
190 if (!startOverlapProp->isDefault() && startOverlapBeyondRange) {
191 char message[200];
192 std::sprintf(message,
193 "StartOverlap is outside range at %0.4f, Min is "
194 "%0.4f, Max is %0.4f . Forced to be: %0.4f",
195 startOverlapVal, intesectionMin, intesectionMax, intesectionMin);
196 g_log.warning(std::string(message));
197 }
198 startOverlapVal = intesectionMin;
199 std::stringstream buffer;
200 buffer << "StartOverlap calculated to be: " << startOverlapVal;
201 g_log.information(buffer.str());
202 }
203 return startOverlapVal;
204}
205
213double Stitch1D::getEndOverlap(const double intesectionMin, const double intesectionMax) const {
214 Property *endOverlapProp = this->getProperty("EndOverlap");
215 double endOverlapVal = this->getProperty("EndOverlap");
216 endOverlapVal += this->range_tolerance;
217 const bool endOverlapBeyondRange = (endOverlapVal < intesectionMin) || (endOverlapVal > intesectionMax);
218 if (endOverlapProp->isDefault() || endOverlapBeyondRange) {
219 if (!endOverlapProp->isDefault() && endOverlapBeyondRange) {
220 char message[200];
221 std::sprintf(message,
222 "EndOverlap is outside range at %0.4f, Min is "
223 "%0.4f, Max is %0.4f . Forced to be: %0.4f",
224 endOverlapVal, intesectionMin, intesectionMax, intesectionMax);
225 g_log.warning(std::string(message));
226 }
227 endOverlapVal = intesectionMax;
228 std::stringstream buffer;
229 buffer << "EndOverlap calculated to be: " << endOverlapVal;
230 g_log.information(buffer.str());
231 }
232 return endOverlapVal;
233}
234
242 const bool scaleRHS) const {
243 std::vector<double> inputParams = this->getProperty("Params");
244 Property *prop = this->getProperty("Params");
245 const bool areParamsDefault = prop->isDefault();
246
247 const auto &lhsX = lhsWS->x(0);
248 auto it = std::min_element(lhsX.begin(), lhsX.end());
249 const double minLHSX = *it;
250
251 const auto &rhsX = rhsWS->x(0);
252 it = std::max_element(rhsX.begin(), rhsX.end());
253 const double maxRHSX = *it;
254
255 std::vector<double> result;
256 if (areParamsDefault) {
257 std::vector<double> calculatedParams;
258
259 // Calculate the step size based on the existing step size of the LHS
260 // workspace. That way scale factors should be reasonably maintained.
261 double calculatedStep = 0;
262 if (scaleRHS) {
263 // Calculate the step from the workspace that will not be scaled. The LHS
264 // workspace.
265 calculatedStep = lhsX[1] - lhsX[0];
266 } else {
267 // Calculate the step from the workspace that will not be scaled. The RHS
268 // workspace.
269 calculatedStep = rhsX[1] - rhsX[0];
270 }
271
272 calculatedParams.emplace_back(minLHSX);
273 calculatedParams.emplace_back(calculatedStep);
274 calculatedParams.emplace_back(maxRHSX);
275 result = calculatedParams;
276 } else {
277 if (inputParams.size() == 1) {
278 std::vector<double> calculatedParams;
279 calculatedParams.emplace_back(minLHSX);
280 calculatedParams.emplace_back(inputParams.front()); // Use the step supplied.
281 calculatedParams.emplace_back(maxRHSX);
282 result = calculatedParams;
283 } else {
284 result = inputParams; // user has provided params. Use those.
285 }
286 }
287 return result;
288}
289
295MatrixWorkspace_sptr Stitch1D::rebin(MatrixWorkspace_sptr &input, const std::vector<double> &params) {
296 auto rebin = this->createChildAlgorithm("Rebin");
297 rebin->setProperty("InputWorkspace", input);
298 rebin->setProperty("Params", params);
299 std::stringstream ssParams;
300 ssParams << params[0] << "," << params[1] << "," << params[2];
301 g_log.information("Rebinning Params: " + ssParams.str());
302 rebin->execute();
303 MatrixWorkspace_sptr outWS = rebin->getProperty("OutputWorkspace");
304
305 const auto histogramCount = static_cast<int>(outWS->getNumberHistograms());
306
307 // Record special values and then mask them out as zeros. Special values are
308 // remembered and then replaced post processing.
310 for (int i = 0; i < histogramCount; ++i) {
312 std::vector<size_t> &nanEIndexes = m_nanEIndexes[i];
313 std::vector<size_t> &nanYIndexes = m_nanYIndexes[i];
314 std::vector<size_t> &infEIndexes = m_infEIndexes[i];
315 std::vector<size_t> &infYIndexes = m_infYIndexes[i];
316 // Copy over the data
317 auto &sourceY = outWS->mutableY(i);
318 auto &sourceE = outWS->mutableE(i);
319
320 for (size_t j = 0; j < sourceY.size(); ++j) {
321 const double value = sourceY[j];
322 if (std::isnan(value)) {
323 nanYIndexes.emplace_back(j);
324 sourceY[j] = 0;
325 } else if (std::isinf(value)) {
326 infYIndexes.emplace_back(j);
327 sourceY[j] = 0;
328 }
329
330 const double eValue = sourceE[j];
331 if (std::isnan(eValue)) {
332 nanEIndexes.emplace_back(j);
333 sourceE[j] = 0;
334 } else if (std::isinf(eValue)) {
335 infEIndexes.emplace_back(j);
336 sourceE[j] = 0;
337 }
338 }
339
341 }
343
344 return outWS;
345}
346
353MatrixWorkspace_sptr Stitch1D::integration(MatrixWorkspace_sptr &input, const double start, const double stop) {
354 auto integration = this->createChildAlgorithm("Integration");
355 integration->initialize();
356 integration->setProperty("InputWorkspace", input);
357 integration->setProperty("RangeLower", start);
358 integration->setProperty("RangeUpper", stop);
359 g_log.information("Integration RangeLower: " + boost::lexical_cast<std::string>(start));
360 g_log.information("Integration RangeUpper: " + boost::lexical_cast<std::string>(stop));
361 integration->execute();
362 return integration->getProperty("OutputWorkspace");
363}
364
371 auto weightedMean = this->createChildAlgorithm("WeightedMean");
372 weightedMean->initialize();
373 weightedMean->setProperty("InputWorkspace1", inOne);
374 weightedMean->setProperty("InputWorkspace2", inTwo);
375 weightedMean->execute();
376 return weightedMean->getProperty("OutputWorkspace");
377}
378
385 const std::string in1 = "__Stitch1D_intermediate_workspace_1__";
386 const std::string in2 = "__Stitch1D_intermediate_workspace_2__";
387 Mantid::API::AnalysisDataService::Instance().addOrReplace(in1, inOne);
388 Mantid::API::AnalysisDataService::Instance().addOrReplace(in2, inTwo);
389 auto conjoinX = this->createChildAlgorithm("ConjoinXRuns");
390 conjoinX->initialize();
391 conjoinX->setProperty("InputWorkspaces", std::vector<std::string>{in1, in2});
392 conjoinX->execute();
395 API::Workspace_sptr ws = conjoinX->getProperty("OutputWorkspace");
396 return std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(ws);
397}
404boost::tuple<int, int> Stitch1D::findStartEndIndexes(double startOverlap, double endOverlap,
406 auto a1 = static_cast<int>(workspace->yIndexOfX(startOverlap));
407 auto a2 = static_cast<int>(workspace->yIndexOfX(endOverlap));
408 if (a1 == a2) {
409 throw std::runtime_error("The Params you have provided for binning yield a "
410 "workspace in which start and end overlap appear "
411 "in the same bin. Make binning finer via input "
412 "Params.");
413 }
414 return boost::tuple<int, int>(a1, a2);
415}
416
422 auto ws_size = static_cast<int64_t>(ws->getNumberHistograms());
423 bool hasNonZeroErrors = false;
425 for (int64_t i = 0; i < ws_size; ++i) {
427 if (!hasNonZeroErrors) // Keep checking
428 {
429 const auto &e = ws->e(i);
430 auto it = std::find_if(e.begin(), e.end(), isNonzero);
431 if (it != e.end()) {
432 PARALLEL_CRITICAL(has_non_zero) {
433 hasNonZeroErrors = true; // Set flag. Should not need to check any more spectra.
434 }
435 }
436 }
438 }
440
441 return hasNonZeroErrors;
442}
443
452 ws *= scaleFactorWS;
453 // We lost Dx values (Multiply) and need to get them back for point data
454 if (ws->size() == dxWS->size()) {
455 for (size_t i = 0; i < ws->getNumberHistograms(); ++i) {
456 if (dxWS->hasDx(i) && !ws->hasDx(i) && !ws->isHistogramData()) {
457 ws->setSharedDx(i, dxWS->sharedDx(i));
458 }
459 }
460 }
461 m_scaleFactor = scaleFactorWS->y(0).front();
462 m_errorScaleFactor = scaleFactorWS->e(0).front();
463 if (m_scaleFactor < 1e-2 || m_scaleFactor > 1e2 || std::isnan(m_scaleFactor)) {
464 std::stringstream messageBuffer;
465 messageBuffer << "Stitch1D calculated scale factor is: " << m_scaleFactor
466 << ". Check the overlap region is non-zero.";
467 g_log.warning(messageBuffer.str());
468 }
469}
470
471//----------------------------------------------------------------------------------------------
475 MatrixWorkspace_const_sptr lhsWS = this->getProperty("LHSWorkspace");
476 MatrixWorkspace_const_sptr rhsWS = this->getProperty("RHSWorkspace");
477 const MinMaxTuple intesectionXRegion = calculateXIntersection(lhsWS, rhsWS);
478
479 const size_t histogramCount = rhsWS->getNumberHistograms();
480 m_nanYIndexes.resize(histogramCount);
481 m_infYIndexes.resize(histogramCount);
482 m_nanEIndexes.resize(histogramCount);
483 m_infEIndexes.resize(histogramCount);
484
485 const double intersectionMin = intesectionXRegion.get<0>();
486 const double intersectionMax = intesectionXRegion.get<1>();
487 double startOverlap = getStartOverlap(intersectionMin, intersectionMax);
488 double endOverlap = getEndOverlap(intersectionMin, intersectionMax);
489 if (startOverlap > endOverlap) {
490 std::string message = boost::str(boost::format("Stitch1D cannot have a StartOverlap > EndOverlap. "
491 "StartOverlap: %0.9f, EndOverlap: %0.9f") %
492 startOverlap % endOverlap);
493 throw std::runtime_error(message);
494 }
495
496 const bool scaleRHS = this->getProperty("ScaleRHSWorkspace");
497
498 MatrixWorkspace_sptr lhs = lhsWS->clone();
499 MatrixWorkspace_sptr rhs = rhsWS->clone();
500 if (lhsWS->isHistogramData()) {
501 MantidVec params = getRebinParams(lhsWS, rhsWS, scaleRHS);
502 const double xMin = params.front();
503 const double xMax = params.back();
504
505 if (std::abs(xMin - startOverlap) < 1E-6)
506 startOverlap = xMin;
507
508 if (std::abs(xMax - endOverlap) < 1E-6)
509 endOverlap = xMax;
510
511 if (startOverlap < xMin) {
512 std::string message = boost::str(boost::format("Stitch1D StartOverlap is outside the available X range. "
513 "StartOverlap: %10.9f, X min: %10.9f") %
514 startOverlap % xMin);
515 throw std::runtime_error(message);
516 }
517 if (endOverlap > xMax) {
518 std::string message = boost::str(boost::format("Stitch1D EndOverlap is outside the available X range. "
519 "EndOverlap: %10.9f, X max: %10.9f") %
520 endOverlap % xMax);
521 throw std::runtime_error(message);
522 }
523 lhs = rebin(lhs, params);
524 rhs = rebin(rhs, params);
525 }
526
527 m_scaleFactor = this->getProperty("ManualScaleFactor");
529 const bool useManualScaleFactor = this->getProperty("UseManualScaleFactor");
530 if (useManualScaleFactor) {
531 if (scaleRHS)
533 else
534 lhs *= m_scaleFactor;
535 } else {
536 auto rhsOverlapIntegrated = integration(rhs, startOverlap, endOverlap);
537 auto lhsOverlapIntegrated = integration(lhs, startOverlap, endOverlap);
538 if (scaleRHS) {
539 auto scalingFactors = lhsOverlapIntegrated / rhsOverlapIntegrated;
540 scaleWorkspace(rhs, scalingFactors, rhsWS);
541 } else {
542 auto scalingFactors = rhsOverlapIntegrated / lhsOverlapIntegrated;
543 scaleWorkspace(lhs, scalingFactors, lhsWS);
544 }
545 }
546 // Provide log information about the scale factors used in the calculations.
547 std::stringstream messageBuffer;
548 messageBuffer << "Scale Factor Y is: " << m_scaleFactor << " Scale Factor E is: " << m_errorScaleFactor;
549 g_log.notice(messageBuffer.str());
550
552 if (lhsWS->isHistogramData()) { // If the input workspaces are histograms ...
553 boost::tuple<int, int> startEnd = findStartEndIndexes(startOverlap, endOverlap, lhs);
554 int a1 = boost::tuples::get<0>(startEnd);
555 int a2 = boost::tuples::get<1>(startEnd);
556 // Mask out everything BUT the overlap region as a new workspace.
557 MatrixWorkspace_sptr overlap1 = maskAllBut(a1, a2, lhs);
558 // Mask out everything BUT the overlap region as a new workspace.
559 MatrixWorkspace_sptr overlap2 = maskAllBut(a1, a2, rhs);
560 // Mask out everything AFTER the overlap region as a new workspace.
561 maskInPlace(a1 + 1, static_cast<int>(lhs->blocksize()), lhs);
562 // Mask out everything BEFORE the overlap region as a new workspace.
563 maskInPlace(0, a2, rhs);
564 MatrixWorkspace_sptr overlapave;
565 if (hasNonzeroErrors(overlap1) && hasNonzeroErrors(overlap2)) {
566 overlapave = weightedMean(overlap1, overlap2);
567 } else {
568 g_log.information("Using un-weighted mean for Stitch1D overlap mean");
569 MatrixWorkspace_sptr sum = overlap1 + overlap2;
570 overlapave = sum * 0.5;
571 }
572 result = lhs + overlapave + rhs;
573 reinsertSpecialValues(result);
574 } else { // The input workspaces are point data ... join & sort
575 result = conjoinXAxis(lhs, rhs);
576 if (!result)
577 g_log.error("Could not retrieve joined workspace.");
578
579 // Sort the X Axis
581 childAlg->setProperty("InputWorkspace", result);
582 childAlg->execute();
583 result = childAlg->getProperty("OutputWorkspace");
584 }
585 setProperty("OutputWorkspace", result);
586 setProperty("OutScaleFactor", m_scaleFactor);
587}
588
593 auto histogramCount = static_cast<int>(ws->getNumberHistograms());
595 for (int i = 0; i < histogramCount; ++i) {
597 // Copy over the data
598 auto &sourceY = ws->mutableY(i);
599
600 for (auto j : m_nanYIndexes[i]) {
601 sourceY[j] = std::numeric_limits<double>::quiet_NaN();
602 }
603
604 for (auto j : m_infYIndexes[i]) {
605 sourceY[j] = std::numeric_limits<double>::infinity();
606 }
607
608 for (auto j : m_nanEIndexes[i]) {
609 sourceY[j] = std::numeric_limits<double>::quiet_NaN();
610 }
611
612 for (auto j : m_infEIndexes[i]) {
613 sourceY[j] = std::numeric_limits<double>::infinity();
614 }
615
617 }
619}
620
621} // namespace Mantid::Algorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
const std::vector< double > & rhs
double value
The value of the point.
Definition: FitMW.cpp:51
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
#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...
Definition: MultiThreaded.h:94
#define PARALLEL_CRITICAL(name)
#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.
Definition: Algorithm.cpp:1913
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
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.
Definition: Algorithm.cpp:842
Kernel::Logger & g_log
Definition: Algorithm.h:451
A property class for workspaces.
void setReferenceProperties(const API::MatrixWorkspace_sptr &)
Sets the properties of the reference (usually first) workspace, to later check the compatibility of t...
std::string checkCompatibility(const API::MatrixWorkspace_sptr &, bool checkNumberHistograms=false)
Compares the properties of the input workspace with the reference.
Stitch1D : Stitches two Matrix Workspaces together into a single output.
Definition: Stitch1D.h:20
SpecialTypeIndexes m_infEIndexes
Index per workspace spectra of Infs.
Definition: Stitch1D.h:86
Mantid::API::MatrixWorkspace_sptr weightedMean(Mantid::API::MatrixWorkspace_sptr &inOne, Mantid::API::MatrixWorkspace_sptr &inTwo)
Calculate the weighted mean.
Definition: Stitch1D.cpp:370
Mantid::API::MatrixWorkspace_sptr maskAllBut(int a1, int a2, Mantid::API::MatrixWorkspace_sptr &source)
Mask out everything but the data in the ranges.
Definition: Stitch1D.cpp:61
SpecialTypeIndexes m_nanYIndexes
Definition: Stitch1D.h:83
bool hasNonzeroErrors(Mantid::API::MatrixWorkspace_sptr &ws)
Does the x-axis have non-zero errors.
Definition: Stitch1D.cpp:421
boost::tuple< int, int > findStartEndIndexes(double startOverlap, double endOverlap, Mantid::API::MatrixWorkspace_sptr &workspace)
Find the start and end indexes.
Definition: Stitch1D.cpp:404
Mantid::API::MatrixWorkspace_sptr rebin(Mantid::API::MatrixWorkspace_sptr &input, const std::vector< double > &params)
Perform rebin.
Definition: Stitch1D.cpp:295
std::vector< double > getRebinParams(Mantid::API::MatrixWorkspace_const_sptr &lhsWS, Mantid::API::MatrixWorkspace_const_sptr &rhsWS, const bool scaleRHS) const
Get the rebin parameters.
Definition: Stitch1D.cpp:241
Mantid::API::MatrixWorkspace_sptr integration(Mantid::API::MatrixWorkspace_sptr &input, const double start, const double stop)
Perform integration.
Definition: Stitch1D.cpp:353
void maskInPlace(int a1, int a2, Mantid::API::MatrixWorkspace_sptr &source)
Mask out everything but the data in the ranges, but do it inplace.
Definition: Stitch1D.cpp:97
Mantid::API::MatrixWorkspace_sptr conjoinXAxis(Mantid::API::MatrixWorkspace_sptr &inOne, Mantid::API::MatrixWorkspace_sptr &inTwo)
Conjoin x axis.
Definition: Stitch1D.cpp:384
void scaleWorkspace(API::MatrixWorkspace_sptr &ws, API::MatrixWorkspace_sptr &scaleFactorWS, API::MatrixWorkspace_const_sptr &dxWS)
Scale workspace (left hand side or right hand side)
Definition: Stitch1D.cpp:450
double getStartOverlap(const double intesectionMin, const double intesectionMax) const
Get the start overlap.
Definition: Stitch1D.cpp:184
SpecialTypeIndexes m_nanEIndexes
Index per workspace spectra of Nans.
Definition: Stitch1D.h:82
void exec() override
Overwrites Algorithm method.
Definition: Stitch1D.cpp:474
SpecialTypeIndexes m_infYIndexes
Definition: Stitch1D.h:87
double m_scaleFactor
Scaling factors.
Definition: Stitch1D.h:76
void init() override
Overwrites Algorithm method.
Definition: Stitch1D.cpp:118
double getEndOverlap(const double intesectionMin, const double intesectionMax) const
Get the end overlap.
Definition: Stitch1D.cpp:213
static const double range_tolerance
Range tolerance.
Definition: Stitch1D.h:74
void reinsertSpecialValues(const Mantid::API::MatrixWorkspace_sptr &ws)
Add back in any special values.
Definition: Stitch1D.cpp:592
std::map< std::string, std::string > validateInputs() override
Cross-check properties with each other.
Definition: Stitch1D.cpp:152
Support for a property that holds an array of values.
Definition: ArrayProperty.h:28
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void notice(const std::string &msg)
Logs at notice level.
Definition: Logger.cpp:95
void error(const std::string &msg)
Logs at error level.
Definition: Logger.cpp:77
void warning(const std::string &msg)
Logs at warning level.
Definition: Logger.cpp:86
void information(const std::string &msg)
Logs at information level.
Definition: Logger.cpp:105
The concrete, templated class for properties.
Base class for properties.
Definition: Property.h:94
virtual bool isDefault() const =0
Overriden function that returns if property has the same value that it was initialised with,...
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
Definition: Workspace_fwd.h:20
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
Definition: Algorithm.h:61
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
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.
Definition: MultiThreaded.h:22
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
Definition: cow_ptr.h:172
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
Definition: EmptyValues.h:43
@ Input
An input workspace.
Definition: Property.h:53
@ Output
An output workspace.
Definition: Property.h:54