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>
57using return_readonly_numpy = return_value_policy<VectorRefToNumpy<WrapReadOnly>>;
59using return_readwrite_numpy = return_value_policy<VectorRefToNumpy<WrapReadWrite>>;
70BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(MatrixWorkspace_YUnitLabelOverloads, YUnitLabel, 0, 1)
85template <
typename HistogramType>
86void setSpectrumFromPyObject(HistogramType &histogram,
const boost::python::object &values) {
87 auto data = histogram.rawData();
95 histogram = HistogramType(std::move(data));
133 const auto &spectrumNums = self.
indexInfo().spectrumNumbers();
136 for (
const auto &
index : spectrumNums) {
137 spectra.append(
static_cast<int32_t
>(
index));
177 PyErr_Warn(PyExc_DeprecationWarning,
178 "`MatrixWorkspace.readX()` is deprecated in Mantid 7.0, use `MatrixWorkspace.x()` instead. "
179 "For more information, see the Histogram data concept page: "
180 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
181 return xData(self,
index);
191 PyErr_Warn(PyExc_DeprecationWarning,
192 "`MatrixWorkspace.readY()` is deprecated in Mantid 7.0, use `MatrixWorkspace.y()` instead. "
193 "For more information, see the Histogram data concept page: "
194 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
195 return yData(self,
index);
205 PyErr_Warn(PyExc_DeprecationWarning,
206 "`MatrixWorkspace.readE()` is deprecated in Mantid 7.0, use `MatrixWorkspace.e()` instead. "
207 "For more information, see the Histogram data concept page: "
208 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
209 return eData(self,
index);
219 PyErr_Warn(PyExc_DeprecationWarning,
220 "`MatrixWorkspace.readDx()` is deprecated in Mantid 7.0, use `MatrixWorkspace.dx()` instead. "
221 "For more information, see the Histogram data concept page: "
222 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
223 return dxData(self,
index);
233 PyErr_Warn(PyExc_DeprecationWarning,
234 "`MatrixWorkspace.dataX()` is deprecated in Mantid 7.0, use `MatrixWorkspace.mutableX()` instead. "
235 "For more information, see the Histogram data concept page: "
236 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
237 return mutableXData(self,
index);
247 PyErr_Warn(PyExc_DeprecationWarning,
248 "`MatrixWorkspace.dataY()` is deprecated in Mantid 7.0, use `MatrixWorkspace.mutableY()` instead. "
249 "For more information, see the Histogram data concept page: "
250 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
251 return mutableYData(self,
index);
261 PyErr_Warn(PyExc_DeprecationWarning,
262 "`MatrixWorkspace.dataE()` is deprecated in Mantid 7.0, use `MatrixWorkspace.mutableE()` instead. "
263 "For more information, see the Histogram data concept page: "
264 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
265 return mutableEData(self,
index);
275 PyErr_Warn(PyExc_DeprecationWarning,
276 "`MatrixWorkspace.dataDx()` is deprecated in Mantid 7.0, use `MatrixWorkspace.mutableDx()` instead. "
277 "For more information, see the Histogram data concept page: "
278 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
279 return mutableDxData(self,
index);
288void setXFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
289 setSpectrumFromPyObject(self.
mutableX(wsIndex), values);
298void setYFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
299 setSpectrumFromPyObject(self.
mutableY(wsIndex), values);
308void setEFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
309 setSpectrumFromPyObject(self.
mutableE(wsIndex), values);
318void setDxFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
319 setSpectrumFromPyObject(self.
mutableDx(wsIndex), values);
328void setXDeprecated(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
329 PyErr_Warn(PyExc_DeprecationWarning,
330 "`MatrixWorkspace.setX()` is deprecated in Mantid 7.0, use `MatrixWorkspace.setSharedX()` instead. "
331 "For more information, see the Histogram data concept page: "
332 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
333 setXFromPyObject(self, wsIndex, values);
342void setYDeprecated(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
343 PyErr_Warn(PyExc_DeprecationWarning,
344 "`MatrixWorkspace.setY()` is deprecated in Mantid 7.0, use `MatrixWorkspace.setSharedY()` instead. "
345 "For more information, see the Histogram data concept page: "
346 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
347 setYFromPyObject(self, wsIndex, values);
356void setEDeprecated(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
357 PyErr_Warn(PyExc_DeprecationWarning,
358 "`MatrixWorkspace.setE()` is deprecated in Mantid 7.0, use `MatrixWorkspace.setSharedE()` instead. "
359 "For more information, see the Histogram data concept page: "
360 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
361 setEFromPyObject(self, wsIndex, values);
370void setDxDeprecated(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
371 PyErr_Warn(PyExc_DeprecationWarning,
372 "`MatrixWorkspace.setDx()` is deprecated in Mantid 7.0, use `MatrixWorkspace.setSharedDx()` instead. "
373 "For more information, see the Histogram data concept page: "
374 "https://docs.mantidproject.org/nightly/concepts/HistogramData.html");
375 setDxFromPyObject(self, wsIndex, values);
383std::vector<double> extractVectorFromPyObject(
const boost::python::object &values) {
396void setSharedXFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
397 self.
setSharedX(wsIndex, make_cow<Mantid::HistogramData::HistogramX>(extractVectorFromPyObject(values)));
406void setSharedYFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
407 self.
setSharedY(wsIndex, make_cow<Mantid::HistogramData::HistogramY>(extractVectorFromPyObject(values)));
416void setSharedEFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
417 self.
setSharedE(wsIndex, make_cow<Mantid::HistogramData::HistogramE>(extractVectorFromPyObject(values)));
426void setSharedDxFromPyObject(
MatrixWorkspace &self,
const size_t wsIndex,
const boost::python::object &values) {
427 self.
setSharedDx(wsIndex, make_cow<Mantid::HistogramData::HistogramDx>(extractVectorFromPyObject(values)));
430std::vector<double> getIntegratedCountsForWorkspaceIndices(
MatrixWorkspace &self,
431 const boost::python::object &workspaceIndices,
432 const size_t numberOfWorkspaces,
const double minX,
433 const double maxX,
const bool entireRange) {
435 std::vector<size_t> sWorkspaceIndices(numberOfWorkspaces);
438 converter.
copyTo(sWorkspaceIndices);
441 converter.
copyTo(sWorkspaceIndices);
454 PyErr_Warn(PyExc_DeprecationWarning,
"``getSampleDetails`` is deprecated, use ``getRun`` instead.");
465 PyErr_Warn(PyExc_DeprecationWarning,
"``getNumberBins`` is deprecated, use ``blocksize`` instead.");
479std::size_t binIndexOfDeprecated(
MatrixWorkspace &self,
const double xValue,
const std::size_t
index = 0) {
480 PyErr_Warn(PyExc_DeprecationWarning,
"``binIndexOf`` is deprecated, use ``yIndexOfX`` instead.");
489BOOST_PYTHON_FUNCTION_OVERLOADS(binIndexOfDeprecatedOverloads, binIndexOfDeprecated, 2, 3)
509void pythonReplaceAxis(
MatrixWorkspace &self,
const std::size_t &axisIndex,
Axis *newAxis) {
523 throw std::invalid_argument(
"MatrixWorkspace::getSignalAtCoord - Input "
524 "array must have shape (n, 2)");
527 Py_intptr_t length = len(npCoords);
534 for (
int i = 0; i < length; ++i) {
535 std::array<Mantid::coord_t, 2> coord = {{coords[2 * i], coords[2 * i + 1]}};
538 PyObject *npSignalArray =
540 return object(handle<>(npSignalArray));
544 int64_t first = extract<int64_t>(start[0]);
545 int64_t second = extract<int64_t>(start[1]);
546 auto idx = self.
findY(
value, std::make_pair(first, second));
547 return make_tuple(idx.first, idx.second);
559 const size_t setIndex) {
572 const size_t setIndex) {
576std::vector<size_t> getIndicesFromDetectorIDs(
MatrixWorkspace &self,
const boost::python::list &detIDs) {
580boost::python::dict getDetectorIDToWorkspaceIndexMap(
MatrixWorkspace &self,
bool throwIfMultipleDets,
581 bool ignoreIfNoValidDets) {
583 boost::python::dict pythonDict;
584 for (
const auto &[key,
value] : unorderedMap) {
585 pythonDict[key] =
value;
598 class_<MatrixWorkspace, boost::python::bases<ExperimentInfo, IMDWorkspace>, boost::noncopyable>(
"MatrixWorkspace",
603 "Returns true if the workspace is ragged (has differently sized "
607 "Returns the number of bins for a given histogram index.")
608 .def(
"getNumberBins", &getNumberBinsDeprecated, arg(
"self"),
609 "Returns size of the Y data array (deprecated, use "
610 ":class:`~mantid.api.MatrixWorkspace.blocksize` "
613 "Returns the maximum number of bins in a workspace (works on ragged "
616 "Returns the number of spectra in the workspace")
620 .def(
"getSpectrumNumbers", &getSpectrumNumbers, arg(
"self"),
621 "Returns a list of all spectrum numbers in the workspace")
623 MatrixWorkspace_yIndexOfXOverloads((arg(
"self"), arg(
"xvalue"), arg(
"workspaceIndex"), arg(
"tolerance")),
624 "Returns the y index which corresponds to the X Value provided. "
625 "The workspace_index [default=0] and tolerance [default=0.0] is "
628 "Returns the two theta value for a given detector")
630 "Returns the signed two theta value for given detector")
632 (arg(
"self"), arg(
"workspaceIndex")), return_internal_reference<>(),
633 "Return the spectra at the given workspace index.")
635 "Returns workspace index correspondent to the given spectrum "
636 "number. Throws if no such spectrum is present in the workspace")
637 .def(
"getIndicesFromDetectorIDs", &getIndicesFromDetectorIDs, (arg(
"self"), arg(
"detID_list")),
638 "Returns a list of workspace indices from the corrresponding "
640 .def(
"getDetectorIDToWorkspaceIndexMap", &getDetectorIDToWorkspaceIndexMap,
641 (arg(
"self"), arg(
"throwIfMultipleDets"), arg(
"ignoreIfNoValidDets")),
642 " Return a map where the key is detector ID (pixel ID), and the value at that index = the corresponding "
645 (arg(
"self"), arg(
"workspaceIndex")),
646 "Return the :class:`~mantid.geometry.Detector` or "
647 ":class:`~mantid.geometry.DetectorGroup` that is linked to "
648 "the given workspace index")
650 "Return the :class:`~mantid.api.Run` object for this workspace")
651 .def(
"axes", &
MatrixWorkspace::axes, arg(
"self"),
"Returns the number of axes attached to the workspace")
653 "Get a pointer to a workspace axis")
655 "Returns ``True`` if this is considered to be binned data.")
657 "Returns the status of the distribution flag")
659 "Returns the current Y unit for the data (Y axis) in the workspace")
661 MatrixWorkspace_YUnitLabelOverloads((arg(
"self"), arg(
"useLatex")),
"Returns the caption for the Y axis"))
663 "Returns true if any of the bins in this workspace are masked.")
665 "Returns true if this spectrum contains any masked bins")
666 .def(
"maskedBinsIndices", &maskedBinsIndices, (arg(
"self"), arg(
"workspaceIndex")),
667 "Returns all the masked bins' indices at the workspace index. "
668 ":class:`~mantid.api.MatrixWorkspace.hasMaskedBins` MUST be called "
669 "first to check if any bins are "
670 "masked, otherwise an exception will be thrown")
671 .def(
"findY", &findY, (arg(
"self"), arg(
"value"), arg(
"start") = make_tuple(0, 0)),
672 "Find first index in Y equal to value. Start may be specified to "
673 "begin at a specifc index. Returns tuple with the "
674 "histogram and bin indices.")
675 .def(
"getSampleDetails", &getSampleDetailsDeprecated, arg(
"self"), return_internal_reference<>(),
676 "Return the Run object for this workspace (deprecated, use "
677 ":class:`~mantid.api.MatrixWorkspace.getRun` "
679 .def(
"binIndexOf", &binIndexOfDeprecated,
680 binIndexOfDeprecatedOverloads((arg(
"self"), arg(
"xvalue"), arg(
"workspaceIndex")),
681 "Returns the index of the bin containing the given xvalue "
683 ":class:`~mantid.api.MatrixWorkspace.yIndexOfX` instead)"))
688 "Sets a new plot type for the workspace")
690 "Sets the marker type for the workspace")
692 "Sets the size of the marker for the workspace")
694 "Sets a new caption for the data (Y axis) in the workspace")
696 "Sets a new unit for the data (Y axis) in the workspace")
698 "Set distribution flag. If True the workspace has been divided by "
700 .def(
"replaceAxis", &pythonReplaceAxis, (arg(
"self"), arg(
"axisIndex"), arg(
"newAxis")),
701 "Replaces one of the workspace's axes with the new one provided. "
702 "The axis is cloned.")
703 .def(
"applyBinEdgesFromAnotherWorkspace", &applyBinEdgesFromAnotherWorkspace,
704 (arg(
"self"), arg(
"ws"), arg(
"getIndex"), arg(
"setIndex")),
705 "Sets the bin edges at setIndex to be the bin edges of ws at "
707 .def(
"applyPointsFromAnotherWorkspace", &applyPointsFromAnotherWorkspace,
708 (arg(
"self"), arg(
"ws"), arg(
"getIndex"), arg(
"setIndex")),
709 "Sets the points at setIndex to be the points of ws at getIndex.")
713 .def(
"x", &xData, return_readonly_numpy(), args(
"self",
"workspaceIndex"),
714 "Creates a read-only numpy wrapper around the X data at the given index")
715 .def(
"y", &yData, return_readonly_numpy(), args(
"self",
"workspaceIndex"),
716 "Creates a read-only numpy wrapper around the Y data at the given index")
717 .def(
"e", &eData, return_readonly_numpy(), args(
"self",
"workspaceIndex"),
718 "Creates a read-only numpy wrapper around the E data at the given index")
719 .def(
"dx", &dxData, return_readonly_numpy(), args(
"self",
"workspaceIndex"),
720 "Creates a read-only numpy wrapper around the Dx data at the given index. "
721 "If :class:`~mantid.api.MatrixWorkspace.hasDx` is False for this index, "
722 "the Dx data is first initialized to zeros.")
723 .def(
"readX", &readXDeprecated, (arg(
"self"), arg(
"workspaceIndex")), return_readonly_numpy(),
724 "Creates a read-only numpy wrapper "
725 "around the original X data at the "
726 "given index (deprecated, use "
727 ":class:`~mantid.api.MatrixWorkspace.x` instead)")
728 .def(
"readY", &readYDeprecated, return_readonly_numpy(), args(
"self",
"workspaceIndex"),
729 "Creates a read-only numpy wrapper "
730 "around the original Y data at the "
731 "given index (deprecated, use "
732 ":class:`~mantid.api.MatrixWorkspace.y` instead)")
733 .def(
"readE", &readEDeprecated, return_readonly_numpy(), args(
"self",
"workspaceIndex"),
734 "Creates a read-only numpy wrapper "
735 "around the original E data at the "
736 "given index (deprecated, use "
737 ":class:`~mantid.api.MatrixWorkspace.e` instead)")
738 .def(
"readDx", &readDxDeprecated, return_readonly_numpy(), args(
"self",
"workspaceIndex"),
739 "Creates a read-only numpy wrapper "
740 "around the original Dx data at the "
741 "given index (deprecated, use "
742 ":class:`~mantid.api.MatrixWorkspace.dx` instead)")
744 "Returns True if the spectrum uses the DX (X Error) array, else "
748 .def(
"mutableX", &mutableXData, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
749 "Creates a writable numpy wrapper around the X data at the given index")
750 .def(
"mutableY", &mutableYData, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
751 "Creates a writable numpy wrapper around the Y data at the given index. "
752 "Raises a RuntimeError for :class:`~mantid.api.IEventWorkspace`, since "
753 "non-const access to Y data is not possible for event data.")
754 .def(
"mutableE", &mutableEData, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
755 "Creates a writable numpy wrapper around the E data at the given index. "
756 "Raises a RuntimeError for :class:`~mantid.api.IEventWorkspace`, since "
757 "non-const access to E data is not possible for event data.")
758 .def(
"mutableDx", &mutableDxData, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
759 "Creates a writable numpy wrapper around the Dx data at the given index. "
760 "If :class:`~mantid.api.MatrixWorkspace.hasDx` is False for this index, "
761 "the Dx data is first initialized to zeros.")
762 .def(
"dataX", &dataXDeprecated, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
763 "Creates a writable numpy wrapper around the original X data at the "
764 "given index (deprecated, use "
765 ":class:`~mantid.api.MatrixWorkspace.mutableX` instead)")
766 .def(
"dataY", &dataYDeprecated, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
767 "Creates a writable numpy wrapper around the original Y data at the "
768 "given index (deprecated, use "
769 ":class:`~mantid.api.MatrixWorkspace.mutableY` instead)")
770 .def(
"dataE", &dataEDeprecated, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
771 "Creates a writable numpy wrapper around the original E data at the "
772 "given index (deprecated, use "
773 ":class:`~mantid.api.MatrixWorkspace.mutableE` instead)")
774 .def(
"dataDx", &dataDxDeprecated, return_readwrite_numpy(), args(
"self",
"workspaceIndex"),
775 "Creates a writable numpy wrapper around the original Dx data at "
776 "the given index (deprecated, use "
777 ":class:`~mantid.api.MatrixWorkspace.mutableDx` instead)")
778 .def(
"setX", &setXDeprecated, args(
"self",
"workspaceIndex",
"x"),
779 "Set X values from a python list or numpy array. It performs a "
780 "simple copy into the array (deprecated, use "
781 ":class:`~mantid.api.MatrixWorkspace.setSharedX` instead)")
782 .def(
"setY", &setYDeprecated, args(
"self",
"workspaceIndex",
"y"),
783 "Set Y values from a python list or numpy array. It performs a "
784 "simple copy into the array (deprecated, use "
785 ":class:`~mantid.api.MatrixWorkspace.setSharedY` instead)")
786 .def(
"setE", &setEDeprecated, args(
"self",
"workspaceIndex",
"e"),
787 "Set E values from a python list or numpy array. It performs a "
788 "simple copy into the array (deprecated, use "
789 ":class:`~mantid.api.MatrixWorkspace.setSharedE` instead)")
790 .def(
"setDx", &setDxDeprecated, args(
"self",
"workspaceIndex",
"dX"),
791 "Set Dx values from a python list or numpy array. It performs a "
792 "simple copy into the array (deprecated, use "
793 ":class:`~mantid.api.MatrixWorkspace.setSharedDx` instead)")
794 .def(
"setSharedX", &setSharedXFromPyObject, args(
"self",
"workspaceIndex",
"x"),
795 "Set the X data at the given index by building a new copy-on-write array "
796 "from a python list or numpy array and sharing it into the workspace.")
797 .def(
"setSharedY", &setSharedYFromPyObject, args(
"self",
"workspaceIndex",
"y"),
798 "Set the Y data at the given index by building a new copy-on-write array "
799 "from a python list or numpy array and sharing it into the workspace.")
800 .def(
"setSharedE", &setSharedEFromPyObject, args(
"self",
"workspaceIndex",
"e"),
801 "Set the E data at the given index by building a new copy-on-write array "
802 "from a python list or numpy array and sharing it into the workspace.")
803 .def(
"setSharedDx", &setSharedDxFromPyObject, args(
"self",
"workspaceIndex",
"dX"),
804 "Set the Dx data at the given index by building a new copy-on-write array "
805 "from a python list or numpy array and sharing it into the workspace.")
810 "Extracts (copies) the X data from the workspace into a 2D numpy array. "
811 "Note: This can fail for large workspaces as numpy will require a block of memory free that will fit all of "
813 "Note: This will fail for ragged workspaces.")
815 "Extracts (copies) the Y data from the workspace into a 2D numpy array. "
816 "Note: This can fail for large workspaces as numpy will require a block of memory free that will fit all of "
818 "Note: This will fail for ragged workspaces.")
820 "Extracts (copies) the E data from the workspace into a 2D numpy array. "
821 "Note: This can fail for large workspaces as numpy will require a block of memory free that will fit all of "
823 "Note: This will fail for ragged workspaces.")
825 "Extracts (copies) the Dx data from the workspace into a 2D numpy array. "
826 "Note: This can fail for large workspaces as numpy will require a block of memory free that will fit all of "
828 "Note: This will fail for ragged workspaces.")
829 .def(
"getSignalAtCoord", &getSignalAtCoord, args(
"self",
"coords",
"normalization"),
830 "Return signal for array of coordinates")
831 .def(
"getIntegratedCountsForWorkspaceIndices", &getIntegratedCountsForWorkspaceIndices,
832 args(
"self",
"workspaceIndices",
"numberOfWorkspaces",
"minX",
"maxX",
"entireRange"),
833 "Return a vector with the integrated counts within the given range for the given workspace indices")
837 "Performs a comparison operation on two workspaces, using the "
838 "CompareWorkspaces algorithm")
840 .def(
"getMonitorWorkspace", &getMonitorWorkspace, args(
"self"),
841 "Return internal monitor workspace bound to current workspace.")
842 .def(
"setMonitorWorkspace", &setMonitorWorkspace, args(
"self",
"MonitorWS"),
843 "Set specified workspace as monitor workspace for"
844 "current workspace. "
845 "Note: The workspace does not have to contain monitors though "
846 "some subsequent algorithms may expect it to be "
847 "monitor workspace later.")
848 .def(
"clearMonitorWorkspace", &clearMonitorWorkspace, args(
"self"),
849 "Forget about monitor workspace, attached to the current workspace")
852 "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 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 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) &
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.
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...