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 std::vector<detid_t> pixelIDs = this->
getInstrument()->getDetectorIDs(!includeMonitors);
443 std::vector<detid_t>::const_iterator iend = pixelIDs.end();
444 for (std::vector<detid_t>::const_iterator it = pixelIDs.begin(); it != iend; ++it) {
451 spec.setSpectrumNo(specNo);
452 spec.setDetectorID(detId);
458 }
catch (std::runtime_error &) {
470 throw std::runtime_error(
"MatrixWorkspace::getSpectrumToWorkspaceIndexMap: "
471 "axis[1] is not a SpectraAxis, so I cannot "
474 return ax->getSpectraIndexMap();
475 }
catch (std::runtime_error &) {
476 g_log.
error() <<
"MatrixWorkspace::getSpectrumToWorkspaceIndexMap: no elements!";
492 throw std::runtime_error(
"MatrixWorkspace::getSpectrumToWorkspaceIndexMap: "
493 "axis[1] is not a SpectraAxis, so I cannot "
497 specnum_t min = std::numeric_limits<specnum_t>::max();
499 specnum_t max = -std::numeric_limits<specnum_t>::max();
502 size_t length = ax->length();
503 for (
size_t i = 0; i < length; i++) {
515 std::vector<size_t> out(max - min + 1, 0);
518 for (
size_t i = 0; i < length; i++) {
520 out[spec + offset] = i;
533 for (
size_t workspaceIndex = 0; workspaceIndex < this->
getNumberHistograms(); workspaceIndex++) {
535 if (detList.size() > 1) {
557 bool ignoreIfNoValidDets)
const {
562 for (
size_t workspaceIndex = 0; workspaceIndex < this->
getNumberHistograms(); ++workspaceIndex) {
564 if (ignoreIfNoValidDets && !specInfo.hasDetectors(workspaceIndex)) {
569 if (throwIfMultipleDets) {
570 if (detList.size() > 1) {
571 throw std::runtime_error(
"MatrixWorkspace::getDetectorIDToWorkspaceIndexMap(): more than 1 "
572 "detector for one histogram! I cannot generate a map of detector "
573 "ID to workspace index.");
577 if (detList.size() == 1)
578 map[*detList.begin()] = workspaceIndex;
581 for (
auto det : detList)
582 map[det] = workspaceIndex;
604 bool throwIfMultipleDets)
const {
606 std::vector<size_t> out;
611 const int outSize = maxId - minId + 1;
613 out.resize(outSize, std::numeric_limits<size_t>::max());
615 for (
size_t workspaceIndex = 0; workspaceIndex <
getNumberHistograms(); ++workspaceIndex) {
619 if (throwIfMultipleDets && (detList.size() > 1))
620 throw std::runtime_error(
"MatrixWorkspace::getDetectorIDToWorkspaceIndexVector(): more than 1 "
621 "detector for one histogram! I cannot generate a map of detector ID "
622 "to workspace index.");
626 for (
auto det : detList) {
627 int index = det + offset;
628 if (index < 0 || index >= outSize) {
629 g_log.
debug() <<
"MatrixWorkspace::getDetectorIDToWorkspaceIndexVector("
630 "): detector ID found ("
631 << det <<
" at workspace index " << workspaceIndex <<
") is invalid.\n";
634 out[
index] = workspaceIndex;
649 std::vector<size_t> indexList;
652 auto iter = spectraList.cbegin();
653 while (iter != spectraList.cend()) {
656 indexList.emplace_back(i);
676 throw std::runtime_error(
"Could not find spectrum number in any spectrum.");
692 throw std::runtime_error(
"MatrixWorkspace: Using getIndicesFromDetectorIDs "
693 "in a parallel run is most likely incorrect. "
697 std::set<detid_t> detIdSet(detIdList.cbegin(), detIdList.cend());
700 std::map<detid_t, std::set<size_t>> detectorIDtoWSIndices;
702 for (
size_t i = 0; i < NUM_HIST; ++i) {
704 for (
const auto &detID : detIDs) {
706 if (detIdSet.count(detID) > 0) {
707 detectorIDtoWSIndices[detID].insert(i);
713 std::vector<size_t> indexList;
714 indexList.reserve(detIdList.size());
715 for (
const auto &detId : detIdList) {
716 const auto wsIndices = detectorIDtoWSIndices.find(detId);
717 if (wsIndices != detectorIDtoWSIndices.end()) {
718 std::copy(wsIndices->second.cbegin(), wsIndices->second.cend(), std::back_inserter(indexList));
733 std::vector<specnum_t> spectraList;
736 for (
auto detId : detIdList) {
737 bool foundDet =
false;
750 spectraList.emplace_back(foundSpecNum);
771 xmin = std::numeric_limits<double>::max();
776 for (
size_t workspaceIndex = 0; workspaceIndex < numberOfSpectra; workspaceIndex++) {
777 const auto &xData = this->
x(workspaceIndex);
778 const double xfront = xData.front();
779 const double xback = xData.back();
780 if (std::isfinite(xfront) && std::isfinite(xback)) {
803 const bool entireRange)
const {
811 for (
int wksp_index = 0; wksp_index < static_cast<int>(this->
getNumberHistograms()); wksp_index++) {
814 const auto &yData = this->
y(wksp_index);
816 if ((xData.size() <= 1 + histogramOffset) && (!yData.empty())) {
817 out[wksp_index] = yData[0];
820 Mantid::MantidVec::const_iterator lowit, highit;
821 lowit = xData.begin();
822 highit = xData.end() - histogramOffset;
828 lowit = std::lower_bound(xData.begin(), xData.end(), minX);
830 if (*(highit - 1 + histogramOffset) > maxX)
831 highit = std::upper_bound(lowit, xData.end(), maxX);
835 Mantid::MantidVec::difference_type distmin = std::distance(xData.begin(), lowit);
836 Mantid::MantidVec::difference_type distmax = std::distance(xData.begin(), highit);
838 if (distmin <= distmax) {
840 sum = std::accumulate(yData.begin() + distmin, yData.begin() + distmax, 0.0, accumulate_if_finite);
843 out[wksp_index] = sum;
849 const double minX,
const double maxX,
850 const bool entireRange)
const {
851 std::vector<double> integratedSpectra;
853 std::vector<double> detectorCounts;
854 std::transform(workspaceIndices.cbegin(), workspaceIndices.cend(), std::back_inserter(detectorCounts),
855 [&](
const auto &wsIndex) { return integratedSpectra[wsIndex]; });
856 return detectorCounts;
871 if (!localInstrument) {
876 const size_t ndets = dets.size();
879 return localInstrument->getDetector(*dets.begin());
880 }
else if (ndets == 0) {
882 "detectors for this workspace "
887 auto dets_ptr = localInstrument->getDetectors(dets);
888 return std::make_shared<Geometry::DetectorGroup>(dets_ptr);
903 if (source ==
nullptr ||
sample ==
nullptr) {
905 "Instrument not sufficiently defined: failed to get source and/or "
910 const Kernel::V3D beamLine = samplePos - source->getPos();
916 const V3D &thetaSignAxis = instrument->getReferenceFrame()->vecThetaSign();
931 if (source ==
nullptr ||
sample ==
nullptr) {
933 "Instrument not sufficiently defined: failed to get source and/or "
938 const Kernel::V3D beamLine = samplePos - source->getPos();
956 if (axisIndex >=
m_axes.size()) {
960 return m_axes[axisIndex].get();
974 if (axisIndex >=
m_axes.size()) {
978 m_axes[axisIndex] = std::move(newAxis);
994 const auto &x0 = this->
x(0);
1000 if (x0[1] == x0[0]) {
1004 double diff = x0[1] / x0[0];
1005 if (!std::isfinite(diff)) {
1009 for (
size_t i = 1; i < x0.size() - 2; ++i) {
1010 if (std::isfinite(x0[i + 1]) && std::isfinite(x0[i])) {
1011 if (std::abs(x0[i + 1] / x0[i] - diff) >
EPSILON) {
1045 retVal = appendUnitDenominatorUsingPer(retVal, *
this, useLatex);
1053 retVal = appendUnitDenominatorUsingPer(retVal, *
this, useLatex);
1056 retVal = replacePerWithLatex(retVal);
1068 return getSpectrum(0).
yMode() == HistogramData::Histogram::YMode::Frequencies;
1076 HistogramData::Histogram::YMode ymode =
1077 newValue ? HistogramData::Histogram::YMode::Frequencies : HistogramData::Histogram::YMode::Counts;
1102 throw std::logic_error(
"In MatrixWorkspace::isHistogramData(): "
1103 "Histogram::Xmode is not BinEdges");
1107 throw std::logic_error(
"In MatrixWorkspace::isHistogramData(): "
1108 "Histogram::Xmode is not Points");
1132 const HistogramData::HistogramX *first = &
x(0);
1133 for (
size_t i = 1; i < numHist; ++i) {
1134 if (&
x(i) != first) {
1147 const size_t numBins =
x(0).size();
1148 for (
size_t i = 1; i < numHist; ++i) {
1149 if (
x(i).
size() != numBins) {
1155 const auto &x0 =
x(0);
1158 for (
int i = 1; i < static_cast<int>(numHist); ++i) {
1160 const auto specIndex =
static_cast<std::size_t
>(i);
1161 const auto &xi =
x(specIndex);
1162 for (
size_t j = 0; j < numBins; ++j) {
1163 const double a = x0[j];
1164 const double b = xi[j];
1166 if (std::isfinite(a) && std::isfinite(b)) {
1167 if (std::abs(a - b) >
EPSILON) {
1172 }
else if ((std::isnan(a) != std::isnan(b)) || (std::isinf(a) != std::isinf(b))) {
1190 const HistogramData::HistogramX bins =
x(0);
1192 for (
size_t i = 0; i < bins.size(); ++i) {
1193 if (std::trunc(bins[i]) != bins[i])
1217 "MatrixWorkspace::maskBin,workspaceIndex");
1219 if (binIndex >=
y(workspaceIndex).
size())
1223 flagMasked(workspaceIndex, binIndex, weight);
1233 double &yData = this->
mutableY(workspaceIndex)[binIndex];
1234 (std::isnan(yData) || std::isinf(yData)) ? yData = 0. : yData *= (1 - weight);
1235 double &eData = this->
mutableE(workspaceIndex)[binIndex];
1236 (std::isnan(eData) || std::isinf(eData)) ? eData = 0. : eData *= (1 - weight);
1254 binList[binIndex] = weight;
1282 auto it =
m_masks.find(workspaceIndex);
1293 auto it =
m_masks.find(workspaceIndex);
1300 auto maskedBinsList = it->second;
1301 std::vector<size_t> maskedIds;
1302 maskedIds.reserve(maskedBinsList.size());
1304 std::transform(maskedBinsList.begin(), maskedBinsList.end(), std::back_inserter(maskedIds),
1305 [](
const auto &mb) { return mb.first; });
1335 if (monitorWS.get() ==
this) {
1336 throw std::runtime_error(
"To avoid memory leak, monitor workspace"
1337 " can not be the same workspace as the host workspace");
1359 auto lastX = this->
refX(0);
1361 auto X = this->
refX(wi);
1363 if (!(
X == lastX) || wi == 0)
1364 total += (*X).size() *
sizeof(double);
1398 [[maybe_unused]]
const double tolerance)
const {
1400 throw std::out_of_range(
"MatrixWorkspace::yIndexOfX - Index out of range.");
1402 const auto &xValues = this->
x(index);
1403 const bool ascendingOrder = xValues.front() < xValues.back();
1404 const auto minX = ascendingOrder ? xValues.front() : xValues.back();
1405 const auto maxX = ascendingOrder ? xValues.back() : xValues.front();
1408 if (xValue < minX || xValue > maxX)
1409 throw std::out_of_range(
"MatrixWorkspace::yIndexOfX - X value is out of "
1410 "the range of the min and max bin edges.");
1414 if (xValue < minX - tolerance || xValue > maxX +
tolerance)
1415 throw std::out_of_range(
"MatrixWorkspace::yIndexOfX - X value is out of "
1416 "range for this point data.");
1430 const bool ascendingOrder)
const {
1432 if (ascendingOrder) {
1433 auto lowerIter = std::lower_bound(xValues.cbegin(), xValues.cend(), xValue);
1436 if (lowerIter == xValues.cbegin())
1439 hops = std::distance(xValues.cbegin(), lowerIter);
1441 auto lowerIter = std::lower_bound(xValues.crbegin(), xValues.crend(), xValue);
1443 if (lowerIter == xValues.crbegin())
1446 hops = xValues.size() - std::distance(xValues.crbegin(), lowerIter);
1463 auto const iter = std::find_if(xValues.cbegin(), xValues.cend(), [&xValue, &
tolerance](
double const &
value) {
1464 return std::abs(xValue - value) <= tolerance;
1466 if (iter != xValues.cend())
1467 return std::distance(xValues.cbegin(), iter);
1469 throw std::invalid_argument(
"MatrixWorkspace::yIndexOfX - the X value provided could not be found "
1470 "in the workspace containing point data.");
1482 if (0 == axisIndex) {
1484 }
else if (1 == axisIndex) {
1487 throw std::invalid_argument(
"Cannot have an index for a MatrixWorkspace "
1488 "axis that is not == 0 or == 1");
1504 if (unit && unit->unitID() !=
"Empty")
1505 return unit->caption();
1541 throw std::runtime_error(
"Not implemented");
1558 std::string
toXMLString()
const override {
throw std::runtime_error(
"Not implemented"); }
1579 m_ws->getAxis(0)->unit()->label())) {}
1584 const auto &unit = axis->
unit();
1585 if (unit && unit->unitID() !=
"Empty")
1586 return unit->caption();
1588 return axis->title();
1617 throw std::runtime_error(
"Not implemented");
1624 std::string
toXMLString()
const override {
throw std::runtime_error(
"Not implemented"); }
1641 return std::make_shared<MWXDimension>(
this,
xDimensionId);
1642 }
else if (
index == 1) {
1644 return std::make_shared<MWDimension>(yAxis,
yDimensionId);
1646 throw std::invalid_argument(
"MatrixWorkspace only has 2 dimensions.");
1650 int nAxes = this->
axes();
1651 std::shared_ptr<IMDDimension> dim;
1652 for (
int i = 0; i < nAxes; i++) {
1654 if (knownId ==
id) {
1655 dim = std::make_shared<MWDimension>(this->
getAxis(i),
id);
1660 if (
nullptr == dim) {
1661 std::string message =
"Cannot find id : " +
id;
1662 throw std::overflow_error(message);
1674std::vector<std::unique_ptr<IMDIterator>>
1677 size_t numCores = suggestedNumCores;
1681 if (numCores > numElements)
1682 numCores = numElements;
1687 std::vector<std::unique_ptr<IMDIterator>> out;
1688 for (
size_t i = 0; i < numCores; i++) {
1689 size_t begin = (i * numElements) / numCores;
1690 size_t end = ((i + 1) * numElements) / numCores;
1691 if (end > numElements)
1693 out.emplace_back(std::make_unique<MatrixWorkspaceMDIterator>(
this, function, begin, end));
1724 if (this->
axes() != 2)
1725 throw std::invalid_argument(
"MatrixWorkspace::getSignalAtCoord() - "
1726 "Workspace can only have 2 axes, found " +
1734 }
catch (std::out_of_range &) {
1735 return std::numeric_limits<double>::quiet_NaN();
1739 const auto &yVals = this->
y(wi);
1740 double yBinSize(1.0);
1743 double currentVertical = ax1->operator()(wi, uVI);
1744 if (wi + 1 == nhist && nhist > 1)
1746 yBinSize = currentVertical - ax1->operator()(wi - 1, uVI);
1748 yBinSize = ax1->operator()(wi + 1, uVI) - currentVertical;
1753 const auto &xVals =
x(wi);
1761 }
catch (std::out_of_range &) {
1762 return std::numeric_limits<double>::quiet_NaN();
1765 double yVal = yVals[i];
1767 switch (normalization) {
1772 auto volume = yBinSize * (xVals[i + 1] - xVals[i]);
1773 if (volume == 0.0) {
1774 return std::numeric_limits<double>::quiet_NaN();
1776 return yVal / volume;
1785 return std::numeric_limits<double>::quiet_NaN();
1806 throw std::runtime_error(
"MatrixWorkspace::setMDMasking has no implementation");
1813 throw std::runtime_error(
"MatrixWorkspace::clearMDMasking has no implementation");
1837 size_t start, size_t stop, size_t width, size_t indexStart,
1838 size_t indexEnd) const {
1841 throw std::runtime_error(
"Cannot create image with width 0");
1844 size_t nHist = getNumberHistograms();
1852 throw std::runtime_error(
"Cannot create image for an empty data set.");
1855 if (start >= nHist) {
1856 throw std::runtime_error(
"Cannot create image: start index is out of range");
1859 if (stop >= nHist) {
1860 throw std::runtime_error(
"Cannot create image: stop index is out of range");
1864 size_t dataSize = stop - start + 1;
1865 size_t height = dataSize / width;
1868 if (
height * width != dataSize) {
1869 throw std::runtime_error(
"Cannot create image: the data set cannot form a rectangle.");
1872 size_t nBins = blocksize();
1873 bool isHisto = isHistogramData();
1876 if (indexEnd == 0) {
1878 if (!isHisto && indexEnd > 0)
1883 if (indexEnd < indexStart) {
1884 throw std::runtime_error(
"Cannot create image for an empty data set.");
1887 if (indexStart >= nBins || indexEnd > nBins || (!isHisto && indexEnd == nBins)) {
1888 throw std::runtime_error(
"Cannot create image: integration interval is out of range.");
1892 auto image = std::make_shared<MantidImage>(
height);
1897 if (isHisto && indexEnd == indexStart + 1) {
1899 for (
int i = 0; i < static_cast<
int>(
height); ++i) {
1900 auto &row = (*image)[i];
1902 size_t spec = start +
static_cast<size_t>(i) * width;
1903 for (
size_t j = 0; j < width; ++j, ++spec) {
1904 row[j] = (this->*read)(spec)[indexStart];
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 auto &V = (this->*read)(spec);
1916 row[j] = std::accumulate(V.begin() + indexStart, V.begin() + indexEnd, 0.0);
1925 std::pair<int64_t, int64_t> out(-1, -1);
1927 if (std::isnan(
value)) {
1928 for (int64_t i = idx.first; i < numHists; ++i) {
1929 const auto &
Y = this->
y(i);
1930 if (
auto it = std::find_if(std::next(
Y.begin(), idx.second),
Y.end(), [](
double v) { return std::isnan(v); });
1932 out = {i, std::distance(
Y.begin(), it)};
1937 for (int64_t i = idx.first; i < numHists; ++i) {
1938 const auto &
Y = this->
y(i);
1939 if (
auto it = std::find(std::next(
Y.begin(), idx.second),
Y.end(),
value); it !=
Y.end()) {
1940 out = {i, std::distance(
Y.begin(), it)};
1956 startX =
x(i).front();
1957 auto pStart =
getXIndex(i, startX,
true);
1958 if (pStart.second != 0.0) {
1959 throw std::runtime_error(
"Start X value is required to be on bin boundary.");
1963 auto pEnd =
getXIndex(i, endX,
false, pStart.first);
1964 if (pEnd.second != 0.0) {
1965 throw std::runtime_error(
"End X value is required to be on bin boundary.");
1967 return std::make_pair(pStart.first, pEnd.first);
2009 auto &
X = this->
x(i);
2014 return std::make_pair(nx, 0.0);
2015 if (start > 0 && start == nx - 1) {
2018 return std::make_pair(start, 0.0);
2019 return std::make_pair(nx, 0.0);
2026 return x <=
X[start] ? std::make_pair(start, 0.0) : std::make_pair(nx, 0.0);
2027 return x >=
X[start] ? std::make_pair(start, 0.0) : std::make_pair(nx, 0.0);
2031 if (
x <=
X[start]) {
2032 return isLeft ? std::make_pair(start, 0.0) : std::make_pair(nx, 0.0);
2035 if (
x >=
X.back()) {
2036 return !isLeft ? std::make_pair(nx - 1, 0.0) : std::make_pair(nx, 0.0);
2041 for (
auto ix =
X.begin() + start + 1; ix != end; ++ix) {
2043 auto index =
static_cast<size_t>(std::distance(
X.begin(), ix));
2046 return std::make_pair(
index, std::abs((
X[
index] -
x) / (*ix - *(ix - 1))));
2050 return std::make_pair(nx, 0.0);
2062 size_t start, [[maybe_unused]] bool parallelExecution) {
2066 if (image[0].empty())
2070 throw std::runtime_error(
"Cannot set image: a single bin workspace is expected.");
2073 size_t height = image.size();
2074 size_t width = image.front().size();
2075 size_t dataSize = width *
height;
2078 throw std::runtime_error(
"Cannot set image: image is bigger than workspace.");
2082 for (
int i = 0; i < static_cast<int>(
height); ++i) {
2083 auto &row = image[i];
2084 if (row.size() != width) {
2085 throw std::runtime_error(
"Canot set image: image is corrupted.");
2087 size_t spec = start +
static_cast<size_t>(i) * width;
2088 auto rowEnd = row.end();
2089 for (
auto pixel = row.begin(); pixel != rowEnd; ++pixel, ++spec) {
2090 (this->*dataVec)(spec)[0] = *pixel;
2129 size_t numberOfDetectors{detInfo.size()};
2130 if (numberOfDetectors == 0) {
2135 size_t numberOfSpectra = numberOfDetectors * detInfo.scanCount();
2137 throw std::invalid_argument(
"MatrixWorkspace: IndexInfo does not contain spectrum definitions so "
2138 "building a 1:1 mapping from spectra to detectors was attempted, but "
2139 "the number of spectra in the workspace is not equal to the number of "
2140 "detectors in the instrument.");
2141 std::vector<SpectrumDefinition> specDefs(
m_indexInfo->size());
2142 if (!detInfo.isScanning() && (numberOfSpectra ==
m_indexInfo->size())) {
2143 for (
size_t i = 0; i < numberOfSpectra; ++i)
2146 size_t specIndex = 0;
2147 size_t globalSpecIndex = 0;
2148 for (
size_t detIndex = 0; detIndex < detInfo.size(); ++detIndex) {
2149 for (
size_t time = 0; time < detInfo.scanCount(); ++time) {
2150 if (
m_indexInfo->isOnThisPartition(Indexing::GlobalSpectrumIndex(globalSpecIndex++)))
2151 specDefs[specIndex++].add(detIndex, time);
2155 m_indexInfo->setSpectrumDefinitions(std::move(specDefs));
2160 const auto &allDetIDs = detInfo.detectorIDs();
2161 const auto &specDefs =
m_indexInfo->spectrumDefinitions();
2162 const auto indexInfoSize =
static_cast<int64_t
>(
m_indexInfo->size());
2163 enum class ErrorCode {
None, InvalidDetIndex, InvalidTimeIndex };
2164 std::atomic<ErrorCode> errorValue(ErrorCode::None);
2165#pragma omp parallel for
2166 for (int64_t i = 0; i < indexInfoSize; ++i) {
2169 spec.setMatrixWorkspace(
nullptr, i);
2171 std::set<detid_t> detIDs;
2172 for (
const auto &
index : (*specDefs)[i]) {
2173 const size_t detIndex =
index.first;
2174 const size_t timeIndex =
index.second;
2175 if (detIndex >= allDetIDs.size()) {
2176 errorValue = ErrorCode::InvalidDetIndex;
2177 }
else if (timeIndex >= detInfo.scanCount()) {
2178 errorValue = ErrorCode::InvalidTimeIndex;
2180 detIDs.insert(allDetIDs[detIndex]);
2183 spec.setDetectorIDs(std::move(detIDs));
2185 switch (errorValue) {
2186 case ErrorCode::InvalidDetIndex:
2187 throw std::invalid_argument(
"MatrixWorkspace: SpectrumDefinition contains an out-of-range "
2188 "detector index, i.e., the spectrum definition does not match "
2189 "the instrument in the workspace.");
2190 case ErrorCode::InvalidTimeIndex:
2191 throw std::invalid_argument(
"MatrixWorkspace: SpectrumDefinition contains an out-of-range "
2192 "time index for a detector, i.e., the spectrum definition does "
2193 "not match the instrument in the workspace.");
2194 case ErrorCode::None:;
2205IPropertyManager::getValue<Mantid::API::MatrixWorkspace_sptr>(
const std::string &
name)
const {
2210 std::string message =
2211 "Attempt to assign property " +
name +
" to incorrect type. Expected shared_ptr<MatrixWorkspace>.";
2212 throw std::runtime_error(message);
2218IPropertyManager::getValue<Mantid::API::MatrixWorkspace_const_sptr>(
const std::string &
name)
const {
2219 auto const *prop =
dynamic_cast<PropertyWithValue<Mantid::API::MatrixWorkspace_sptr> *
>(getPointerToProperty(
name));
2221 return prop->operator()();
2223 std::string message =
2224 "Attempt to assign property " +
name +
" to incorrect type. Expected const shared_ptr<MatrixWorkspace>.";
2225 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 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.
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.