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 +
13#include "MantidHistogramData/HistogramDx.h"
14#include "MantidHistogramData/HistogramE.h"
15#include "MantidHistogramData/HistogramX.h"
16#include "MantidHistogramData/HistogramY.h"
23
24#include <algorithm>
25#include <boost/format.hpp>
26#include <boost/math/special_functions.hpp>
27#include <boost/tuple/tuple.hpp>
28#include <map>
29
30using namespace Mantid::API;
31using namespace Mantid::Kernel;
33using Mantid::HistogramData::HistogramE;
34using Mantid::HistogramData::HistogramY;
35
36namespace {
39using MinMaxTuple = boost::tuple<double, double>;
40MinMaxTuple calculateXIntersection(MatrixWorkspace_const_sptr &lhsWS, MatrixWorkspace_const_sptr &rhsWS) {
41 return MinMaxTuple(rhsWS->x(0).front(), lhsWS->x(0).back());
42}
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
96void Stitch1D::maskInPlace(int a1, int a2, MatrixWorkspace_sptr &source) {
97 const auto histogramCount = static_cast<int>(source->getNumberHistograms());
99 for (int i = 0; i < histogramCount; ++i) {
101 // Copy over the data
102 auto &sourceY = source->mutableY(i);
103 auto &sourceE = source->mutableE(i);
104 for (int binIndex = a1; binIndex < a2; ++binIndex) {
105 sourceY[binIndex] = 0;
106 sourceE[binIndex] = 0;
107 }
108
110 }
112}
113
114//----------------------------------------------------------------------------------------------
118
119 declareProperty(std::make_unique<WorkspaceProperty<MatrixWorkspace>>("LHSWorkspace", "", Direction::Input),
120 "LHS input workspace.");
121 declareProperty(std::make_unique<WorkspaceProperty<MatrixWorkspace>>("RHSWorkspace", "", Direction::Input),
122 "RHS input workspace, must be same type as LHSWorkspace "
123 "(histogram or point data).");
124 declareProperty(std::make_unique<WorkspaceProperty<MatrixWorkspace>>("OutputWorkspace", "", Direction::Output),
125 "Output stitched workspace.");
127 "Start overlap x-value in units of x-axis.");
129 "End overlap x-value in units of x-axis.");
130 declareProperty(std::make_unique<ArrayProperty<double>>("Params", std::make_shared<RebinParamsValidator>(true)),
131 "Rebinning Parameters. See Rebin for format. If only a "
132 "single value is provided, start and end are taken from "
133 "input workspaces.");
134 declareProperty(std::make_unique<PropertyWithValue<bool>>("ScaleRHSWorkspace", true, Direction::Input),
135 "Scaling either with respect to LHS workspace or RHS workspace");
136 declareProperty(std::make_unique<PropertyWithValue<bool>>("UseManualScaleFactor", false, Direction::Input),
137 "True to use a provided value for the scale factor.");
139 "OutputScalingWorkspace", "",
140 "Output WorkspaceSingleValue containing the scale factor and its error. No workspace creation if left empty.");
141 auto manualScaleFactorValidator = std::make_shared<BoundedValidator<double>>();
142 manualScaleFactorValidator->setLower(0);
143 manualScaleFactorValidator->setExclusive(true);
144 declareProperty(std::make_unique<PropertyWithValue<double>>("ManualScaleFactor", 1.0, manualScaleFactorValidator,
146 "Provided value for the scale factor.");
148 "The actual used value for the scaling factor.");
149}
150
154std::map<std::string, std::string> Stitch1D::validateInputs(void) {
155 std::map<std::string, std::string> issues;
156 MatrixWorkspace_sptr lhs = getProperty("LHSWorkspace");
157 MatrixWorkspace_sptr rhs = getProperty("RHSWorkspace");
158 if (!lhs) {
159 issues["LHSWorkspace"] = "The LHSWorkspace must be a MatrixWorkspace.";
160 }
161 if (!rhs) {
162 issues["RHSWorkspace"] = "The RHSWorkspace must be a MatrixWorkspace.";
163 }
164 if (!issues.empty()) {
165 return issues;
166 }
167 RunCombinationHelper combHelper;
168 combHelper.setReferenceProperties(lhs);
169 std::string compatible = combHelper.checkCompatibility(rhs, true);
170 if (!compatible.empty()) {
171 // histograms: no recalculation of Dx implemented -> do not treat Dx
172 if (!(compatible == "spectra must have either Dx values or not; ") ||
173 (rhs->isHistogramData())) // Issue only for point data
174 issues["RHSWorkspace"] = "Workspace " + rhs->getName() + " is not compatible: " + compatible + "\n";
175 }
176 return issues;
177}
178
186double Stitch1D::getStartOverlap(const double intesectionMin, const double intesectionMax) const {
187 Property const *startOverlapProp = this->getProperty("StartOverlap");
188 double startOverlapVal = this->getProperty("StartOverlap");
189 startOverlapVal -= this->range_tolerance;
190 const bool startOverlapBeyondRange = (startOverlapVal < intesectionMin) || (startOverlapVal > intesectionMax);
191 if (startOverlapProp->isDefault() || startOverlapBeyondRange) {
192 if (!startOverlapProp->isDefault() && startOverlapBeyondRange) {
193 char message[200];
194 std::sprintf(message,
195 "StartOverlap is outside range at %0.4f, Min is "
196 "%0.4f, Max is %0.4f . Forced to be: %0.4f",
197 startOverlapVal, intesectionMin, intesectionMax, intesectionMin);
198 g_log.warning(std::string(message));
199 }
200 startOverlapVal = intesectionMin;
201 std::stringstream buffer;
202 buffer << "StartOverlap calculated to be: " << startOverlapVal;
203 g_log.information(buffer.str());
204 }
205 return startOverlapVal;
206}
207
215double Stitch1D::getEndOverlap(const double intesectionMin, const double intesectionMax) const {
216 Property const *endOverlapProp = this->getProperty("EndOverlap");
217 double endOverlapVal = this->getProperty("EndOverlap");
218 endOverlapVal += this->range_tolerance;
219 const bool endOverlapBeyondRange = (endOverlapVal < intesectionMin) || (endOverlapVal > intesectionMax);
220 if (endOverlapProp->isDefault() || endOverlapBeyondRange) {
221 if (!endOverlapProp->isDefault() && endOverlapBeyondRange) {
222 char message[200];
223 std::sprintf(message,
224 "EndOverlap is outside range at %0.4f, Min is "
225 "%0.4f, Max is %0.4f . Forced to be: %0.4f",
226 endOverlapVal, intesectionMin, intesectionMax, intesectionMax);
227 g_log.warning(std::string(message));
228 }
229 endOverlapVal = intesectionMax;
230 std::stringstream buffer;
231 buffer << "EndOverlap calculated to be: " << endOverlapVal;
232 g_log.information(buffer.str());
233 }
234 return endOverlapVal;
235}
236
244 const bool scaleRHS) const {
245 std::vector<double> inputParams = this->getProperty("Params");
246 Property const *prop = this->getProperty("Params");
247 const bool areParamsDefault = prop->isDefault();
248
249 const auto &lhsX = lhsWS->x(0);
250 auto it = std::min_element(lhsX.begin(), lhsX.end());
251 const double minLHSX = *it;
252
253 const auto &rhsX = rhsWS->x(0);
254 it = std::max_element(rhsX.begin(), rhsX.end());
255 const double maxRHSX = *it;
256
257 std::vector<double> result;
258 if (areParamsDefault) {
259 std::vector<double> calculatedParams;
260
261 // Calculate the step size based on the existing step size of the LHS
262 // workspace. That way scale factors should be reasonably maintained.
263 double calculatedStep = 0;
264 if (scaleRHS) {
265 // Calculate the step from the workspace that will not be scaled. The LHS
266 // workspace.
267 calculatedStep = lhsX[1] - lhsX[0];
268 } else {
269 // Calculate the step from the workspace that will not be scaled. The RHS
270 // workspace.
271 calculatedStep = rhsX[1] - rhsX[0];
272 }
273
274 calculatedParams.emplace_back(minLHSX);
275 calculatedParams.emplace_back(calculatedStep);
276 calculatedParams.emplace_back(maxRHSX);
277 result = calculatedParams;
278 } else {
279 if (inputParams.size() == 1) {
280 std::vector<double> calculatedParams;
281 calculatedParams.emplace_back(minLHSX);
282 calculatedParams.emplace_back(inputParams.front()); // Use the step supplied.
283 calculatedParams.emplace_back(maxRHSX);
284 result = calculatedParams;
285 } else {
286 result = inputParams; // user has provided params. Use those.
287 }
288 }
289 return result;
290}
291
297MatrixWorkspace_sptr Stitch1D::rebin(MatrixWorkspace_sptr &input, const std::vector<double> &params) {
298 auto rebin = this->createChildAlgorithm("Rebin");
299 rebin->setProperty("InputWorkspace", input);
300 rebin->setProperty("Params", params);
301 std::stringstream ssParams;
302 ssParams << params[0] << "," << params[1] << "," << params[2];
303 g_log.information("Rebinning Params: " + ssParams.str());
304 rebin->execute();
305 MatrixWorkspace_sptr outWS = rebin->getProperty("OutputWorkspace");
306
307 const auto histogramCount = static_cast<int>(outWS->getNumberHistograms());
308
309 // Record special values and then mask them out as zeros. Special values are
310 // remembered and then replaced post processing.
312 for (int i = 0; i < histogramCount; ++i) {
314 std::vector<size_t> &nanEIndexes = m_nanEIndexes[i];
315 std::vector<size_t> &nanYIndexes = m_nanYIndexes[i];
316 std::vector<size_t> &infEIndexes = m_infEIndexes[i];
317 std::vector<size_t> &infYIndexes = m_infYIndexes[i];
318 // Copy over the data
319 auto &sourceY = outWS->mutableY(i);
320 auto &sourceE = outWS->mutableE(i);
321
322 for (size_t j = 0; j < sourceY.size(); ++j) {
323 const double value = sourceY[j];
324 if (std::isnan(value)) {
325 nanYIndexes.emplace_back(j);
326 sourceY[j] = 0;
327 } else if (std::isinf(value)) {
328 infYIndexes.emplace_back(j);
329 sourceY[j] = 0;
330 }
331
332 const double eValue = sourceE[j];
333 if (std::isnan(eValue)) {
334 nanEIndexes.emplace_back(j);
335 sourceE[j] = 0;
336 } else if (std::isinf(eValue)) {
337 infEIndexes.emplace_back(j);
338 sourceE[j] = 0;
339 }
340 }
341
343 }
345
346 return outWS;
347}
348
355MatrixWorkspace_sptr Stitch1D::integration(MatrixWorkspace_sptr const &input, const double start, const double stop) {
356 auto integration = this->createChildAlgorithm("Integration");
357 integration->initialize();
358 integration->setProperty("InputWorkspace", input);
359 integration->setProperty("RangeLower", start);
360 integration->setProperty("RangeUpper", stop);
361 g_log.information("Integration RangeLower: " + boost::lexical_cast<std::string>(start));
362 g_log.information("Integration RangeUpper: " + boost::lexical_cast<std::string>(stop));
363 integration->execute();
364 return integration->getProperty("OutputWorkspace");
365}
366
373 auto weightedMean = this->createChildAlgorithm("WeightedMean");
374 weightedMean->initialize();
375 weightedMean->setProperty("InputWorkspace1", inOne);
376 weightedMean->setProperty("InputWorkspace2", inTwo);
377 weightedMean->execute();
378 return weightedMean->getProperty("OutputWorkspace");
379}
380
387 const std::string in1 = "__Stitch1D_intermediate_workspace_1__";
388 const std::string in2 = "__Stitch1D_intermediate_workspace_2__";
389 Mantid::API::AnalysisDataService::Instance().addOrReplace(in1, inOne);
390 Mantid::API::AnalysisDataService::Instance().addOrReplace(in2, inTwo);
391 auto conjoinX = this->createChildAlgorithm("ConjoinXRuns");
392 conjoinX->initialize();
393 conjoinX->setProperty("InputWorkspaces", std::vector<std::string>{in1, in2});
394 conjoinX->execute();
395 Mantid::API::AnalysisDataService::Instance().remove(in1);
396 Mantid::API::AnalysisDataService::Instance().remove(in2);
397 API::Workspace_sptr ws = conjoinX->getProperty("OutputWorkspace");
398 return std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(ws);
399}
406boost::tuple<int, int> Stitch1D::findStartEndIndexes(double startOverlap, double endOverlap,
408 auto a1 = static_cast<int>(workspace->yIndexOfX(startOverlap));
409 auto a2 = static_cast<int>(workspace->yIndexOfX(endOverlap));
410 if (a1 == a2) {
411 throw std::runtime_error("The Params you have provided for binning yield a "
412 "workspace in which start and end overlap appear "
413 "in the same bin. Make binning finer via input "
414 "Params.");
415 }
416 return boost::tuple<int, int>(a1, a2);
417}
418
424 for (auto i = 0u; i < ws->getNumberHistograms(); ++i) {
425 const auto &e = ws->e(i);
426 // It's faster to sum and then check the result is non-zero than to check each element is non-zero individually
427 if (std::accumulate(e.begin(), e.end(), 0.0) != 0.0) {
428 return true;
429 }
430 }
431 return false;
432}
433
442 ws *= scaleFactorWS;
443 // We lost Dx values (Multiply) and need to get them back for point data
444 if (ws->size() == dxWS->size()) {
445 for (size_t i = 0; i < ws->getNumberHistograms(); ++i) {
446 if (dxWS->hasDx(i) && !ws->hasDx(i) && !ws->isHistogramData()) {
447 ws->setSharedDx(i, dxWS->sharedDx(i));
448 }
449 }
450 }
451 m_scaleFactor = scaleFactorWS->y(0).front();
452 m_errorScaleFactor = scaleFactorWS->e(0).front();
453 if (m_scaleFactor < 1e-2 || m_scaleFactor > 1e2 || std::isnan(m_scaleFactor)) {
454 std::stringstream messageBuffer;
455 messageBuffer << "Stitch1D calculated scale factor is: " << m_scaleFactor
456 << ". Check the overlap region is non-zero.";
457 g_log.warning(messageBuffer.str());
458 }
459}
460
461//----------------------------------------------------------------------------------------------
465 MatrixWorkspace_const_sptr lhsWS = this->getProperty("LHSWorkspace");
466 MatrixWorkspace_const_sptr rhsWS = this->getProperty("RHSWorkspace");
467 const MinMaxTuple intesectionXRegion = calculateXIntersection(lhsWS, rhsWS);
468
469 const size_t histogramCount = rhsWS->getNumberHistograms();
470 m_nanYIndexes.resize(histogramCount);
471 m_infYIndexes.resize(histogramCount);
472 m_nanEIndexes.resize(histogramCount);
473 m_infEIndexes.resize(histogramCount);
474
475 const double intersectionMin = intesectionXRegion.get<0>();
476 const double intersectionMax = intesectionXRegion.get<1>();
477 double startOverlap = getStartOverlap(intersectionMin, intersectionMax);
478 double endOverlap = getEndOverlap(intersectionMin, intersectionMax);
479 if (startOverlap > endOverlap) {
480 std::string message = boost::str(boost::format("Stitch1D cannot have a StartOverlap > EndOverlap. "
481 "StartOverlap: %0.9f, EndOverlap: %0.9f") %
482 startOverlap % endOverlap);
483 throw std::runtime_error(message);
484 }
485
486 const bool scaleRHS = this->getProperty("ScaleRHSWorkspace");
487
488 MatrixWorkspace_sptr lhs = lhsWS->clone();
489 MatrixWorkspace_sptr rhs = rhsWS->clone();
490 if (lhsWS->isHistogramData()) {
491 MantidVec params = getRebinParams(lhsWS, rhsWS, scaleRHS);
492 const double xMin = params.front();
493 const double xMax = params.back();
494
495 if (Kernel::withinAbsoluteDifference(xMin, startOverlap, 1E-6))
496 startOverlap = xMin;
497
498 if (Kernel::withinAbsoluteDifference(xMax, endOverlap, 1E-6))
499 endOverlap = xMax;
500
501 if (startOverlap < xMin) {
502 std::string message = boost::str(boost::format("Stitch1D StartOverlap is outside the available X range. "
503 "StartOverlap: %10.9f, X min: %10.9f") %
504 startOverlap % xMin);
505 throw std::runtime_error(message);
506 }
507 if (endOverlap > xMax) {
508 std::string message = boost::str(boost::format("Stitch1D EndOverlap is outside the available X range. "
509 "EndOverlap: %10.9f, X max: %10.9f") %
510 endOverlap % xMax);
511 throw std::runtime_error(message);
512 }
513 lhs = rebin(lhs, params);
514 rhs = rebin(rhs, params);
515 }
516
517 m_scaleFactor = this->getProperty("ManualScaleFactor");
519 const bool useManualScaleFactor = this->getProperty("UseManualScaleFactor");
520 if (useManualScaleFactor) {
521 if (scaleRHS)
523 else
524 lhs *= m_scaleFactor;
525 } else {
526 auto rhsOverlapIntegrated = integration(rhs, startOverlap, endOverlap);
527 auto lhsOverlapIntegrated = integration(lhs, startOverlap, endOverlap);
528 if (scaleRHS) {
529 auto scalingFactors = lhsOverlapIntegrated / rhsOverlapIntegrated;
530 scaleWorkspace(rhs, scalingFactors, rhsWS);
531 } else {
532 auto scalingFactors = rhsOverlapIntegrated / lhsOverlapIntegrated;
533 scaleWorkspace(lhs, scalingFactors, lhsWS);
534 }
535 }
536 // Provide log information about the scale factors used in the calculations.
537 std::stringstream messageBuffer;
538 messageBuffer << "Scale Factor Y is: " << m_scaleFactor << " Scale Factor E is: " << m_errorScaleFactor;
539 g_log.notice(messageBuffer.str());
540
542 if (lhsWS->isHistogramData()) { // If the input workspaces are histograms ...
543 boost::tuple<int, int> startEnd = findStartEndIndexes(startOverlap, endOverlap, lhs);
544 int a1 = boost::tuples::get<0>(startEnd);
545 int a2 = boost::tuples::get<1>(startEnd);
546 // Mask out everything BUT the overlap region as a new workspace.
547 MatrixWorkspace_sptr overlap1 = maskAllBut(a1, a2, lhs);
548 // Mask out everything BUT the overlap region as a new workspace.
549 MatrixWorkspace_sptr overlap2 = maskAllBut(a1, a2, rhs);
550 // Mask out everything AFTER the overlap region as a new workspace.
551 maskInPlace(a1 + 1, static_cast<int>(lhs->blocksize()), lhs);
552 // Mask out everything BEFORE the overlap region as a new workspace.
553 maskInPlace(0, a2, rhs);
554 MatrixWorkspace_sptr overlapave;
555 if (hasNonzeroErrors(overlap1) && hasNonzeroErrors(overlap2)) {
556 overlapave = weightedMean(overlap1, overlap2);
557 } else {
558 g_log.information("Using un-weighted mean for Stitch1D overlap mean");
559 MatrixWorkspace_sptr sum = overlap1 + overlap2;
560 overlapave = sum * 0.5;
561 }
562 result = lhs + overlapave + rhs;
563 reinsertSpecialValues(result);
564 } else { // The input workspaces are point data ... join & sort
565 result = conjoinXAxis(lhs, rhs);
566 if (!result)
567 g_log.error("Could not retrieve joined workspace.");
568
569 // Sort the X Axis
571 childAlg->setProperty("InputWorkspace", result);
572 childAlg->execute();
573 result = childAlg->getProperty("OutputWorkspace");
574 }
575 setProperty("OutputWorkspace", result);
576 setProperty("OutScaleFactor", m_scaleFactor);
577
578 // if required, create the output single value workspace containing the scaling factor and its error
579 const std::string scalingWsName = this->getPropertyValue("OutputScalingWorkspace");
580 if (!scalingWsName.empty()) {
581 auto createSingleAlg = createChildAlgorithm("CreateSingleValuedWorkspace");
582 createSingleAlg->setProperty("DataValue", m_scaleFactor);
583 createSingleAlg->setProperty("ErrorValue", m_errorScaleFactor);
584 createSingleAlg->executeAsChildAlg();
585 MatrixWorkspace_sptr singleWS = createSingleAlg->getProperty("OutputWorkspace");
586 AnalysisDataService::Instance().addOrReplace(scalingWsName, singleWS);
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:538
const std::vector< double > & rhs
double value
The value of the point.
Definition FitMW.cpp:51
IPeaksWorkspace_sptr workspace
#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.
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.
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.
Kernel::Logger & g_log
Definition Algorithm.h:422
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 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:423
boost::tuple< int, int > findStartEndIndexes(double startOverlap, double endOverlap, Mantid::API::MatrixWorkspace_sptr &workspace)
Find the start and end indexes.
Definition Stitch1D.cpp:406
Mantid::API::MatrixWorkspace_sptr rebin(Mantid::API::MatrixWorkspace_sptr &input, const std::vector< double > &params)
Perform rebin.
Definition Stitch1D.cpp:297
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:243
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:96
Mantid::API::MatrixWorkspace_sptr integration(Mantid::API::MatrixWorkspace_sptr const &input, const double start, const double stop)
Perform integration.
Definition Stitch1D.cpp:355
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:440
double getStartOverlap(const double intesectionMin, const double intesectionMax) const
Get the start overlap.
Definition Stitch1D.cpp:186
SpecialTypeIndexes m_nanEIndexes
Index per workspace spectra of Nans.
Definition Stitch1D.h:82
void exec() override
Overwrites Algorithm method.
Definition Stitch1D.cpp:464
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:117
double getEndOverlap(const double intesectionMin, const double intesectionMax) const
Get the end overlap.
Definition Stitch1D.cpp:215
static const double range_tolerance
Range tolerance.
Definition Stitch1D.h:74
Mantid::API::MatrixWorkspace_sptr weightedMean(Mantid::API::MatrixWorkspace_sptr const &inOne, Mantid::API::MatrixWorkspace_sptr const &inTwo)
Calculate the weighted mean.
Definition Stitch1D.cpp:372
void reinsertSpecialValues(const Mantid::API::MatrixWorkspace_sptr &ws)
Add back in any special values.
Definition Stitch1D.cpp:592
Mantid::API::MatrixWorkspace_sptr conjoinXAxis(Mantid::API::MatrixWorkspace_sptr const &inOne, Mantid::API::MatrixWorkspace_sptr const &inTwo)
Conjoin x axis.
Definition Stitch1D.cpp:386
std::map< std::string, std::string > validateInputs() override
Cross-check properties with each other.
Definition Stitch1D.cpp:154
Concrete workspace implementation.
Support for a property that holds an array of values.
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:126
void error(const std::string &msg)
Logs at error level.
Definition Logger.cpp:108
void warning(const std::string &msg)
Logs at warning level.
Definition Logger.cpp:117
void information(const std::string &msg)
Logs at information level.
Definition Logger.cpp:136
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,...
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< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
Definition Algorithm.h:52
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
MANTID_KERNEL_DLL bool withinAbsoluteDifference(T const x, T const y, S const tolerance)
Test whether x, y are within absolute tolerance tol.
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.
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:42
@ Input
An input workspace.
Definition Property.h:53
@ Output
An output workspace.
Definition Property.h:54