23#include "MantidIndexing/GlobalSpectrumIndex.h"
24#include "MantidIndexing/IndexInfo.h"
33#include "MantidTypes/SpectrumDefinition.h"
35#include <boost/algorithm/string/join.hpp>
36#include <boost/algorithm/string/regex.hpp>
47using Mantid::Types::Core::DateAndTime;
51auto accumulate_if_finite = [](
const double accumulator,
const double newValue) {
52 if (std::isfinite(newValue)) {
53 return accumulator + newValue;
62using namespace Geometry;
67Kernel::Logger
g_log(
"MatrixWorkspace");
68constexpr const double EPSILON{1.0e-9};
78std::string appendUnitDenominatorUsingPer(std::string yLabel,
const MatrixWorkspace &
workspace,
bool useLatex) {
80 std::string xLabel =
workspace.getAxis(0)->unit()->label().latex();
82 yLabel +=
" per $" +
workspace.getAxis(0)->unit()->label().latex() +
"$";
84 std::string xLabel =
workspace.getAxis(0)->unit()->label().ascii();
86 yLabel +=
" per " +
workspace.getAxis(0)->unit()->label().ascii();
97std::string replacePerWithLatex(std::string yLabel) {
98 std::vector<std::string> splitVec;
99 boost::split_regex(splitVec, yLabel, boost::regex(
" per "));
100 if (splitVec.size() > 1) {
101 yLabel = splitVec[0];
102 splitVec.erase(splitVec.begin());
103 std::string unitString = boost::algorithm::join(splitVec,
" ");
106 yLabel +=
"(" + unitString +
")$^{-1}$";
118template <
typename WorkspaceIndices>
119std::pair<double, double> findXMinMax(
const MatrixWorkspace &
workspace,
const WorkspaceIndices &workspaceIndices,
120 const bool includeNonFiniteSpectra) {
121 double xmin = std::numeric_limits<double>::max();
122 double xmax = -1.0 * xmin;
123 const auto isFinite = [](
const double value) {
return std::isfinite(
value); };
125 for (
const auto workspaceIndex : workspaceIndices) {
126 const auto &xData =
workspace.x(workspaceIndex);
127 auto xfront = xData.front();
128 auto xback = xData.back();
129 if (!isFinite(xfront) || !isFinite(xback)) {
130 if (!includeNonFiniteSpectra)
132 const auto firstFinite = std::find_if(xData.cbegin(), xData.cend(), isFinite);
133 if (firstFinite == xData.cend())
135 xfront = *firstFinite;
136 xback = *std::find_if(xData.crbegin(), xData.crend(), isFinite);
138 xmin = std::min(xmin, xfront);
139 xmax = std::max(xmax, xback);
155 m_isInitialized(other.m_isInitialized), m_YUnit(other.m_YUnit), m_YUnitLabel(other.m_YUnitLabel),
156 m_masks(other.m_masks), m_indexInfoNeedsUpdate(false), m_marker_size(6.) {
157 m_axes.resize(other.m_axes.size());
158 for (
size_t i = 0; i <
m_axes.size(); ++i)
159 m_axes[i] = std::unique_ptr<Axis>(other.m_axes[i]->clone(
this));
183 std::vector<Indexing::SpectrumNumber> spectrumNumbers;
186 m_indexInfo->setSpectrumNumbers(std::move(spectrumNumbers));
198 throw std::invalid_argument(
"MatrixWorkspace::setIndexInfo: IndexInfo size "
199 "does not match number of histograms in "
230 throw std::invalid_argument(
"MatrixWorkspace::setIndexInfo: IndexInfo size "
231 "does not match number of histograms in "
240 std::ostringstream os;
248 }
catch (std::length_error &) {
255 os <<
"Data points\n";
260 if (ax && ax->
unit())
261 os << ax->
unit()->caption() <<
" / " << ax->
unit()->label().ascii();
270 os <<
"Distribution: " << (
isDistribution() ?
"True" :
"False") <<
"\n";
288 if (NVectors == 0 || XLength == 0 || YLength == 0) {
289 throw std::out_of_range(
"All arguments to init must be positive and non-zero");
297 m_indexInfo = std::make_unique<Indexing::IndexInfo>(NVectors);
301 this->
init(NVectors, XLength, YLength);
302 }
catch (std::runtime_error &) {
312 Indexing::IndexInfo indices(NVectors);
314 indices.setSpectrumDefinitions(std::vector<SpectrumDefinition>(NVectors));
321 throw std::out_of_range(
"All arguments to init must be positive and non-zero");
356 if (
run().hasProperty(
"run_title")) {
371 if (v.isValid(t) ==
"") {
374 std::string validValues = std::accumulate(
376 [](
const std::string &valuesString,
const std::string &plotType) { return valuesString +
", " + plotType; });
377 throw std::invalid_argument(
"Invalid plot type '" + t +
"'. Must be one of: " + validValues);
386 std::string plotType;
387 if (
run().hasProperty(
"plot_type")) {
403 if (v.isValid(markerType) ==
"") {
406 std::string validValues =
408 [](
const std::string &valuesString,
const std::string &markerStyle) {
409 return valuesString +
", " + markerStyle;
411 throw std::invalid_argument(
"Invalid marker type '" + markerType +
"'. Must be one of: " + validValues);
422 return Kernel::ConfigService::Instance().getString(
"plots.markerworkspace.MarkerStyle");
451 }
catch (std::out_of_range &exception) {
453 spec.clearDetectorIDs();
455 g_log.
debug() <<
"Spectrum number " << spec.getSpectrumNo() <<
" not in map.\n";
474 const std::vector<detid_t> pixelIDs = this->
getInstrument()->getDetectorIDs(!includeMonitors);
479 std::vector<detid_t>::const_iterator
iend = pixelIDs.end();
480 for (std::vector<detid_t>::const_iterator it = pixelIDs.begin(); it !=
iend; ++it) {
485 if (
index < NUM_HIST) {
487 spec.setSpectrumNo(specNo);
488 spec.setDetectorID(detId);
494 }
catch (std::runtime_error &) {
506 throw std::runtime_error(
"MatrixWorkspace::getSpectrumToWorkspaceIndexMap: "
507 "axis[1] is not a SpectraAxis, so I cannot "
510 return ax->getSpectraIndexMap();
511 }
catch (std::runtime_error &) {
512 g_log.
error() <<
"MatrixWorkspace::getSpectrumToWorkspaceIndexMap: no elements!";
528 throw std::runtime_error(
"MatrixWorkspace::getSpectrumToWorkspaceIndexMap: "
529 "axis[1] is not a SpectraAxis, so I cannot "
533 specnum_t min = std::numeric_limits<specnum_t>::max();
535 specnum_t max = -std::numeric_limits<specnum_t>::max();
538 size_t length = ax->length();
539 for (
size_t i = 0; i < length; i++) {
551 std::vector<size_t> out(max - min + 1, 0);
554 for (
size_t i = 0; i < length; i++) {
556 out[spec + offset] = i;
569 for (
size_t workspaceIndex = 0; workspaceIndex < this->
getNumberHistograms(); workspaceIndex++) {
571 if (detList.size() > 1) {
593 bool ignoreIfNoValidDets)
const {
598 for (
size_t workspaceIndex = 0; workspaceIndex < this->
getNumberHistograms(); ++workspaceIndex) {
600 if (ignoreIfNoValidDets && !specInfo.hasDetectors(workspaceIndex)) {
605 if (throwIfMultipleDets) {
606 if (detList.size() > 1) {
607 throw std::runtime_error(
"MatrixWorkspace::getDetectorIDToWorkspaceIndexMap(): more than 1 "
608 "detector for one histogram! I cannot generate a map of detector "
609 "ID to workspace index.");
613 if (detList.size() == 1)
614 map[*detList.begin()] = workspaceIndex;
617 for (
auto det : detList)
618 map[det] = workspaceIndex;
640 bool throwIfMultipleDets)
const {
642 std::vector<size_t> out;
647 const int outSize = maxId - minId + 1;
649 out.resize(outSize, std::numeric_limits<size_t>::max());
651 for (
size_t workspaceIndex = 0; workspaceIndex <
getNumberHistograms(); ++workspaceIndex) {
655 if (throwIfMultipleDets && (detList.size() > 1))
656 throw std::runtime_error(
"MatrixWorkspace::getDetectorIDToWorkspaceIndexVector(): more than 1 "
657 "detector for one histogram! I cannot generate a map of detector ID "
658 "to workspace index.");
662 for (
auto det : detList) {
663 int index = det + offset;
664 if (index < 0 || index >= outSize) {
665 g_log.
debug() <<
"MatrixWorkspace::getDetectorIDToWorkspaceIndexVector("
666 "): detector ID found ("
667 << det <<
" at workspace index " << workspaceIndex <<
") is invalid.\n";
670 out[
index] = workspaceIndex;
685 std::vector<size_t> indexList;
688 auto iter = spectraList.cbegin();
689 while (iter != spectraList.cend()) {
692 indexList.emplace_back(i);
712 throw std::runtime_error(
"Could not find spectrum number in any spectrum.");
728 throw std::runtime_error(
"MatrixWorkspace: Using getIndicesFromDetectorIDs "
729 "in a parallel run is most likely incorrect. "
733 std::set<detid_t> detIdSet(detIdList.cbegin(), detIdList.cend());
736 std::map<detid_t, std::set<size_t>> detectorIDtoWSIndices;
738 for (
size_t i = 0; i < NUM_HIST; ++i) {
740 for (
const auto &detID : detIDs) {
742 if (detIdSet.count(detID) > 0) {
743 detectorIDtoWSIndices[detID].insert(i);
749 std::vector<size_t> indexList;
750 indexList.reserve(detIdList.size());
751 for (
const auto &detId : detIdList) {
752 const auto wsIndices = detectorIDtoWSIndices.find(detId);
753 if (wsIndices != detectorIDtoWSIndices.end()) {
754 std::copy(wsIndices->second.cbegin(), wsIndices->second.cend(), std::back_inserter(indexList));
769 std::vector<specnum_t> spectraList;
772 for (
auto detId : detIdList) {
773 bool foundDet =
false;
786 spectraList.emplace_back(foundSpecNum);
799 return findXMinMax(*
this, std::views::iota(
size_t{0}, this->
getNumberHistograms()),
false);
809 const bool includeNonFiniteSpectra)
const {
810 return findXMinMax(*
this, workspaceIndices, includeNonFiniteSpectra);
827 const bool entireRange)
const {
835 for (
int wksp_index = 0; wksp_index < static_cast<int>(this->
getNumberHistograms()); wksp_index++) {
837 const Mantid::HistogramData::HistogramX &xData = this->
x(wksp_index);
838 const auto &yData = this->
y(wksp_index);
840 if ((xData.size() <= 1 + histogramOffset) && (!yData.empty())) {
841 out[wksp_index] = yData[0];
844 Mantid::MantidVec::const_iterator lowit, highit;
845 lowit = xData.begin();
846 highit = xData.end() - histogramOffset;
852 lowit = std::lower_bound(xData.begin(), xData.end(), minX);
854 if (*(highit - 1 + histogramOffset) > maxX)
855 highit = std::upper_bound(lowit, xData.end(), maxX);
859 Mantid::MantidVec::difference_type distmin = std::distance(xData.begin(), lowit);
860 Mantid::MantidVec::difference_type distmax = std::distance(xData.begin(), highit);
862 if (distmin <= distmax) {
864 sum = std::accumulate(yData.begin() + distmin, yData.begin() + distmax, 0.0, accumulate_if_finite);
867 out[wksp_index] = sum;
873 const double minX,
const double maxX,
874 const bool entireRange)
const {
875 std::vector<double> integratedSpectra;
877 std::vector<double> detectorCounts;
878 std::transform(workspaceIndices.cbegin(), workspaceIndices.cend(), std::back_inserter(detectorCounts),
879 [&](
const auto &wsIndex) { return integratedSpectra[wsIndex]; });
880 return detectorCounts;
895 if (!localInstrument) {
900 const size_t ndets = dets.size();
903 return localInstrument->getDetector(*dets.begin());
904 }
else if (ndets == 0) {
906 "detectors for this workspace "
911 auto dets_ptr = localInstrument->getDetectors(dets);
912 return std::make_shared<Geometry::DetectorGroup>(dets_ptr);
927 if (source ==
nullptr ||
sample ==
nullptr) {
929 "Instrument not sufficiently defined: failed to get source and/or "
934 const Kernel::V3D beamLine = samplePos - source->getPos();
940 const V3D &thetaSignAxis = instrument->getReferenceFrame()->vecThetaSign();
955 if (source ==
nullptr ||
sample ==
nullptr) {
957 "Instrument not sufficiently defined: failed to get source and/or "
962 const Kernel::V3D beamLine = samplePos - source->getPos();
980 if (axisIndex >=
m_axes.size()) {
984 return m_axes[axisIndex].get();
998 if (axisIndex >=
m_axes.size()) {
1002 m_axes[axisIndex] = std::move(newAxis);
1018 const auto &x0 = this->
x(0);
1019 if (x0.size() < 2) {
1024 if (x0[1] == x0[0]) {
1028 double diff = x0[1] / x0[0];
1029 if (!std::isfinite(diff)) {
1033 for (
size_t i = 1; i < x0.size() - 2; ++i) {
1034 if (std::isfinite(x0[i + 1]) && std::isfinite(x0[i])) {
1035 if (std::abs(x0[i + 1] / x0[i] - diff) >
EPSILON) {
1066 retVal = appendUnitDenominatorUsingPer(retVal, *
this, useLatex);
1070 retVal = replacePerWithLatex(retVal);
1083 return getSpectrum(0).
yMode() == HistogramData::Histogram::YMode::Frequencies;
1091 HistogramData::Histogram::YMode ymode =
1092 newValue ? HistogramData::Histogram::YMode::Frequencies : HistogramData::Histogram::YMode::Counts;
1117 throw std::logic_error(
"In MatrixWorkspace::isHistogramData(): "
1118 "Histogram::Xmode is not BinEdges");
1122 throw std::logic_error(
"In MatrixWorkspace::isHistogramData(): "
1123 "Histogram::Xmode is not Points");
1147 const HistogramData::HistogramX *first = &
x(0);
1148 for (
size_t i = 1; i < numHist; ++i) {
1149 if (&
x(i) != first) {
1162 const size_t numBins =
x(0).size();
1163 for (
size_t i = 1; i < numHist; ++i) {
1164 if (
x(i).
size() != numBins) {
1170 const auto &x0 =
x(0);
1173 for (
int i = 1; i < static_cast<int>(numHist); ++i) {
1175 const auto specIndex =
static_cast<std::size_t
>(i);
1176 const auto &xi =
x(specIndex);
1177 for (
size_t j = 0; j < numBins; ++j) {
1178 const double a = x0[j];
1179 const double b = xi[j];
1181 if (std::isfinite(a) && std::isfinite(b)) {
1182 if (std::abs(a - b) >
EPSILON) {
1187 }
else if ((std::isnan(a) != std::isnan(b)) || (std::isinf(a) != std::isinf(b))) {
1205 const HistogramData::HistogramX bins =
x(0);
1207 for (
size_t i = 0; i < bins.size(); ++i) {
1208 if (std::trunc(bins[i]) != bins[i])
1232 "MatrixWorkspace::maskBin,workspaceIndex");
1234 if (binIndex >=
y(workspaceIndex).
size())
1238 flagMasked(workspaceIndex, binIndex, weight);
1248 double &yData = this->
mutableY(workspaceIndex)[binIndex];
1249 (std::isnan(yData) || std::isinf(yData)) ? yData = 0. : yData *= (1 - weight);
1250 double &eData = this->
mutableE(workspaceIndex)[binIndex];
1251 (std::isnan(eData) || std::isinf(eData)) ? eData = 0. : eData *= (1 - weight);
1269 binList[binIndex] = weight;
1297 auto it =
m_masks.find(workspaceIndex);
1308 auto it =
m_masks.find(workspaceIndex);
1315 auto maskedBinsList = it->second;
1316 std::vector<size_t> maskedIds;
1317 maskedIds.reserve(maskedBinsList.size());
1319 std::transform(maskedBinsList.begin(), maskedBinsList.end(), std::back_inserter(maskedIds),
1320 [](
const auto &mb) { return mb.first; });
1350 if (monitorWS.get() ==
this) {
1351 throw std::runtime_error(
"To avoid memory leak, monitor workspace"
1352 " can not be the same workspace as the host workspace");
1369 for (
size_t i = 0; i < numHist; ++i) {
1372 return total + runMemSize;
1375 return 3 *
size() *
sizeof(double) + runMemSize;
1384 auto lastX = this->
sharedX(0);
1388 if (!(
X == lastX) || wi == 0)
1389 total += (*X).size() *
sizeof(double);
1423 [[maybe_unused]]
const double tolerance)
const {
1425 throw std::out_of_range(
"MatrixWorkspace::yIndexOfX - Index out of range.");
1427 const auto &xValues = this->
x(index);
1428 const bool ascendingOrder = xValues.front() < xValues.back();
1429 const auto minX = ascendingOrder ? xValues.front() : xValues.back();
1430 const auto maxX = ascendingOrder ? xValues.back() : xValues.front();
1433 if (xValue < minX || xValue > maxX)
1434 throw std::out_of_range(
"MatrixWorkspace::yIndexOfX - X value is out of "
1435 "the range of the min and max bin edges.");
1439 if (xValue < minX - tolerance || xValue > maxX +
tolerance)
1440 throw std::out_of_range(
"MatrixWorkspace::yIndexOfX - X value is out of "
1441 "range for this point data.");
1455 const bool ascendingOrder)
const {
1457 if (ascendingOrder) {
1458 auto lowerIter = std::lower_bound(xValues.cbegin(), xValues.cend(), xValue);
1461 if (lowerIter == xValues.cbegin())
1464 hops = std::distance(xValues.cbegin(), lowerIter);
1466 auto lowerIter = std::lower_bound(xValues.crbegin(), xValues.crend(), xValue);
1468 if (lowerIter == xValues.crbegin())
1471 hops = xValues.size() - std::distance(xValues.crbegin(), lowerIter);
1488 auto const iter = std::find_if(xValues.cbegin(), xValues.cend(), [&xValue, &
tolerance](
double const &
value) {
1489 return std::abs(xValue - value) <= tolerance;
1491 if (iter != xValues.cend())
1492 return std::distance(xValues.cbegin(), iter);
1494 throw std::invalid_argument(
"MatrixWorkspace::yIndexOfX - the X value provided could not be found "
1495 "in the workspace containing point data.");
1507 if (0 == axisIndex) {
1509 }
else if (1 == axisIndex) {
1512 throw std::invalid_argument(
"Cannot have an index for a MatrixWorkspace "
1513 "axis that is not == 0 or == 1");
1529 if (unit && unit->unitID() !=
"Empty")
1530 return unit->caption();
1566 throw std::runtime_error(
"Not implemented");
1583 std::string
toXMLString()
const override {
throw std::runtime_error(
"Not implemented"); }
1604 m_ws->getAxis(0)->unit()->label())) {}
1609 const auto &unit = axis->
unit();
1610 if (unit && unit->unitID() !=
"Empty")
1611 return unit->caption();
1613 return axis->title();
1642 throw std::runtime_error(
"Not implemented");
1649 std::string
toXMLString()
const override {
throw std::runtime_error(
"Not implemented"); }
1666 return std::make_shared<MWXDimension>(
this,
xDimensionId);
1667 }
else if (
index == 1) {
1669 return std::make_shared<MWDimension>(yAxis,
yDimensionId);
1671 throw std::invalid_argument(
"MatrixWorkspace only has 2 dimensions.");
1675 int nAxes = this->
axes();
1676 std::shared_ptr<IMDDimension> dim;
1677 for (
int i = 0; i < nAxes; i++) {
1679 if (knownId ==
id) {
1680 dim = std::make_shared<MWDimension>(this->
getAxis(i),
id);
1685 if (
nullptr == dim) {
1686 std::string message =
"Cannot find id : " +
id;
1687 throw std::overflow_error(message);
1699std::vector<std::unique_ptr<IMDIterator>>
1702 size_t numCores = suggestedNumCores;
1706 if (numCores > numElements)
1707 numCores = numElements;
1712 std::vector<std::unique_ptr<IMDIterator>> out;
1713 for (
size_t i = 0; i < numCores; i++) {
1714 size_t begin = (i * numElements) / numCores;
1715 size_t end = ((i + 1) * numElements) / numCores;
1716 if (end > numElements)
1718 out.emplace_back(std::make_unique<MatrixWorkspaceMDIterator>(
this, function, begin, end));
1749 if (this->
axes() != 2)
1750 throw std::invalid_argument(
"MatrixWorkspace::getSignalAtCoord() - "
1751 "Workspace can only have 2 axes, found " +
1759 }
catch (std::out_of_range &) {
1760 return std::numeric_limits<double>::quiet_NaN();
1764 const auto &yVals = this->
y(wi);
1765 double yBinSize(1.0);
1768 double currentVertical = ax1->operator()(wi, uVI);
1769 if (wi + 1 == nhist && nhist > 1)
1771 yBinSize = currentVertical - ax1->operator()(wi - 1, uVI);
1773 yBinSize = ax1->operator()(wi + 1, uVI) - currentVertical;
1778 const auto &xVals =
x(wi);
1786 }
catch (std::out_of_range &) {
1787 return std::numeric_limits<double>::quiet_NaN();
1790 double yVal = yVals[i];
1792 switch (normalization) {
1797 auto volume = yBinSize * (xVals[i + 1] - xVals[i]);
1798 if (volume == 0.0) {
1799 return std::numeric_limits<double>::quiet_NaN();
1801 return yVal / volume;
1810 return std::numeric_limits<double>::quiet_NaN();
1831 throw std::runtime_error(
"MatrixWorkspace::setMDMasking has no implementation");
1838 throw std::runtime_error(
"MatrixWorkspace::clearMDMasking has no implementation");
1862template <
class Accessor>
1864 size_t indexEnd)
const {
1867 throw std::runtime_error(
"Cannot create image with width 0");
1878 throw std::runtime_error(
"Cannot create image for an empty data set.");
1881 if (start >= nHist) {
1882 throw std::runtime_error(
"Cannot create image: start index is out of range");
1885 if (stop >= nHist) {
1886 throw std::runtime_error(
"Cannot create image: stop index is out of range");
1890 size_t dataSize = stop - start + 1;
1891 size_t height = dataSize / width;
1894 if (
height * width != dataSize) {
1895 throw std::runtime_error(
"Cannot create image: the data set cannot form a rectangle.");
1902 if (indexEnd == 0) {
1904 if (!isHisto && indexEnd > 0)
1909 if (indexEnd < indexStart) {
1910 throw std::runtime_error(
"Cannot create image for an empty data set.");
1913 if (indexStart >= nBins || indexEnd > nBins || (!isHisto && indexEnd == nBins)) {
1914 throw std::runtime_error(
"Cannot create image: integration interval is out of range.");
1918 auto image = std::make_shared<MantidImage>(
height);
1923 if (isHisto && indexEnd == indexStart + 1) {
1925 for (
int i = 0; i < static_cast<int>(
height); ++i) {
1926 auto &row = (*image)[i];
1928 size_t spec = start +
static_cast<size_t>(i) * width;
1929 for (
size_t j = 0; j < width; ++j, ++spec) {
1930 row[j] = (this->*read)(spec)[indexStart];
1936 for (
int i = 0; i < static_cast<int>(
height); ++i) {
1937 auto &row = (*image)[i];
1939 size_t spec = start +
static_cast<size_t>(i) * width;
1940 for (
size_t j = 0; j < width; ++j, ++spec) {
1941 auto &V = (this->*read)(spec);
1942 row[j] = std::accumulate(V.begin() + indexStart, V.begin() + indexEnd, 0.0);
1951 std::pair<int64_t, int64_t> out(-1, -1);
1953 if (std::isnan(
value)) {
1954 for (int64_t i = idx.first; i < numHists; ++i) {
1955 const auto &
Y = this->
y(i);
1956 if (
auto it = std::find_if(std::next(
Y.begin(), idx.second),
Y.end(), [](
double v) { return std::isnan(v); });
1958 out = {i, std::distance(
Y.begin(), it)};
1963 for (int64_t i = idx.first; i < numHists; ++i) {
1964 const auto &
Y = this->
y(i);
1965 if (
auto it = std::find(std::next(
Y.begin(), idx.second),
Y.end(),
value); it !=
Y.end()) {
1966 out = {i, std::distance(
Y.begin(), it)};
1982 startX =
x(i).front();
1983 auto pStart =
getXIndex(i, startX,
true);
1984 if (pStart.second != 0.0) {
1985 throw std::runtime_error(
"Start X value is required to be on bin boundary.");
1989 auto pEnd =
getXIndex(i, endX,
false, pStart.first);
1990 if (pEnd.second != 0.0) {
1991 throw std::runtime_error(
"End X value is required to be on bin boundary.");
1993 return std::make_pair(pStart.first, pEnd.first);
2035 auto &
X = this->
x(i);
2040 return std::make_pair(nx, 0.0);
2041 if (start > 0 && start == nx - 1) {
2044 return std::make_pair(start, 0.0);
2045 return std::make_pair(nx, 0.0);
2052 return x <=
X[start] ? std::make_pair(start, 0.0) : std::make_pair(nx, 0.0);
2053 return x >=
X[start] ? std::make_pair(start, 0.0) : std::make_pair(nx, 0.0);
2057 if (
x <=
X[start]) {
2058 return isLeft ? std::make_pair(start, 0.0) : std::make_pair(nx, 0.0);
2061 if (
x >=
X.back()) {
2062 return !isLeft ? std::make_pair(nx - 1, 0.0) : std::make_pair(nx, 0.0);
2067 for (
auto ix =
X.begin() + start + 1; ix != end; ++ix) {
2069 auto index =
static_cast<size_t>(std::distance(
X.begin(), ix));
2072 return std::make_pair(
index, std::abs((
X[
index] -
x) / (*ix - *(ix - 1))));
2076 return std::make_pair(nx, 0.0);
2088template <
class Accessor>
2090 [[maybe_unused]]
bool parallelExecution) {
2094 if (image[0].empty())
2098 throw std::runtime_error(
"Cannot set image: a single bin workspace is expected.");
2101 size_t height = image.size();
2102 size_t width = image.front().size();
2103 size_t dataSize = width *
height;
2106 throw std::runtime_error(
"Cannot set image: image is bigger than workspace.");
2110 for (
int i = 0; i < static_cast<int>(
height); ++i) {
2111 auto &row = image[i];
2112 if (row.size() != width) {
2113 throw std::runtime_error(
"Canot set image: image is corrupted.");
2115 size_t spec = start +
static_cast<size_t>(i) * width;
2116 auto rowEnd = row.end();
2117 for (
auto pixel = row.begin(); pixel != rowEnd; ++pixel, ++spec) {
2118 (this->*mutableData)(spec)[0] = *pixel;
2157 size_t numberOfDetectors{detInfo.size()};
2158 if (numberOfDetectors == 0) {
2163 size_t numberOfSpectra = numberOfDetectors * detInfo.scanCount();
2165 throw std::invalid_argument(
"MatrixWorkspace: IndexInfo does not contain spectrum definitions so "
2166 "building a 1:1 mapping from spectra to detectors was attempted, but "
2167 "the number of spectra in the workspace is not equal to the number of "
2168 "detectors in the instrument.");
2169 std::vector<SpectrumDefinition> specDefs(
m_indexInfo->size());
2170 if (!detInfo.isScanning() && (numberOfSpectra ==
m_indexInfo->size())) {
2171 for (
size_t i = 0; i < numberOfSpectra; ++i)
2174 size_t specIndex = 0;
2175 size_t globalSpecIndex = 0;
2176 for (
size_t detIndex = 0; detIndex < detInfo.size(); ++detIndex) {
2177 for (
size_t time = 0; time < detInfo.scanCount(); ++time) {
2178 if (
m_indexInfo->isOnThisPartition(Indexing::GlobalSpectrumIndex(globalSpecIndex++)))
2179 specDefs[specIndex++].add(detIndex, time);
2183 m_indexInfo->setSpectrumDefinitions(std::move(specDefs));
2188 const auto detInfo_scanCount = detInfo.scanCount();
2190 const auto allDetIDs_size = detInfo.size();
2191 const auto &specDefs =
m_indexInfo->spectrumDefinitions();
2192 const auto indexInfoSize =
static_cast<int64_t
>(
m_indexInfo->size());
2193 enum class ErrorCode {
None, InvalidDetIndex, InvalidTimeIndex };
2194 std::atomic<ErrorCode> errorValue(ErrorCode::None);
2195#pragma omp parallel for
2196 for (int64_t i = 0; i < indexInfoSize; ++i) {
2199 spec.setMatrixWorkspace(
nullptr, i);
2201 std::set<detid_t> detIDs;
2202 for (
const auto &
index : (*specDefs)[i]) {
2203 const size_t detIndex =
index.first;
2204 if (detIndex >= allDetIDs_size) {
2205 errorValue = ErrorCode::InvalidDetIndex;
2206 }
else if (
index.second >= detInfo_scanCount) {
2207 errorValue = ErrorCode::InvalidTimeIndex;
2209 detIDs.insert(detInfo.detid(detIndex));
2212 spec.setDetectorIDs(std::move(detIDs));
2214 switch (errorValue) {
2215 case ErrorCode::InvalidDetIndex:
2216 throw std::invalid_argument(
"MatrixWorkspace: SpectrumDefinition contains an out-of-range "
2217 "detector index, i.e., the spectrum definition does not match "
2218 "the instrument in the workspace.");
2219 case ErrorCode::InvalidTimeIndex:
2220 throw std::invalid_argument(
"MatrixWorkspace: SpectrumDefinition contains an out-of-range "
2221 "time index for a detector, i.e., the spectrum definition does "
2222 "not match the instrument in the workspace.");
2223 case ErrorCode::None:;
2234IPropertyManager::getValue<Mantid::API::MatrixWorkspace_sptr>(
const std::string &
name)
const {
2239 std::string message =
2240 "Attempt to assign property " +
name +
" to incorrect type. Expected shared_ptr<MatrixWorkspace>.";
2241 throw std::runtime_error(message);
2247IPropertyManager::getValue<Mantid::API::MatrixWorkspace_const_sptr>(
const std::string &
name)
const {
2248 auto const *prop =
dynamic_cast<PropertyWithValue<Mantid::API::MatrixWorkspace_sptr> *
>(getPointerToProperty(
name));
2250 return prop->operator()();
2252 std::string message =
2253 "Attempt to assign property " +
name +
" to incorrect type. Expected const shared_ptr<MatrixWorkspace>.";
2254 throw std::runtime_error(message);
double value
The value of the point.
IPeaksWorkspace_sptr workspace
std::map< DeltaEMode::Type, std::string > index
const double EPSILON(1.0E-10)
#define PARALLEL_FOR_NO_WSP_CHECK()
#define PARALLEL_CRITICAL(name)
#define PARALLEL_FOR_IF(condition)
Empty definitions - to enable set your complier to enable openMP.
Class to represent the axis of a workspace.
virtual double getMin() const =0
returns min value defined on axis
virtual double getMax() const =0
returns max value defined on axis
const std::string & title() const
Returns the user-defined title for this axis.
virtual size_t indexOfValue(const double value) const =0
Find the index of the given double value.
virtual std::size_t length() const =0
Get the length of the axis.
virtual bool isNumeric() const
Returns true if the axis is numeric.
const Kernel::Unit_sptr & unit() const
The unit for this axis.
Stores numeric values that are assumed to be bin edge values.
This class is shared by a few Workspace types and holds information related to a particular experimen...
Run & mutableRun()
Writable version of the run object.
const SpectrumInfo & spectrumInfo() const
Return a reference to the SpectrumInfo object.
const Geometry::DetectorInfo & detectorInfo() const
Return a const reference to the DetectorInfo object.
const Run & run() const
Run details object access.
Geometry::Instrument_const_sptr getInstrument() const
Returns the parameterized instrument.
const Sample & sample() const
Sample accessors.
const std::string toString() const
Returns a string description of the object.
void setDetectorGrouping(const size_t index, const std::set< detid_t > &detIDs) const
Sets the detector grouping for the spectrum with the given index.
void setSpectrumDefinitions(Kernel::cow_ptr< std::vector< SpectrumDefinition > > spectrumDefinitions)
Sets the SpectrumDefinition for all spectra.
void setNumberOfDetectorGroups(const size_t count) const
Sets the number of detector groups.
Geometry::Instrument_const_sptr sptr_instrument
The base (unparametrized) instrument.
Basic MD Workspace Abstract Class.
virtual LinePlot getLinePlot(const Mantid::Kernel::VMD &start, const Mantid::Kernel::VMD &end, Mantid::API::MDNormalization normalize) const
Method to generate a line plot through a MD-workspace.
HistogramData::Histogram::YMode yMode() const
specnum_t getSpectrumNo() const
bool hasDetectorID(const detid_t detID) const
Return true if the given detector ID is in the list for this ISpectrum.
virtual size_t getMemorySize() const =0
virtual HistogramData::Histogram histogram() const
Returns the Histogram associated with this spectrum.
void setYMode(HistogramData::Histogram::YMode ymode)
const std::set< detid_t > & getDetectorIDs() const
Get a const reference to the detector IDs set.
Kernel::Property * getProperty(const std::string &name) const
Returns the named property as a pointer.
const Types::Core::DateAndTime getFirstPulseTime() const
Return the first pulse time from sample logs.
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
const Types::Core::DateAndTime getLastPulseTime() const
Return the last pulse time from sample logs.
coord_t getX(size_t ind) const override
Get coordinate for index;.
size_t getNBoundaries() const override
number of bin boundaries (axis points)
const Geometry::MDFrame_const_uptr m_frame
const std::string m_dimensionId
std::string getName() const override
the name of the dimennlsion as can be displayed along the axis
std::string toXMLString() const override
size_t getNBins() const override
number of bins dimension have (an integrated has one).
const Kernel::MDUnit & getMDUnits() const override
coord_t getMinimum() const override
const Kernel::UnitLabel getUnits() const override
const std::string & getDimensionId() const override
short name which identify the dimension among other dimension.
coord_t getBinWidth() const override
Return the bin width taking into account if the stored values are actually bin centres or not.
void setRange(size_t, coord_t, coord_t) override
Change the extents and number of bins.
coord_t getMaximum() const override
const Geometry::MDFrame & getMDFrame() const override
bool getIsIntegrated() const override
if the dimension is integrated (e.g. have single bin)
MWDimension(const Axis *axis, std::string dimensionId)
An implementation of IMDDimension for MatrixWorkspace that points to the X vector of the first spectr...
const Geometry::MDFrame & getMDFrame() const override
coord_t getX(size_t ind) const override
Get coordinate for index;.
const Geometry::MDFrame_const_uptr m_frame
Unit.
const MatrixWorkspace * m_ws
Workspace we refer to.
std::string getName() const override
the name of the dimennlsion as can be displayed along the axis
const Kernel::UnitLabel getUnits() const override
size_t getNBins() const override
number of bins dimension have (an integrated has one).
size_t getNBoundaries() const override
number of axis points (bin boundaries)
MWXDimension(const MatrixWorkspace *ws, std::string dimensionId)
const std::string & getDimensionId() const override
short name which identify the dimension among other dimension.
MantidVec m_X
Cached X vector.
const std::string m_dimensionId
Dimension ID string.
bool getIsIntegrated() const override
if the dimension is integrated (e.g. have single bin)
std::string toXMLString() const override
void setRange(size_t, coord_t, coord_t) override
Change the extents and number of bins.
coord_t getMinimum() const override
coord_t the minimum extent of this dimension
coord_t getMaximum() const override
const Kernel::MDUnit & getMDUnits() const override
Base MatrixWorkspace Abstract Class.
const MaskList & maskedBins(const size_t &workspaceIndex) const
Returns the list of masked bins for a spectrum.
virtual std::pair< int64_t, int64_t > findY(double value, const std::pair< int64_t, int64_t > &idx={0, 0}) const
Find first index in Y equal to value.
void setMarkerStyle(const std::string &markerType)
Set the marker style for plotting.
std::vector< specnum_t > getSpectraFromDetectorIDs(const std::vector< detid_t > &detIdList) const
Converts a list of detector IDs to the corresponding spectrum numbers.
virtual Types::Core::DateAndTime getFirstPulseTime() const
Return the time of the first pulse received, by accessing the run's sample logs to find the proton_ch...
std::vector< std::unique_ptr< IMDIterator > > createIterators(size_t suggestedNumCores=1, Mantid::Geometry::MDImplicitFunction *function=nullptr) const override
Create iterators.
void rebuildSpectraMapping(const bool includeMonitors=true, const specnum_t specNumOffset=1)
Build the default spectra mapping, most likely wanted after an instrument update.
virtual ISpectrum & getSpectrum(const size_t index)=0
Return the underlying ISpectrum ptr at the given workspace index.
std::vector< std::unique_ptr< Axis > > m_axes
A vector of pointers to the axes for this workspace.
virtual size_t getMemorySizeForXAxes() const
Returns the memory used (in bytes) by the X axes, handling ragged bins.
const HistogramData::HistogramE & e(const size_t index) const
double detectorSignedTwoTheta(const Geometry::IDetector &det) const
Returns the signed 2Theta scattering angle for a detector.
std::pair< size_t, size_t > getImageStartEndXIndices(size_t i, double startX, double endX) const
Get start and end x indices for images.
virtual void updateSpectraUsing(const SpectrumDetectorMapping &map)
bool hasAnyMaskedBins() const
Does this workspace contain any masked bins.
virtual bool isHistogramDataByIndex(std::size_t index=0) const
Whether the specified histogram contains histogram data (ie bins)
virtual std::vector< size_t > getDetectorIDToWorkspaceIndexVector(detid_t &offset, bool throwIfMultipleDets=false) const
Return a vector where: The index into the vector = DetectorID (pixel ID) + offset The value at that i...
Types::Core::DateAndTime getLastPulseTime() const
Return the time of the last pulse received, by accessing the run's sample logs to find the proton_cha...
virtual bool isCommonLogBins() const
Returns true if the workspace contains common X bins with log spacing.
std::pair< size_t, double > getXIndex(size_t i, double x, bool isLeft=true, size_t start=0) const
Return an index in the X vector for an x-value close to a given value.
void setUnmaskedBins(const size_t workspaceIndex)
Removes the mask from an index.
bool m_isInitialized
Has this workspace been initialised?
std::unique_ptr< Indexing::IndexInfo > m_indexInfo
std::atomic< bool > m_indexInfoNeedsUpdate
static const std::string xDimensionId
Dimension id for x-dimension.
double detectorTwoTheta(const Geometry::IDetector &det) const
Returns the 2Theta scattering angle for a detector.
std::string m_YUnit
The unit for the data values (e.g. Counts)
void updateCachedDetectorGrouping(const size_t index) const override
Update detector grouping for spectrum with given index.
virtual std::size_t blocksize() const =0
Returns the size of each block of data returned by the dataY accessors.
signal_t getSignalAtCoord(const coord_t *coords, const Mantid::API::MDNormalization &normalization) const override
Get the signal at a coordinate in the workspace.
virtual std::pair< double, double > getXMinMax() const
Get the X range of all spectra, skipping spectra with a non-finite first or last value.
MantidImage_sptr getImageY(size_t start=0, size_t stop=0, size_t width=0, double startX=EMPTY_DBL(), double endX=EMPTY_DBL()) const
Create an image of Ys.
std::shared_ptr< MatrixWorkspace > m_monitorWorkspace
A workspace holding monitor data relating to the main data in the containing workspace (null if none)...
virtual double getXMin() const
void initialize(const std::size_t &NVectors, const std::size_t &XLength, const std::size_t &YLength)
Initialize the workspace.
virtual void setMonitorWorkspace(const std::shared_ptr< MatrixWorkspace > &monitorWS)
Sets the internal monitor workspace to the provided workspace.
virtual std::size_t getNumberHistograms() const =0
Returns the number of histograms in the workspace.
void setMaskedBins(const size_t workspaceIndex, const MaskList &maskedBins)
Set the list of masked bins for given workspaceIndex.
std::size_t binIndexOfValue(Mantid::HistogramData::HistogramX const &xValues, const double xValue, const bool ascendingOrder) const
Returns the bin index of the given X value.
bool hasMaskedBins(const size_t &workspaceIndex) const
Does this spectrum contain any masked bins.
virtual bool hasOrientedLattice() const override
void setTitle(const std::string &) override
Sets MatrixWorkspace title.
void setImage(Accessor mutableData, const MantidImage &image, size_t start, bool parallelExecution)
Copy data from an image.
bool hasGroupedDetectors() const
Does the workspace has any grouped detectors?
virtual std::vector< size_t > getSpectrumToWorkspaceIndexVector(specnum_t &offset) const
Return a vector where: The index into the vector = spectrum number + offset The value at that index =...
std::map< size_t, double > MaskList
Masked bins for each spectrum are stored as a set of pairs containing <bin index, weight>
std::mutex m_isCommonBinsMutex
A mutex protecting the update of m_isCommonBinsFlag.
virtual void setImageE(const MantidImage &image, size_t start=0, bool parallelExecution=true)
Copy the data from an image to this workspace's errors.
std::vector< size_t > getIndicesFromSpectra(const std::vector< specnum_t > &spectraList) const
Converts a list of spectrum numbers to the corresponding workspace indices.
std::size_t yIndexOfX(const double xValue, const std::size_t &index=0, const double tolerance=0.0) const
Returns the y index which corresponds to the X Value provided.
~MatrixWorkspace() override
Delete.
std::map< int64_t, MaskList > m_masks
The set of masked bins in a map keyed on workspace index.
virtual void setImageY(const MantidImage &image, size_t start=0, bool parallelExecution=true)
Copy the data (Y's) from an image to this workspace.
bool isDistribution() const
Are the Y-values dimensioned?
void flagMasked(const size_t &index, const size_t &binIndex, const double &weight=1.0)
Writes the masking weight to m_masks (doesn't alter y-values).
MantidImage_sptr getImageE(size_t start=0, size_t stop=0, size_t width=0, double startX=EMPTY_DBL(), double endX=EMPTY_DBL()) const
Create an image of Es.
void setMDMasking(std::unique_ptr< Mantid::Geometry::MDImplicitFunction > maskingRegion) override
Apply masking.
void maskBin(const size_t &workspaceIndex, const size_t &binIndex, const double &weight=1.0)
Called by the algorithm MaskBins to mask a single bin for the first time, algorithms that later propa...
std::string getMarkerStyle() const
Get the marker style for plotting.
std::shared_ptr< MatrixWorkspace > monitorWorkspace() const
Returns a pointer to the internal monitor workspace.
Kernel::cow_ptr< HistogramData::HistogramX > sharedX(const size_t index) const
LinePlot getLinePlot(const Mantid::Kernel::VMD &start, const Mantid::Kernel::VMD &end, Mantid::API::MDNormalization normalize) const override
Generate a line plot through the matrix workspace.
virtual bool isRaggedWorkspace() const =0
Returns true if the workspace is ragged (has differently sized spectra).
void invalidateCachedSpectrumNumbers()
std::vector< size_t > maskedBinsIndices(const size_t &workspaceIndex) const
virtual bool isIntegerBins() const
Returns true if the workspace has common, integer X bins.
HistogramData::Histogram histogram(const size_t index) const
Returns the Histogram at the given workspace index.
std::vector< size_t > getIndicesFromDetectorIDs(const std::vector< detid_t > &detIdList) const
Converts a list of detector IDs to the corresponding workspace indices.
const std::string getTitle() const override
Gets MatrixWorkspace title (same as Run object run_title property)
void setDistribution(bool newValue)
Set the flag for whether the Y-values are dimensioned.
size_t getMemorySize() const override
Get the footprint in memory in bytes.
const Indexing::IndexInfo & indexInfo() const
Returns a const reference to the IndexInfo object of the workspace.
virtual void getIntegratedSpectra(std::vector< double > &out, const double minX, const double maxX, const bool entireRange) const
Return a vector with the integrated counts for all spectra withing the given range.
float getMarkerSize() const
Get the size of the marker for plotting.
uint64_t getNPoints() const override
Gets the number of points available on the workspace.
std::string getPlotType() const
Gets MatrixWorkspace plot_type.
detid2index_map getDetectorIDToWorkspaceIndexMap(bool throwIfMultipleDets=false, bool ignoreIfNoValidDets=false) const
Return a map where: KEY is the DetectorID (pixel ID) VALUE is the Workspace Index.
std::atomic< bool > m_isCommonBinsFlagValid
Flag indicating if the common bins flag is in a valid state.
std::string getDimensionIdFromAxis(const int &axisIndex) const
Getter for the dimension id based on the axis.
virtual Axis * getAxis(const std::size_t &axisIndex) const
Get a non owning pointer to a workspace axis.
void setPlotType(const std::string &)
Sets MatrixWorkspace plot_type.
std::vector< double > getIntegratedCountsForWorkspaceIndices(const std::vector< size_t > &workspaceIndices, const double minX, const double maxX, const bool entireRange) const
size_t getNumDims() const override
virtual double getXMax() const
std::atomic< bool > m_isCommonBinsFlag
Flag indicating whether the data has common bins.
HistogramData::HistogramE & mutableE(const size_t index) &
std::mutex m_indexInfoMutex
void setIndexInfoWithoutISpectrumUpdate(const Indexing::IndexInfo &indexInfo)
Variant of setIndexInfo, used by WorkspaceFactoryImpl.
static const std::string yDimensionId
Dimensin id for y-dimension.
void rebuildDetectorIDGroupings()
void buildDefaultSpectrumDefinitions()
spec2index_map getSpectrumToWorkspaceIndexMap() const
Return a map where: KEY is the Spectrum # VALUE is the Workspace Index.
size_t getIndexFromSpectrumNumber(const specnum_t specNo) const
Given a spectrum number, find the corresponding workspace index.
MatrixWorkspace()
Default constructor.
void replaceAxis(const std::size_t &axisIndex, std::unique_ptr< Axis > newAxis)
Replaces one of the workspace's axes with the new one provided.
virtual std::size_t size() const =0
Returns the number of single indexable items in the workspace.
virtual void init(const std::size_t &NVectors, const std::size_t &XLength, const std::size_t &YLength)=0
Initialises the workspace.
const std::string toString() const override
String description of state.
HistogramData::HistogramY & mutableY(const size_t index) &
MantidImage_sptr getImage(Accessor read, size_t start, size_t stop, size_t width, size_t indexStart, size_t indexEnd) const
Create an MantidImage instance.
virtual ISpectrum & getSpectrumWithoutInvalidation(const size_t index)=0
Mantid::Kernel::SpecialCoordinateSystem getSpecialCoordinateSystem() const override
std::string YUnitLabel(bool useLatex=false) const
Returns a caption for the units of the data in the workspace.
void setYUnitLabel(const std::string &newLabel)
Sets a new caption for the data (Y axis) in the workspace.
const HistogramData::HistogramY & y(const size_t index) const
signal_t getSignalWithMaskAtCoord(const coord_t *coords, const Mantid::API::MDNormalization &normalization) const override
Get the signal at a coordinate in the workspace.
void setMarkerSize(const float markerSize)
Set the size of the marker for plotting.
std::shared_ptr< const Mantid::Geometry::IMDDimension > getDimension(size_t index) const override
Get a dimension.
virtual bool isCommonBins() const
Returns true if the workspace contains common X bins.
std::shared_ptr< const Geometry::IDetector > getDetector(const size_t workspaceIndex) const
Get the effective detector for the given spectrum.
void setYUnit(const std::string &newUnit)
Sets a new unit for the data (Y axis) in the workspace.
size_t numberOfAxis() const
Will return the number of Axis currently stored in the workspace it is not always safe to assume it i...
std::string m_YUnitLabel
A text label for use when plotting spectra.
virtual bool isHistogramData() const
Returns true if the workspace contains data in histogram form (as opposed to point-like)
void setIndexInfo(const Indexing::IndexInfo &indexInfo)
Sets the IndexInfo object of the workspace.
void clearMDMasking() override
Clear exsting masking.
std::size_t xIndexOfValue(const Mantid::HistogramData::HistogramX &xValues, const double xValue, const double tolerance) const
Returns the X index of the given X value.
std::shared_ptr< const Mantid::Geometry::IMDDimension > getDimensionWithId(std::string id) const override
Get a dimension.
This class stores information regarding an experimental run as a series of log entries.
size_t getMemorySize() const override
Return an approximate memory size for the object in bytes.
bool hasOrientedLattice() const
Class to represent the spectra axis of a workspace.
A minimal class to hold the mapping between the spectrum number and its related detector ID numbers f...
const std::set< detid_t > & getDetectorIDsForSpectrumNo(const specnum_t spectrumNo) const
const std::set< detid_t > & getDetectorIDsForSpectrumIndex(const size_t spectrumIndex) const
bool indexIsSpecNumber() const
bool threadSafe() const override
Marks the workspace as safe for multiple threads to edit data simutaneously.
virtual void setTitle(const std::string &)
Set the title of the workspace.
virtual const std::string getTitle() const
Get the workspace title.
GeneralFrame : Any MDFrame that isn't related to momemtum transfer.
Interface class for detector objects.
virtual double getTwoTheta(const Kernel::V3D &observer, const Kernel::V3D &axis) const =0
Gives the angle of this detector object with respect to an axis.
virtual double getSignedTwoTheta(const Kernel::V3D &observer, const Kernel::V3D &axis, const Kernel::V3D &instrumentUp) const =0
Gives the signed angle of this detector object with respect to an axis.
The class describes one dimension of multidimensional dataset representing an orthogonal dimension an...
MDFrame : The coordinate frame for a dimension, or set of dimensions in a multidimensional workspace.
An "ImplicitFunction" defining a hyper-cuboid-shaped region in N dimensions.
virtual const std::string id() const =0
A string ID for the class.
Exception for index errors.
Exception for errors associated with the instrument definition.
Exception for when an item is not found in a collection.
ListValidator is a validator that requires the value of a property to be one of a defined list of pos...
void debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
MDUnit : Unit type for multidimensional data types.
The concrete, templated class for properties.
virtual std::string value() const =0
Returns the value of the property as a string.
A specialised Property class for holding a series of time-value pairs.
A base-class for the a class that is able to return unit labels in different representations.
bool nullVector(const double tolerance=1e-3) const noexcept
Determine if the point is null.
std::vector< std::vector< double > > MantidImage
typedef for the image type
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
MDNormalization
Enum describing different ways to normalize the signal in a MDWorkspace.
@ VolumeNormalization
Divide the signal by the volume of the box/bin.
@ NumEventsNormalization
Divide the signal by the number of events that contributed to it.
@ NoNormalization
Don't normalize = return raw counts.
std::shared_ptr< MantidImage > MantidImage_sptr
shared pointer to MantidImage
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< const IComponent > IComponent_const_sptr
Typdef of a shared pointer to a const IComponent.
std::unique_ptr< const MDFrame > MDFrame_const_uptr
std::shared_ptr< const Mantid::Geometry::IDetector > IDetector_const_sptr
Shared pointer to IDetector (const version)
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
size_t MANTID_KERNEL_DLL indexOfValueFromEdges(std::span< double const > bin_edges, const double value)
Gets the bin of a value from a vector of bin edges.
size_t MANTID_KERNEL_DLL indexOfValueFromCenters(std::span< double const > bin_centers, const double value)
Gets the bin of a value from a vector of bin centers and throws exception if out of range.
SpecialCoordinateSystem
Special coordinate systems for Q3D.
MANTID_KERNEL_DLL V3D normalize(V3D v)
Normalizes a V3D.
std::unordered_map< specnum_t, size_t > spec2index_map
Map with key = spectrum number, value = workspace index.
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
int32_t detid_t
Typedef for a detector ID.
std::unordered_map< detid_t, size_t > detid2index_map
Map with key = detector ID, value = workspace index.
const std::vector< std::string > validPlotTypes
double signal_t
Typedef for the signal recorded in a MDBox, etc.
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
int32_t specnum_t
Typedef for a spectrum Number.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
const std::vector< std::string > validMarkerStyles
std::string to_string(const wide_integer< Bits, Signed > &n)
Holds X, Y, E for a line plot.