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>
45using Mantid::Types::Core::DateAndTime;
49auto accumulate_if_finite = [](
const double accumulator,
const double newValue) {
50 if (std::isfinite(newValue)) {
51 return accumulator + newValue;
60using namespace Geometry;
65Kernel::Logger
g_log(
"MatrixWorkspace");
66constexpr const double EPSILON{1.0e-9};
76std::string appendUnitDenominatorUsingPer(std::string yLabel,
const MatrixWorkspace &
workspace,
bool useLatex) {
78 std::string xLabel =
workspace.getAxis(0)->unit()->label().latex();
80 yLabel +=
" per $" +
workspace.getAxis(0)->unit()->label().latex() +
"$";
82 std::string xLabel =
workspace.getAxis(0)->unit()->label().ascii();
84 yLabel +=
" per " +
workspace.getAxis(0)->unit()->label().ascii();
95std::string replacePerWithLatex(std::string yLabel) {
96 std::vector<std::string> splitVec;
97 boost::split_regex(splitVec, yLabel, boost::regex(
" per "));
98 if (splitVec.size() > 1) {
100 splitVec.erase(splitVec.begin());
101 std::string unitString = boost::algorithm::join(splitVec,
" ");
104 yLabel +=
"(" + unitString +
")$^{-1}$";
120 m_isInitialized(other.m_isInitialized), m_YUnit(other.m_YUnit), m_YUnitLabel(other.m_YUnitLabel),
121 m_masks(other.m_masks), m_indexInfoNeedsUpdate(false), m_marker_size(6.) {
122 m_axes.resize(other.m_axes.size());
123 for (
size_t i = 0; i <
m_axes.size(); ++i)
124 m_axes[i] = std::unique_ptr<Axis>(other.m_axes[i]->clone(
this));
148 std::vector<Indexing::SpectrumNumber> spectrumNumbers;
151 m_indexInfo->setSpectrumNumbers(std::move(spectrumNumbers));
163 throw std::invalid_argument(
"MatrixWorkspace::setIndexInfo: IndexInfo size "
164 "does not match number of histograms in "
195 throw std::invalid_argument(
"MatrixWorkspace::setIndexInfo: IndexInfo size "
196 "does not match number of histograms in "
205 std::ostringstream os;
213 }
catch (std::length_error &) {
220 os <<
"Data points\n";
225 if (ax && ax->
unit())
226 os << ax->
unit()->caption() <<
" / " << ax->
unit()->label().ascii();
235 os <<
"Distribution: " << (
isDistribution() ?
"True" :
"False") <<
"\n";
253 if (NVectors == 0 || XLength == 0 || YLength == 0) {
254 throw std::out_of_range(
"All arguments to init must be positive and non-zero");
262 m_indexInfo = std::make_unique<Indexing::IndexInfo>(NVectors);
266 this->
init(NVectors, XLength, YLength);
267 }
catch (std::runtime_error &) {
277 Indexing::IndexInfo indices(NVectors);
279 indices.setSpectrumDefinitions(std::vector<SpectrumDefinition>(NVectors));
286 throw std::out_of_range(
"All arguments to init must be positive and non-zero");
321 if (
run().hasProperty(
"run_title")) {
336 if (v.isValid(t) ==
"") {
339 std::string validValues = std::accumulate(
341 [](
const std::string &valuesString,
const std::string &plotType) { return valuesString +
", " + plotType; });
342 throw std::invalid_argument(
"Invalid plot type '" + t +
"'. Must be one of: " + validValues);
351 std::string plotType;
352 if (
run().hasProperty(
"plot_type")) {
368 if (v.isValid(markerType) ==
"") {
371 std::string validValues =
373 [](
const std::string &valuesString,
const std::string &markerStyle) {
374 return valuesString +
", " + markerStyle;
376 throw std::invalid_argument(
"Invalid marker type '" + markerType +
"'. Must be one of: " + validValues);
387 return Kernel::ConfigService::Instance().getString(
"plots.markerworkspace.MarkerStyle");
416 }
catch (std::out_of_range &exception) {
418 spec.clearDetectorIDs();
420 g_log.
debug() <<
"Spectrum number " << spec.getSpectrumNo() <<
" not in map.\n";
439 const std::vector<detid_t> pixelIDs = this->
getInstrument()->getDetectorIDs(!includeMonitors);
444 std::vector<detid_t>::const_iterator iend = pixelIDs.end();
445 for (std::vector<detid_t>::const_iterator it = pixelIDs.begin(); it != iend; ++it) {
450 if (
index < NUM_HIST) {
452 spec.setSpectrumNo(specNo);
453 spec.setDetectorID(detId);
459 }
catch (std::runtime_error &) {
471 throw std::runtime_error(
"MatrixWorkspace::getSpectrumToWorkspaceIndexMap: "
472 "axis[1] is not a SpectraAxis, so I cannot "
475 return ax->getSpectraIndexMap();
476 }
catch (std::runtime_error &) {
477 g_log.
error() <<
"MatrixWorkspace::getSpectrumToWorkspaceIndexMap: no elements!";
493 throw std::runtime_error(
"MatrixWorkspace::getSpectrumToWorkspaceIndexMap: "
494 "axis[1] is not a SpectraAxis, so I cannot "
498 specnum_t min = std::numeric_limits<specnum_t>::max();
500 specnum_t max = -std::numeric_limits<specnum_t>::max();
503 size_t length = ax->length();
504 for (
size_t i = 0; i < length; i++) {
516 std::vector<size_t> out(max - min + 1, 0);
519 for (
size_t i = 0; i < length; i++) {
521 out[spec + offset] = i;
534 for (
size_t workspaceIndex = 0; workspaceIndex < this->
getNumberHistograms(); workspaceIndex++) {
536 if (detList.size() > 1) {
558 bool ignoreIfNoValidDets)
const {
563 for (
size_t workspaceIndex = 0; workspaceIndex < this->
getNumberHistograms(); ++workspaceIndex) {
565 if (ignoreIfNoValidDets && !specInfo.hasDetectors(workspaceIndex)) {
570 if (throwIfMultipleDets) {
571 if (detList.size() > 1) {
572 throw std::runtime_error(
"MatrixWorkspace::getDetectorIDToWorkspaceIndexMap(): more than 1 "
573 "detector for one histogram! I cannot generate a map of detector "
574 "ID to workspace index.");
578 if (detList.size() == 1)
579 map[*detList.begin()] = workspaceIndex;
582 for (
auto det : detList)
583 map[det] = workspaceIndex;
605 bool throwIfMultipleDets)
const {
607 std::vector<size_t> out;
612 const int outSize = maxId - minId + 1;
614 out.resize(outSize, std::numeric_limits<size_t>::max());
616 for (
size_t workspaceIndex = 0; workspaceIndex <
getNumberHistograms(); ++workspaceIndex) {
620 if (throwIfMultipleDets && (detList.size() > 1))
621 throw std::runtime_error(
"MatrixWorkspace::getDetectorIDToWorkspaceIndexVector(): more than 1 "
622 "detector for one histogram! I cannot generate a map of detector ID "
623 "to workspace index.");
627 for (
auto det : detList) {
628 int index = det + offset;
629 if (index < 0 || index >= outSize) {
630 g_log.
debug() <<
"MatrixWorkspace::getDetectorIDToWorkspaceIndexVector("
631 "): detector ID found ("
632 << det <<
" at workspace index " << workspaceIndex <<
") is invalid.\n";
635 out[
index] = workspaceIndex;
650 std::vector<size_t> indexList;
653 auto iter = spectraList.cbegin();
654 while (iter != spectraList.cend()) {
657 indexList.emplace_back(i);
677 throw std::runtime_error(
"Could not find spectrum number in any spectrum.");
693 throw std::runtime_error(
"MatrixWorkspace: Using getIndicesFromDetectorIDs "
694 "in a parallel run is most likely incorrect. "
698 std::set<detid_t> detIdSet(detIdList.cbegin(), detIdList.cend());
701 std::map<detid_t, std::set<size_t>> detectorIDtoWSIndices;
703 for (
size_t i = 0; i < NUM_HIST; ++i) {
705 for (
const auto &detID : detIDs) {
707 if (detIdSet.count(detID) > 0) {
708 detectorIDtoWSIndices[detID].insert(i);
714 std::vector<size_t> indexList;
715 indexList.reserve(detIdList.size());
716 for (
const auto &detId : detIdList) {
717 const auto wsIndices = detectorIDtoWSIndices.find(detId);
718 if (wsIndices != detectorIDtoWSIndices.end()) {
719 std::copy(wsIndices->second.cbegin(), wsIndices->second.cend(), std::back_inserter(indexList));
734 std::vector<specnum_t> spectraList;
737 for (
auto detId : detIdList) {
738 bool foundDet =
false;
751 spectraList.emplace_back(foundSpecNum);
772 xmin = std::numeric_limits<double>::max();
777 for (
size_t workspaceIndex = 0; workspaceIndex < numberOfSpectra; workspaceIndex++) {
778 const auto &xData = this->
x(workspaceIndex);
779 const double xfront = xData.front();
780 const double xback = xData.back();
781 if (std::isfinite(xfront) && std::isfinite(xback)) {
804 const bool entireRange)
const {
812 for (
int wksp_index = 0; wksp_index < static_cast<int>(this->
getNumberHistograms()); wksp_index++) {
815 const auto &yData = this->
y(wksp_index);
817 if ((xData.size() <= 1 + histogramOffset) && (!yData.empty())) {
818 out[wksp_index] = yData[0];
821 Mantid::MantidVec::const_iterator lowit, highit;
822 lowit = xData.begin();
823 highit = xData.end() - histogramOffset;
829 lowit = std::lower_bound(xData.begin(), xData.end(), minX);
831 if (*(highit - 1 + histogramOffset) > maxX)
832 highit = std::upper_bound(lowit, xData.end(), maxX);
836 Mantid::MantidVec::difference_type distmin = std::distance(xData.begin(), lowit);
837 Mantid::MantidVec::difference_type distmax = std::distance(xData.begin(), highit);
839 if (distmin <= distmax) {
841 sum = std::accumulate(yData.begin() + distmin, yData.begin() + distmax, 0.0, accumulate_if_finite);
844 out[wksp_index] = sum;
850 const double minX,
const double maxX,
851 const bool entireRange)
const {
852 std::vector<double> integratedSpectra;
854 std::vector<double> detectorCounts;
855 std::transform(workspaceIndices.cbegin(), workspaceIndices.cend(), std::back_inserter(detectorCounts),
856 [&](
const auto &wsIndex) { return integratedSpectra[wsIndex]; });
857 return detectorCounts;
872 if (!localInstrument) {
877 const size_t ndets = dets.size();
880 return localInstrument->getDetector(*dets.begin());
881 }
else if (ndets == 0) {
883 "detectors for this workspace "
888 auto dets_ptr = localInstrument->getDetectors(dets);
889 return std::make_shared<Geometry::DetectorGroup>(dets_ptr);
904 if (source ==
nullptr ||
sample ==
nullptr) {
906 "Instrument not sufficiently defined: failed to get source and/or "
911 const Kernel::V3D beamLine = samplePos - source->getPos();
917 const V3D &thetaSignAxis = instrument->getReferenceFrame()->vecThetaSign();
932 if (source ==
nullptr ||
sample ==
nullptr) {
934 "Instrument not sufficiently defined: failed to get source and/or "
939 const Kernel::V3D beamLine = samplePos - source->getPos();
957 if (axisIndex >=
m_axes.size()) {
961 return m_axes[axisIndex].get();
975 if (axisIndex >=
m_axes.size()) {
979 m_axes[axisIndex] = std::move(newAxis);
995 const auto &x0 = this->
x(0);
1001 if (x0[1] == x0[0]) {
1005 double diff = x0[1] / x0[0];
1006 if (!std::isfinite(diff)) {
1010 for (
size_t i = 1; i < x0.size() - 2; ++i) {
1011 if (std::isfinite(x0[i + 1]) && std::isfinite(x0[i])) {
1012 if (std::abs(x0[i + 1] / x0[i] - diff) >
EPSILON) {
1046 retVal = appendUnitDenominatorUsingPer(retVal, *
this, useLatex);
1054 retVal = appendUnitDenominatorUsingPer(retVal, *
this, useLatex);
1057 retVal = replacePerWithLatex(retVal);
1069 return getSpectrum(0).
yMode() == HistogramData::Histogram::YMode::Frequencies;
1077 HistogramData::Histogram::YMode ymode =
1078 newValue ? HistogramData::Histogram::YMode::Frequencies : HistogramData::Histogram::YMode::Counts;
1103 throw std::logic_error(
"In MatrixWorkspace::isHistogramData(): "
1104 "Histogram::Xmode is not BinEdges");
1108 throw std::logic_error(
"In MatrixWorkspace::isHistogramData(): "
1109 "Histogram::Xmode is not Points");
1133 const HistogramData::HistogramX *first = &
x(0);
1134 for (
size_t i = 1; i < numHist; ++i) {
1135 if (&
x(i) != first) {
1148 const size_t numBins =
x(0).size();
1149 for (
size_t i = 1; i < numHist; ++i) {
1150 if (
x(i).
size() != numBins) {
1156 const auto &x0 =
x(0);
1159 for (
int i = 1; i < static_cast<int>(numHist); ++i) {
1161 const auto specIndex =
static_cast<std::size_t
>(i);
1162 const auto &xi =
x(specIndex);
1163 for (
size_t j = 0; j < numBins; ++j) {
1164 const double a = x0[j];
1165 const double b = xi[j];
1167 if (std::isfinite(a) && std::isfinite(b)) {
1168 if (std::abs(a - b) >
EPSILON) {
1173 }
else if ((std::isnan(a) != std::isnan(b)) || (std::isinf(a) != std::isinf(b))) {
1191 const HistogramData::HistogramX bins =
x(0);
1193 for (
size_t i = 0; i < bins.size(); ++i) {
1194 if (std::trunc(bins[i]) != bins[i])
1218 "MatrixWorkspace::maskBin,workspaceIndex");
1220 if (binIndex >=
y(workspaceIndex).
size())
1224 flagMasked(workspaceIndex, binIndex, weight);
1234 double &yData = this->
mutableY(workspaceIndex)[binIndex];
1235 (std::isnan(yData) || std::isinf(yData)) ? yData = 0. : yData *= (1 - weight);
1236 double &eData = this->
mutableE(workspaceIndex)[binIndex];
1237 (std::isnan(eData) || std::isinf(eData)) ? eData = 0. : eData *= (1 - weight);
1255 binList[binIndex] = weight;
1283 auto it =
m_masks.find(workspaceIndex);
1294 auto it =
m_masks.find(workspaceIndex);
1301 auto maskedBinsList = it->second;
1302 std::vector<size_t> maskedIds;
1303 maskedIds.reserve(maskedBinsList.size());
1305 std::transform(maskedBinsList.begin(), maskedBinsList.end(), std::back_inserter(maskedIds),
1306 [](
const auto &mb) { return mb.first; });
1336 if (monitorWS.get() ==
this) {
1337 throw std::runtime_error(
"To avoid memory leak, monitor workspace"
1338 " can not be the same workspace as the host workspace");
1355 for (
size_t i = 0; i < numHist; ++i) {
1358 return total + runMemSize;
1361 return 3 *
size() *
sizeof(double) + runMemSize;
1370 auto lastX = this->
refX(0);
1372 auto X = this->
refX(wi);
1374 if (!(
X == lastX) || wi == 0)
1375 total += (*X).size() *
sizeof(double);
1409 [[maybe_unused]]
const double tolerance)
const {
1411 throw std::out_of_range(
"MatrixWorkspace::yIndexOfX - Index out of range.");
1413 const auto &xValues = this->
x(index);
1414 const bool ascendingOrder = xValues.front() < xValues.back();
1415 const auto minX = ascendingOrder ? xValues.front() : xValues.back();
1416 const auto maxX = ascendingOrder ? xValues.back() : xValues.front();
1419 if (xValue < minX || xValue > maxX)
1420 throw std::out_of_range(
"MatrixWorkspace::yIndexOfX - X value is out of "
1421 "the range of the min and max bin edges.");
1425 if (xValue < minX - tolerance || xValue > maxX +
tolerance)
1426 throw std::out_of_range(
"MatrixWorkspace::yIndexOfX - X value is out of "
1427 "range for this point data.");
1441 const bool ascendingOrder)
const {
1443 if (ascendingOrder) {
1444 auto lowerIter = std::lower_bound(xValues.cbegin(), xValues.cend(), xValue);
1447 if (lowerIter == xValues.cbegin())
1450 hops = std::distance(xValues.cbegin(), lowerIter);
1452 auto lowerIter = std::lower_bound(xValues.crbegin(), xValues.crend(), xValue);
1454 if (lowerIter == xValues.crbegin())
1457 hops = xValues.size() - std::distance(xValues.crbegin(), lowerIter);
1474 auto const iter = std::find_if(xValues.cbegin(), xValues.cend(), [&xValue, &
tolerance](
double const &
value) {
1475 return std::abs(xValue - value) <= tolerance;
1477 if (iter != xValues.cend())
1478 return std::distance(xValues.cbegin(), iter);
1480 throw std::invalid_argument(
"MatrixWorkspace::yIndexOfX - the X value provided could not be found "
1481 "in the workspace containing point data.");
1493 if (0 == axisIndex) {
1495 }
else if (1 == axisIndex) {
1498 throw std::invalid_argument(
"Cannot have an index for a MatrixWorkspace "
1499 "axis that is not == 0 or == 1");
1515 if (unit && unit->unitID() !=
"Empty")
1516 return unit->caption();
1552 throw std::runtime_error(
"Not implemented");
1569 std::string
toXMLString()
const override {
throw std::runtime_error(
"Not implemented"); }
1590 m_ws->getAxis(0)->unit()->label())) {}
1595 const auto &unit = axis->
unit();
1596 if (unit && unit->unitID() !=
"Empty")
1597 return unit->caption();
1599 return axis->title();
1628 throw std::runtime_error(
"Not implemented");
1635 std::string
toXMLString()
const override {
throw std::runtime_error(
"Not implemented"); }
1652 return std::make_shared<MWXDimension>(
this,
xDimensionId);
1653 }
else if (
index == 1) {
1655 return std::make_shared<MWDimension>(yAxis,
yDimensionId);
1657 throw std::invalid_argument(
"MatrixWorkspace only has 2 dimensions.");
1661 int nAxes = this->
axes();
1662 std::shared_ptr<IMDDimension> dim;
1663 for (
int i = 0; i < nAxes; i++) {
1665 if (knownId ==
id) {
1666 dim = std::make_shared<MWDimension>(this->
getAxis(i),
id);
1671 if (
nullptr == dim) {
1672 std::string message =
"Cannot find id : " +
id;
1673 throw std::overflow_error(message);
1685std::vector<std::unique_ptr<IMDIterator>>
1688 size_t numCores = suggestedNumCores;
1692 if (numCores > numElements)
1693 numCores = numElements;
1698 std::vector<std::unique_ptr<IMDIterator>> out;
1699 for (
size_t i = 0; i < numCores; i++) {
1700 size_t begin = (i * numElements) / numCores;
1701 size_t end = ((i + 1) * numElements) / numCores;
1702 if (end > numElements)
1704 out.emplace_back(std::make_unique<MatrixWorkspaceMDIterator>(
this, function, begin, end));
1735 if (this->
axes() != 2)
1736 throw std::invalid_argument(
"MatrixWorkspace::getSignalAtCoord() - "
1737 "Workspace can only have 2 axes, found " +
1745 }
catch (std::out_of_range &) {
1746 return std::numeric_limits<double>::quiet_NaN();
1750 const auto &yVals = this->
y(wi);
1751 double yBinSize(1.0);
1754 double currentVertical = ax1->operator()(wi, uVI);
1755 if (wi + 1 == nhist && nhist > 1)
1757 yBinSize = currentVertical - ax1->operator()(wi - 1, uVI);
1759 yBinSize = ax1->operator()(wi + 1, uVI) - currentVertical;
1764 const auto &xVals =
x(wi);
1772 }
catch (std::out_of_range &) {
1773 return std::numeric_limits<double>::quiet_NaN();
1776 double yVal = yVals[i];
1778 switch (normalization) {
1783 auto volume = yBinSize * (xVals[i + 1] - xVals[i]);
1784 if (volume == 0.0) {
1785 return std::numeric_limits<double>::quiet_NaN();
1787 return yVal / volume;
1796 return std::numeric_limits<double>::quiet_NaN();
1817 throw std::runtime_error(
"MatrixWorkspace::setMDMasking has no implementation");
1824 throw std::runtime_error(
"MatrixWorkspace::clearMDMasking has no implementation");
1848 size_t start, size_t stop, size_t width, size_t indexStart,
1849 size_t indexEnd) const {
1852 throw std::runtime_error(
"Cannot create image with width 0");
1855 size_t nHist = getNumberHistograms();
1863 throw std::runtime_error(
"Cannot create image for an empty data set.");
1866 if (start >= nHist) {
1867 throw std::runtime_error(
"Cannot create image: start index is out of range");
1870 if (stop >= nHist) {
1871 throw std::runtime_error(
"Cannot create image: stop index is out of range");
1875 size_t dataSize = stop - start + 1;
1876 size_t height = dataSize / width;
1879 if (
height * width != dataSize) {
1880 throw std::runtime_error(
"Cannot create image: the data set cannot form a rectangle.");
1883 size_t nBins = blocksize();
1884 bool isHisto = isHistogramData();
1887 if (indexEnd == 0) {
1889 if (!isHisto && indexEnd > 0)
1894 if (indexEnd < indexStart) {
1895 throw std::runtime_error(
"Cannot create image for an empty data set.");
1898 if (indexStart >= nBins || indexEnd > nBins || (!isHisto && indexEnd == nBins)) {
1899 throw std::runtime_error(
"Cannot create image: integration interval is out of range.");
1903 auto image = std::make_shared<MantidImage>(
height);
1908 if (isHisto && indexEnd == indexStart + 1) {
1910 for (
int i = 0; i < static_cast<
int>(
height); ++i) {
1911 auto &row = (*image)[i];
1913 size_t spec = start +
static_cast<size_t>(i) * width;
1914 for (
size_t j = 0; j < width; ++j, ++spec) {
1915 row[j] = (this->*read)(spec)[indexStart];
1921 for (
int i = 0; i < static_cast<
int>(
height); ++i) {
1922 auto &row = (*image)[i];
1924 size_t spec = start +
static_cast<size_t>(i) * width;
1925 for (
size_t j = 0; j < width; ++j, ++spec) {
1926 auto &V = (this->*read)(spec);
1927 row[j] = std::accumulate(V.begin() + indexStart, V.begin() + indexEnd, 0.0);
1936 std::pair<int64_t, int64_t> out(-1, -1);
1938 if (std::isnan(
value)) {
1939 for (int64_t i = idx.first; i < numHists; ++i) {
1940 const auto &
Y = this->
y(i);
1941 if (
auto it = std::find_if(std::next(
Y.begin(), idx.second),
Y.end(), [](
double v) { return std::isnan(v); });
1943 out = {i, std::distance(
Y.begin(), it)};
1948 for (int64_t i = idx.first; i < numHists; ++i) {
1949 const auto &
Y = this->
y(i);
1950 if (
auto it = std::find(std::next(
Y.begin(), idx.second),
Y.end(),
value); it !=
Y.end()) {
1951 out = {i, std::distance(
Y.begin(), it)};
1967 startX =
x(i).front();
1968 auto pStart =
getXIndex(i, startX,
true);
1969 if (pStart.second != 0.0) {
1970 throw std::runtime_error(
"Start X value is required to be on bin boundary.");
1974 auto pEnd =
getXIndex(i, endX,
false, pStart.first);
1975 if (pEnd.second != 0.0) {
1976 throw std::runtime_error(
"End X value is required to be on bin boundary.");
1978 return std::make_pair(pStart.first, pEnd.first);
2020 auto &
X = this->
x(i);
2025 return std::make_pair(nx, 0.0);
2026 if (start > 0 && start == nx - 1) {
2029 return std::make_pair(start, 0.0);
2030 return std::make_pair(nx, 0.0);
2037 return x <=
X[start] ? std::make_pair(start, 0.0) : std::make_pair(nx, 0.0);
2038 return x >=
X[start] ? std::make_pair(start, 0.0) : std::make_pair(nx, 0.0);
2042 if (
x <=
X[start]) {
2043 return isLeft ? std::make_pair(start, 0.0) : std::make_pair(nx, 0.0);
2046 if (
x >=
X.back()) {
2047 return !isLeft ? std::make_pair(nx - 1, 0.0) : std::make_pair(nx, 0.0);
2052 for (
auto ix =
X.begin() + start + 1; ix != end; ++ix) {
2054 auto index =
static_cast<size_t>(std::distance(
X.begin(), ix));
2057 return std::make_pair(
index, std::abs((
X[
index] -
x) / (*ix - *(ix - 1))));
2061 return std::make_pair(nx, 0.0);
2073 size_t start, [[maybe_unused]] bool parallelExecution) {
2077 if (image[0].empty())
2081 throw std::runtime_error(
"Cannot set image: a single bin workspace is expected.");
2084 size_t height = image.size();
2085 size_t width = image.front().size();
2086 size_t dataSize = width *
height;
2089 throw std::runtime_error(
"Cannot set image: image is bigger than workspace.");
2093 for (
int i = 0; i < static_cast<int>(
height); ++i) {
2094 auto &row = image[i];
2095 if (row.size() != width) {
2096 throw std::runtime_error(
"Canot set image: image is corrupted.");
2098 size_t spec = start +
static_cast<size_t>(i) * width;
2099 auto rowEnd = row.end();
2100 for (
auto pixel = row.begin(); pixel != rowEnd; ++pixel, ++spec) {
2101 (this->*dataVec)(spec)[0] = *pixel;
2140 size_t numberOfDetectors{detInfo.size()};
2141 if (numberOfDetectors == 0) {
2146 size_t numberOfSpectra = numberOfDetectors * detInfo.scanCount();
2148 throw std::invalid_argument(
"MatrixWorkspace: IndexInfo does not contain spectrum definitions so "
2149 "building a 1:1 mapping from spectra to detectors was attempted, but "
2150 "the number of spectra in the workspace is not equal to the number of "
2151 "detectors in the instrument.");
2152 std::vector<SpectrumDefinition> specDefs(
m_indexInfo->size());
2153 if (!detInfo.isScanning() && (numberOfSpectra ==
m_indexInfo->size())) {
2154 for (
size_t i = 0; i < numberOfSpectra; ++i)
2157 size_t specIndex = 0;
2158 size_t globalSpecIndex = 0;
2159 for (
size_t detIndex = 0; detIndex < detInfo.size(); ++detIndex) {
2160 for (
size_t time = 0; time < detInfo.scanCount(); ++time) {
2161 if (
m_indexInfo->isOnThisPartition(Indexing::GlobalSpectrumIndex(globalSpecIndex++)))
2162 specDefs[specIndex++].add(detIndex, time);
2166 m_indexInfo->setSpectrumDefinitions(std::move(specDefs));
2171 const auto detInfo_scanCount = detInfo.scanCount();
2172 const auto &allDetIDs = detInfo.detectorIDs();
2173 const auto allDetIDs_size = allDetIDs.size();
2174 const auto &specDefs =
m_indexInfo->spectrumDefinitions();
2175 const auto indexInfoSize =
static_cast<int64_t
>(
m_indexInfo->size());
2176 enum class ErrorCode {
None, InvalidDetIndex, InvalidTimeIndex };
2177 std::atomic<ErrorCode> errorValue(ErrorCode::None);
2178#pragma omp parallel for
2179 for (int64_t i = 0; i < indexInfoSize; ++i) {
2182 spec.setMatrixWorkspace(
nullptr, i);
2184 std::set<detid_t> detIDs;
2185 for (
const auto &
index : (*specDefs)[i]) {
2186 const size_t detIndex =
index.first;
2187 if (detIndex >= allDetIDs_size) {
2188 errorValue = ErrorCode::InvalidDetIndex;
2189 }
else if (
index.second >= detInfo_scanCount) {
2190 errorValue = ErrorCode::InvalidTimeIndex;
2192 detIDs.insert(allDetIDs[detIndex]);
2195 spec.setDetectorIDs(std::move(detIDs));
2197 switch (errorValue) {
2198 case ErrorCode::InvalidDetIndex:
2199 throw std::invalid_argument(
"MatrixWorkspace: SpectrumDefinition contains an out-of-range "
2200 "detector index, i.e., the spectrum definition does not match "
2201 "the instrument in the workspace.");
2202 case ErrorCode::InvalidTimeIndex:
2203 throw std::invalid_argument(
"MatrixWorkspace: SpectrumDefinition contains an out-of-range "
2204 "time index for a detector, i.e., the spectrum definition does "
2205 "not match the instrument in the workspace.");
2206 case ErrorCode::None:;
2217IPropertyManager::getValue<Mantid::API::MatrixWorkspace_sptr>(
const std::string &
name)
const {
2222 std::string message =
2223 "Attempt to assign property " +
name +
" to incorrect type. Expected shared_ptr<MatrixWorkspace>.";
2224 throw std::runtime_error(message);
2230IPropertyManager::getValue<Mantid::API::MatrixWorkspace_const_sptr>(
const std::string &
name)
const {
2231 auto const *prop =
dynamic_cast<PropertyWithValue<Mantid::API::MatrixWorkspace_sptr> *
>(getPointerToProperty(
name));
2233 return prop->operator()();
2235 std::string message =
2236 "Attempt to assign property " +
name +
" to incorrect type. Expected const shared_ptr<MatrixWorkspace>.";
2237 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 std::shared_ptr< Kernel::Unit > & 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.
std::string YUnitLabel(bool useLatex=false, bool plotAsDistribution=false) const
Returns a caption for the units of the data in the workspace.
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.
const MantidVec & readE(std::size_t const index) const
Deprecated, use e() instead.
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.
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.
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.
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.
void setImage(MantidVec &(MatrixWorkspace::*dataVec)(const std::size_t), const MantidImage &image, size_t start, bool parallelExecution)
Copy data from an image.
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.
virtual MantidVec & dataE(const std::size_t index)
Deprecated, use mutableE() instead. Returns the error data.
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).
virtual Kernel::cow_ptr< HistogramData::HistogramX > refX(const std::size_t index) const
Deprecated, use sharedX() instead. Returns a pointer to the x data.
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.
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.
const MantidVec & readY(std::size_t const index) const
Deprecated, use y() instead.
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.
const MantidVec & readX(std::size_t const index) const
Deprecated, use x() instead.
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 void getXMinMax(double &xmin, double &xmax) const
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.
MantidImage_sptr getImage(const MantidVec &(MatrixWorkspace::*read)(std::size_t const) const, size_t start, size_t stop, size_t width, size_t indexStart, size_t indexEnd) const
Create an MantidImage instance.
virtual MantidVec & dataY(const std::size_t index)
Deprecated, use mutableY() instead. Returns the y data.
const std::string toString() const override
String description of state.
HistogramData::HistogramY & mutableY(const size_t index) &
Mantid::Kernel::SpecialCoordinateSystem getSpecialCoordinateSystem() const override
void setYUnitLabel(const std::string &newLabel)
Sets a new caption for the data (Y axis) in the workspace.
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 indexOfValueFromCenters(const std::vector< double > &bin_centers, const double value)
Gets the bin of a value from a vector of bin centers and throws exception if out of range.
size_t MANTID_KERNEL_DLL indexOfValueFromEdges(const std::vector< double > &bin_edges, const double value)
Gets the bin of a value from a vector of bin edges.
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.