13#include "MantidHistogramData/HistogramDx.h"
14#include "MantidHistogramData/HistogramE.h"
15#include "MantidHistogramData/HistogramX.h"
16#include "MantidHistogramData/HistogramY.h"
17#include "MantidIndexing/IndexInfo.h"
30#include <boost/python/class.hpp>
31#include <boost/python/copy_const_reference.hpp>
32#include <boost/python/dict.hpp>
33#include <boost/python/implicit.hpp>
34#include <boost/python/list.hpp>
35#include <boost/python/overloads.hpp>
36#include <boost/python/register_ptr_to_python.hpp>
37#include <boost/python/suite/indexing/map_indexing_suite.hpp>
38#include <boost/python/tuple.hpp>
40#define PY_ARRAY_UNIQUE_SYMBOL API_ARRAY_API
41#define NO_IMPORT_ARRAY
42#include <numpy/arrayobject.h>
60using return_readonly_numpy = return_value_policy<VectorRefToNumpy<WrapReadOnly>>;
62using return_readwrite_numpy = return_value_policy<VectorRefToNumpy<WrapReadWrite>>;
73BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(MatrixWorkspace_YUnitLabelOverloads, YUnitLabel, 0, 1)
86void setSpectrumFromPyObject(
MatrixWorkspace &self, data_modifier accessor,
const size_t wsIndex,
87 const boost::python::object &values) {
90 converter.
copyTo((self.*accessor)(wsIndex));
93 converter.
copyTo((self.*accessor)(wsIndex));
132 const auto &spectrumNums = self.
indexInfo().spectrumNumbers();
135 for (
const auto &
index : spectrumNums) {
136 spectra.append(
static_cast<int32_t
>(
index));
176 PyErr_Warn(PyExc_DeprecationWarning,
177 "`MatrixWorkspace.readX()` is deprecated in Mantid 7.0, use `MatrixWorkspace.x()` instead. "
178 "For more information, see the Histogram data concept page: "
179 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
180 return xData(self,
index);
190 PyErr_Warn(PyExc_DeprecationWarning,
191 "`MatrixWorkspace.readY()` is deprecated in Mantid 7.0, use `MatrixWorkspace.y()` instead. "
192 "For more information, see the Histogram data concept page: "
193 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
194 return yData(self,
index);
204 PyErr_Warn(PyExc_DeprecationWarning,
205 "`MatrixWorkspace.readE()` is deprecated in Mantid 7.0, use `MatrixWorkspace.e()` instead. "
206 "For more information, see the Histogram data concept page: "
207 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
208 return eData(self,
index);
218 PyErr_Warn(PyExc_DeprecationWarning,
219 "`MatrixWorkspace.readDx()` is deprecated in Mantid 7.0, use `MatrixWorkspace.dx()` instead. "
220 "For more information, see the Histogram data concept page: "
221 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
222 return dxData(self,
index);
232 PyErr_Warn(PyExc_DeprecationWarning,
233 "`MatrixWorkspace.dataX()` is deprecated in Mantid 7.0, use `MatrixWorkspace.mutableX()` instead. "
234 "For more information, see the Histogram data concept page: "
235 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
236 return mutableXData(self,
index);
246 PyErr_Warn(PyExc_DeprecationWarning,
247 "`MatrixWorkspace.dataY()` is deprecated in Mantid 7.0, use `MatrixWorkspace.mutableY()` instead. "
248 "For more information, see the Histogram data concept page: "
249 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
250 return mutableYData(self,
index);
260 PyErr_Warn(PyExc_DeprecationWarning,
261 "`MatrixWorkspace.dataE()` is deprecated in Mantid 7.0, use `MatrixWorkspace.mutableE()` instead. "
262 "For more information, see the Histogram data concept page: "
263 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
264 return mutableEData(self,
index);
274 PyErr_Warn(PyExc_DeprecationWarning,
275 "`MatrixWorkspace.dataDx()` is deprecated in Mantid 7.0, use `MatrixWorkspace.mutableDx()` instead. "
276 "For more information, see the Histogram data concept page: "
277 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
278 return mutableDxData(self,
index);
287void setXFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
297void setYFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
307void setEFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
317void setDxFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
327void setXDeprecated(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
328 PyErr_Warn(PyExc_DeprecationWarning,
329 "`MatrixWorkspace.setX()` is deprecated in Mantid 7.0, use `MatrixWorkspace.setSharedX()` instead. "
330 "For more information, see the Histogram data concept page: "
331 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
332 setXFromPyObject(self, wsIndex, values);
341void setYDeprecated(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
342 PyErr_Warn(PyExc_DeprecationWarning,
343 "`MatrixWorkspace.setY()` is deprecated in Mantid 7.0, use `MatrixWorkspace.setSharedY()` instead. "
344 "For more information, see the Histogram data concept page: "
345 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
346 setYFromPyObject(self, wsIndex, values);
355void setEDeprecated(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
356 PyErr_Warn(PyExc_DeprecationWarning,
357 "`MatrixWorkspace.setE()` is deprecated in Mantid 7.0, use `MatrixWorkspace.setSharedE()` instead. "
358 "For more information, see the Histogram data concept page: "
359 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
360 setEFromPyObject(self, wsIndex, values);
369void setDxDeprecated(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
370 PyErr_Warn(PyExc_DeprecationWarning,
371 "`MatrixWorkspace.setDx()` is deprecated in Mantid 7.0, use `MatrixWorkspace.setSharedDx()` instead. "
372 "For more information, see the Histogram data concept page: "
373 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
374 setDxFromPyObject(self, wsIndex, values);
382std::vector<double> extractVectorFromPyObject(
const boost::python::object &values) {
395void setSharedXFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
396 self.
setSharedX(wsIndex, make_cow<Mantid::HistogramData::HistogramX>(extractVectorFromPyObject(values)));
405void setSharedYFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
406 self.
setSharedY(wsIndex, make_cow<Mantid::HistogramData::HistogramY>(extractVectorFromPyObject(values)));
415void setSharedEFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
416 self.
setSharedE(wsIndex, make_cow<Mantid::HistogramData::HistogramE>(extractVectorFromPyObject(values)));
425void setSharedDxFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
426 self.
setSharedDx(wsIndex, make_cow<Mantid::HistogramData::HistogramDx>(extractVectorFromPyObject(values)));
429std::vector<double> getIntegratedCountsForWorkspaceIndices(
MatrixWorkspace &self,
430 const boost::python::object &workspaceIndices,
431 const size_t numberOfWorkspaces,
const double minX,
432 const double maxX,
const bool entireRange) {
434 std::vector<size_t> sWorkspaceIndices(numberOfWorkspaces);
437 converter.
copyTo(sWorkspaceIndices);
440 converter.
copyTo(sWorkspaceIndices);
453 PyErr_Warn(PyExc_DeprecationWarning,
"``getSampleDetails`` is deprecated, use ``getRun`` instead.");
464 PyErr_Warn(PyExc_DeprecationWarning,
"``getNumberBins`` is deprecated, use ``blocksize`` instead.");
478std::size_t binIndexOfDeprecated(
MatrixWorkspace &self,
const double xValue,
const std::size_t
index = 0) {
479 PyErr_Warn(PyExc_DeprecationWarning,
"``binIndexOf`` is deprecated, use ``yIndexOfX`` instead.");
488BOOST_PYTHON_FUNCTION_OVERLOADS(binIndexOfDeprecatedOverloads, binIndexOfDeprecated, 2, 3)
508void pythonReplaceAxis(
MatrixWorkspace &self,
const std::size_t &axisIndex,
Axis *newAxis) {
522 throw std::invalid_argument(
"MatrixWorkspace::getSignalAtCoord - Input "
523 "array must have shape (n, 2)");
526 Py_intptr_t length = len(npCoords);
533 for (
int i = 0; i < length; ++i) {
534 std::array<Mantid::coord_t, 2> coord = {{coords[2 * i], coords[2 * i + 1]}};
537 PyObject *npSignalArray =
539 return object(handle<>(npSignalArray));
543 int64_t first = extract<int64_t>(start[0]);
544 int64_t second = extract<int64_t>(start[1]);
545 auto idx = self.
findY(
value, std::make_pair(first, second));
546 return make_tuple(idx.first, idx.second);
558 const size_t setIndex) {
571 const size_t setIndex) {
575std::vector<size_t> getIndicesFromDetectorIDs(
MatrixWorkspace &self,
const boost::python::list &detIDs) {
579boost::python::dict getDetectorIDToWorkspaceIndexMap(
MatrixWorkspace &self,
bool throwIfMultipleDets,
580 bool ignoreIfNoValidDets) {
582 boost::python::dict pythonDict;
583 for (
const auto &[key,
value] : unorderedMap) {
584 pythonDict[key] =
value;
597 class_<MatrixWorkspace, boost::python::bases<ExperimentInfo, IMDWorkspace>, boost::noncopyable>(
"MatrixWorkspace",
602 "Returns true if the workspace is ragged (has differently sized "
606 "Returns the number of bins for a given histogram index.")
607 .def(
"getNumberBins", &getNumberBinsDeprecated, arg(
"self"),
608 "Returns size of the Y data array (deprecated, use "
609 ":class:`~mantid.api.MatrixWorkspace.blocksize` "
612 "Returns the maximum number of bins in a workspace (works on ragged "
615 "Returns the number of spectra in the workspace")
619 .def(
"getSpectrumNumbers", &getSpectrumNumbers, arg(
"self"),
620 "Returns a list of all spectrum numbers in the workspace")
622 MatrixWorkspace_yIndexOfXOverloads((arg(
"self"), arg(
"xvalue"), arg(
"workspaceIndex"), arg(
"tolerance")),
623 "Returns the y index which corresponds to the X Value provided. "
624 "The workspace_index [default=0] and tolerance [default=0.0] is "
627 "Returns the two theta value for a given detector")
629 "Returns the signed two theta value for given detector")
631 (arg(
"self"), arg(
"workspaceIndex")), return_internal_reference<>(),
632 "Return the spectra at the given workspace index.")
634 "Returns workspace index correspondent to the given spectrum "
635 "number. Throws if no such spectrum is present in the workspace")
636 .def(
"getIndicesFromDetectorIDs", &getIndicesFromDetectorIDs, (arg(
"self"), arg(
"detID_list")),
637 "Returns a list of workspace indices from the corrresponding "
639 .def(
"getDetectorIDToWorkspaceIndexMap", &getDetectorIDToWorkspaceIndexMap,
640 (arg(
"self"), arg(
"throwIfMultipleDets"), arg(
"ignoreIfNoValidDets")),
641 " Return a map where the key is detector ID (pixel ID), and the value at that index = the corresponding "
644 (arg(
"self"), arg(
"workspaceIndex")),
645 "Return the :class:`~mantid.geometry.Detector` or "
646 ":class:`~mantid.geometry.DetectorGroup` that is linked to "
647 "the given workspace index")
649 "Return the :class:`~mantid.api.Run` object for this workspace")
650 .def(
"axes", &
MatrixWorkspace::axes, arg(
"self"),
"Returns the number of axes attached to the workspace")
652 "Get a pointer to a workspace axis")
654 "Returns ``True`` if this is considered to be binned data.")
656 "Returns the status of the distribution flag")
658 "Returns the current Y unit for the data (Y axis) in the workspace")
660 MatrixWorkspace_YUnitLabelOverloads((arg(
"self"), arg(
"useLatex")),
"Returns the caption for the Y axis"))
662 "Returns true if any of the bins in this workspace are masked.")
664 "Returns true if this spectrum contains any masked bins")
665 .def(
"maskedBinsIndices", &maskedBinsIndices, (arg(
"self"), arg(
"workspaceIndex")),
666 "Returns all the masked bins' indices at the workspace index. "
667 ":class:`~mantid.api.MatrixWorkspace.hasMaskedBins` MUST be called "
668 "first to check if any bins are "
669 "masked, otherwise an exception will be thrown")
670 .def(
"findY", &findY, (arg(
"self"), arg(
"value"), arg(
"start") = make_tuple(0, 0)),
671 "Find first index in Y equal to value. Start may be specified to "
672 "begin at a specifc index. Returns tuple with the "
673 "histogram and bin indices.")
674 .def(
"getSampleDetails", &getSampleDetailsDeprecated, arg(
"self"), return_internal_reference<>(),
675 "Return the Run object for this workspace (deprecated, use "
676 ":class:`~mantid.api.MatrixWorkspace.getRun` "
678 .def(
"binIndexOf", &binIndexOfDeprecated,
679 binIndexOfDeprecatedOverloads((arg(
"self"), arg(
"xvalue"), arg(
"workspaceIndex")),
680 "Returns the index of the bin containing the given xvalue "
682 ":class:`~mantid.api.MatrixWorkspace.yIndexOfX` instead)"))
687 "Sets a new plot type for the workspace")
689 "Sets the marker type for the workspace")
691 "Sets the size of the marker for the workspace")
693 "Sets a new caption for the data (Y axis) in the workspace")
695 "Sets a new unit for the data (Y axis) in the workspace")
697 "Set distribution flag. If True the workspace has been divided by "
699 .def(
"replaceAxis", &pythonReplaceAxis, (arg(
"self"), arg(
"axisIndex"), arg(
"newAxis")),
700 "Replaces one of the workspace's axes with the new one provided. "
701 "The axis is cloned.")
702 .def(
"applyBinEdgesFromAnotherWorkspace", &applyBinEdgesFromAnotherWorkspace,
703 (arg(
"self"), arg(
"ws"), arg(
"getIndex"), arg(
"setIndex")),
704 "Sets the bin edges at setIndex to be the bin edges of ws at "
706 .def(
"applyPointsFromAnotherWorkspace", &applyPointsFromAnotherWorkspace,
707 (arg(
"self"), arg(
"ws"), arg(
"getIndex"), arg(
"setIndex")),
708 "Sets the points at setIndex to be the points of ws at getIndex.")
712 .def(
"x", &xData, return_readonly_numpy(), args(
"self",
"workspaceIndex"),
713 "Creates a read-only numpy wrapper around the X data at the given index")
714 .def(
"y", &yData, return_readonly_numpy(), args(
"self",
"workspaceIndex"),
715 "Creates a read-only numpy wrapper around the Y data at the given index")
716 .def(
"e", &eData, return_readonly_numpy(), args(
"self",
"workspaceIndex"),
717 "Creates a read-only numpy wrapper around the E data at the given index")
718 .def(
"dx", &dxData, return_readonly_numpy(), args(
"self",
"workspaceIndex"),
719 "Creates a read-only numpy wrapper around the Dx data at the given index. "
720 "If :class:`~mantid.api.MatrixWorkspace.hasDx` is False for this index, "
721 "the Dx data is first initialized to zeros.")
722 .def(
"readX", &readXDeprecated, (arg(
"self"), arg(
"workspaceIndex")), return_readonly_numpy(),
723 "Creates a read-only numpy wrapper "
724 "around the original X data at the "
725 "given index (deprecated, use "
726 ":class:`~mantid.api.MatrixWorkspace.x` instead)")
727 .def(
"readY", &readYDeprecated, return_readonly_numpy(), args(
"self",
"workspaceIndex"),
728 "Creates a read-only numpy wrapper "
729 "around the original Y data at the "
730 "given index (deprecated, use "
731 ":class:`~mantid.api.MatrixWorkspace.y` instead)")
732 .def(
"readE", &readEDeprecated, return_readonly_numpy(), args(
"self",
"workspaceIndex"),
733 "Creates a read-only numpy wrapper "
734 "around the original E data at the "
735 "given index (deprecated, use "
736 ":class:`~mantid.api.MatrixWorkspace.e` instead)")
737 .def(
"readDx", &readDxDeprecated, return_readonly_numpy(), args(
"self",
"workspaceIndex"),
738 "Creates a read-only numpy wrapper "
739 "around the original Dx data at the "
740 "given index (deprecated, use "
741 ":class:`~mantid.api.MatrixWorkspace.dx` instead)")
743 "Returns True if the spectrum uses the DX (X Error) array, else "
747 .def(
"mutableX", &mutableXData, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
748 "Creates a writable numpy wrapper around the X data at the given index")
749 .def(
"mutableY", &mutableYData, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
750 "Creates a writable numpy wrapper around the Y data at the given index. "
751 "Raises a RuntimeError for :class:`~mantid.api.IEventWorkspace`, since "
752 "non-const access to Y data is not possible for event data.")
753 .def(
"mutableE", &mutableEData, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
754 "Creates a writable numpy wrapper around the E data at the given index. "
755 "Raises a RuntimeError for :class:`~mantid.api.IEventWorkspace`, since "
756 "non-const access to E data is not possible for event data.")
757 .def(
"mutableDx", &mutableDxData, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
758 "Creates a writable numpy wrapper around the Dx data at the given index. "
759 "If :class:`~mantid.api.MatrixWorkspace.hasDx` is False for this index, "
760 "the Dx data is first initialized to zeros.")
761 .def(
"dataX", &dataXDeprecated, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
762 "Creates a writable numpy wrapper around the original X data at the "
763 "given index (deprecated, use "
764 ":class:`~mantid.api.MatrixWorkspace.mutableX` instead)")
765 .def(
"dataY", &dataYDeprecated, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
766 "Creates a writable numpy wrapper around the original Y data at the "
767 "given index (deprecated, use "
768 ":class:`~mantid.api.MatrixWorkspace.mutableY` instead)")
769 .def(
"dataE", &dataEDeprecated, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
770 "Creates a writable numpy wrapper around the original E data at the "
771 "given index (deprecated, use "
772 ":class:`~mantid.api.MatrixWorkspace.mutableE` instead)")
773 .def(
"dataDx", &dataDxDeprecated, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
774 "Creates a writable numpy wrapper around the original Dx data at "
775 "the given index (deprecated, use "
776 ":class:`~mantid.api.MatrixWorkspace.mutableDx` instead)")
777 .def(
"setX", &setXDeprecated, args(
"self",
"workspaceIndex",
"x"),
778 "Set X values from a python list or numpy array. It performs a "
779 "simple copy into the array (deprecated, use "
780 ":class:`~mantid.api.MatrixWorkspace.setSharedX` instead)")
781 .def(
"setY", &setYDeprecated, args(
"self",
"workspaceIndex",
"y"),
782 "Set Y values from a python list or numpy array. It performs a "
783 "simple copy into the array (deprecated, use "
784 ":class:`~mantid.api.MatrixWorkspace.setSharedY` instead)")
785 .def(
"setE", &setEDeprecated, args(
"self",
"workspaceIndex",
"e"),
786 "Set E values from a python list or numpy array. It performs a "
787 "simple copy into the array (deprecated, use "
788 ":class:`~mantid.api.MatrixWorkspace.setSharedE` instead)")
789 .def(
"setDx", &setDxDeprecated, args(
"self",
"workspaceIndex",
"dX"),
790 "Set Dx values from a python list or numpy array. It performs a "
791 "simple copy into the array (deprecated, use "
792 ":class:`~mantid.api.MatrixWorkspace.setSharedDx` instead)")
793 .def(
"setSharedX", &setSharedXFromPyObject, args(
"self",
"workspaceIndex",
"x"),
794 "Set the X data at the given index by building a new copy-on-write array "
795 "from a python list or numpy array and sharing it into the workspace.")
796 .def(
"setSharedY", &setSharedYFromPyObject, args(
"self",
"workspaceIndex",
"y"),
797 "Set the Y data at the given index by building a new copy-on-write array "
798 "from a python list or numpy array and sharing it into the workspace.")
799 .def(
"setSharedE", &setSharedEFromPyObject, args(
"self",
"workspaceIndex",
"e"),
800 "Set the E data at the given index by building a new copy-on-write array "
801 "from a python list or numpy array and sharing it into the workspace.")
802 .def(
"setSharedDx", &setSharedDxFromPyObject, args(
"self",
"workspaceIndex",
"dX"),
803 "Set the Dx data at the given index by building a new copy-on-write array "
804 "from a python list or numpy array and sharing it into the workspace.")
809 "Extracts (copies) the X data from the workspace into a 2D numpy "
811 "Note: This can fail for large workspaces as numpy will require a "
813 "of memory free that will fit all of the data.")
815 "Extracts (copies) the Y data from the workspace into a 2D numpy "
817 "Note: This can fail for large workspaces as numpy will require a "
819 "of memory free that will fit all of the data.")
821 "Extracts (copies) the E data from the workspace into a 2D numpy "
823 "Note: This can fail for large workspaces as numpy will require a "
825 "of memory free that will fit all of the data.")
827 "Extracts (copies) the E data from the workspace into a 2D numpy "
829 "Note: This can fail for large workspaces as numpy will require a "
831 "of memory free that will fit all of the data.")
832 .def(
"getSignalAtCoord", &getSignalAtCoord, args(
"self",
"coords",
"normalization"),
833 "Return signal for array of coordinates")
834 .def(
"getIntegratedCountsForWorkspaceIndices", &getIntegratedCountsForWorkspaceIndices,
835 args(
"self",
"workspaceIndices",
"numberOfWorkspaces",
"minX",
"maxX",
"entireRange"),
836 "Return a vector with the integrated counts within the given range for the given workspace indices")
840 "Performs a comparison operation on two workspaces, using the "
841 "CompareWorkspaces algorithm")
843 .def(
"getMonitorWorkspace", &getMonitorWorkspace, args(
"self"),
844 "Return internal monitor workspace bound to current workspace.")
845 .def(
"setMonitorWorkspace", &setMonitorWorkspace, args(
"self",
"MonitorWS"),
846 "Set specified workspace as monitor workspace for"
847 "current workspace. "
848 "Note: The workspace does not have to contain monitors though "
849 "some subsequent algorithms may expect it to be "
850 "monitor workspace later.")
851 .def(
"clearMonitorWorkspace", &clearMonitorWorkspace, args(
"self"),
852 "Forget about monitor workspace, attached to the current workspace")
855 "Returns true if the workspace has common X bins with log spacing.");
double value
The value of the point.
#define GET_POINTER_SPECIALIZATION(TYPE)
std::map< DeltaEMode::Type, std::string > index
void export_MatrixWorkspace()
Python exports of the Mantid::API::MatrixWorkspace class.
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
Class to represent the axis of a workspace.
virtual Axis * clone(const MatrixWorkspace *const parentWorkspace)=0
Virtual constructor.
Run & mutableRun()
Writable version of the run object.
A "spectrum" is an object that holds the data for a particular spectrum, in particular:
Base MatrixWorkspace Abstract Class.
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.
void setSharedDx(const size_t index, const Kernel::cow_ptr< HistogramData::HistogramDx > &dx) &
virtual ISpectrum & getSpectrum(const size_t index)=0
Return the underlying ISpectrum ptr at the given workspace index.
const HistogramData::HistogramE & e(const size_t index) const
double detectorSignedTwoTheta(const Geometry::IDetector &det) const
Returns the signed 2Theta scattering angle for a detector.
void setSharedX(const size_t index, const Kernel::cow_ptr< HistogramData::HistogramX > &x) &
bool hasAnyMaskedBins() const
Does this workspace contain any masked bins.
virtual MantidVec & dataDx(const std::size_t index)
Deprecated, use mutableDx() instead. Returns the x error data.
virtual bool isCommonLogBins() const
Returns true if the workspace contains common X bins with log spacing.
HistogramData::BinEdges binEdges(const size_t index) const
void setPoints(const size_t index, T &&...data) &
HistogramData::Points points(const size_t index) const
double detectorTwoTheta(const Geometry::IDetector &det) const
Returns the 2Theta scattering angle for a detector.
HistogramData::HistogramX & mutableX(const size_t index) &
const HistogramData::HistogramDx & dx(const size_t index) const
virtual std::size_t blocksize() const =0
Returns the size of each block of data returned by the dataY accessors.
signal_t getSignalAtCoord(const coord_t *coords, const Mantid::API::MDNormalization &normalization) const override
Get the signal at a coordinate in the workspace.
virtual MantidVec & dataX(const std::size_t index)
Deprecated, use mutableX() instead. Returns the x data.
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.
bool hasMaskedBins(const size_t &workspaceIndex) const
Does this spectrum contain any masked bins.
void setSharedE(const size_t index, const Kernel::cow_ptr< HistogramData::HistogramE > &e) &
const HistogramData::HistogramX & x(const size_t index) const
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.
void setSharedY(const size_t index, const Kernel::cow_ptr< HistogramData::HistogramY > &y) &
virtual MantidVec & dataE(const std::size_t index)
Deprecated, use mutableE() instead. Returns the error data.
bool isDistribution() const
Are the Y-values dimensioned?
std::string getMarkerStyle() const
Get the marker style for plotting.
std::shared_ptr< MatrixWorkspace > monitorWorkspace() const
Returns a pointer to the internal monitor workspace.
virtual bool isRaggedWorkspace() const =0
Returns true if the workspace is ragged (has differently sized spectra).
std::vector< size_t > maskedBinsIndices(const size_t &workspaceIndex) const
std::vector< size_t > getIndicesFromDetectorIDs(const std::vector< detid_t > &detIdList) const
Converts a list of detector IDs to the corresponding workspace indices.
void setDistribution(bool newValue)
Set the flag for whether the Y-values are dimensioned.
const Indexing::IndexInfo & indexInfo() const
Returns a const reference to the IndexInfo object of the workspace.
float getMarkerSize() const
Get the size of the marker for plotting.
virtual bool hasDx(const std::size_t index) const
Probes if DX (X Error) values were set on a particular spectrum.
virtual std::size_t getMaxNumberBins() const =0
Returns the maximum number of bins in a workspace (works on ragged data).
const std::string & YUnit() const
std::string getPlotType() const
Gets MatrixWorkspace plot_type.
detid2index_map getDetectorIDToWorkspaceIndexMap(bool throwIfMultipleDets=false, bool ignoreIfNoValidDets=false) const
Return a map where: KEY is the DetectorID (pixel ID) VALUE is the Workspace Index.
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
virtual std::size_t getNumberBins(const std::size_t &index) const =0
Returns the number of bins for a given histogram index.
HistogramData::HistogramE & mutableE(const size_t index) &
HistogramData::HistogramDx & mutableDx(const size_t index) &
size_t getIndexFromSpectrumNumber(const specnum_t specNo) const
Given a spectrum number, find the corresponding workspace index.
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 MantidVec & dataY(const std::size_t index)
Deprecated, use mutableY() instead. Returns the y data.
HistogramData::HistogramY & mutableY(const size_t index) &
std::string YUnitLabel(bool useLatex=false) const
Returns a caption for the units of the data in the workspace.
void setYUnitLabel(const std::string &newLabel)
Sets a new caption for the data (Y axis) in the workspace.
const HistogramData::HistogramY & y(const size_t index) const
void setMarkerSize(const float markerSize)
Set the size of the marker for plotting.
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.
virtual bool isHistogramData() const
Returns true if the workspace contains data in histogram form (as opposed to point-like)
void setBinEdges(const size_t index, T &&...data) &
This class stores information regarding an experimental run as a series of log entries.
Thin object wrapper around a numpy array.
static bool check(const boost::python::object &obj)
Check if a python object points to an array type object.
Py_intptr_t const * get_shape() const
bool MANTID_API_DLL equals(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs, double tolerance=0.0)
Performs a comparison operation on two workspaces, using the CompareWorkspaces algorithm.
MDNormalization
Enum describing different ways to normalize the signal in a MDWorkspace.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
PyObject * wrapWithNDArray(const ElementType *, const int ndims, Py_intptr_t *dims, const NumpyWrapMode mode, const OwnershipMode oMode=OwnershipMode::Cpp)
Defines the wrapWithNDArray specialization for C array types.
PyObject * cloneE(const API::MatrixWorkspace &self)
Create a numpy array from the E values of the given workspace reference.
PyObject * cloneY(const API::MatrixWorkspace &self)
Create a numpy array from the Y values of the given workspace reference.
PyObject * cloneDx(const API::MatrixWorkspace &self)
Create a numpy array from the E values of the given workspace reference.
PyObject * cloneX(const API::MatrixWorkspace &self)
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
Converter taking an input numpy array and converting it to a std::vector.
void copyTo(TypedVector &dest) const
Fill the container with data from the array.
Converts a Python sequence type to a C++ std::vector, where the element type is defined by the templa...
void copyTo(TypedVector &dest)
Fill the container with data from the array.
Encapsulates the registration required for an interface type T that sits on top of a Kernel::DataItem...