Mantid
Loading...
Searching...
No Matches
MatrixWorkspace.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8
9#include "MantidAPI/Axis.h"
10#include "MantidAPI/Run.h"
13#include "MantidHistogramData/HistogramY.h"
14#include "MantidIndexing/IndexInfo.h"
16
25
26#include <boost/python/class.hpp>
27#include <boost/python/copy_const_reference.hpp>
28#include <boost/python/implicit.hpp>
29#include <boost/python/list.hpp>
30#include <boost/python/overloads.hpp>
31#include <boost/python/register_ptr_to_python.hpp>
32#include <boost/python/suite/indexing/map_indexing_suite.hpp>
33#include <boost/python/tuple.hpp>
34
35#define PY_ARRAY_UNIQUE_SYMBOL API_ARRAY_API
36#define NO_IMPORT_ARRAY
37#include <numpy/arrayobject.h>
38
39using namespace Mantid::API;
40using namespace Mantid::Geometry;
41using namespace Mantid::Kernel;
42using namespace Mantid::PythonInterface;
46using namespace boost::python;
47
49
50namespace {
52using data_modifier = Mantid::MantidVec &(MatrixWorkspace::*)(const std::size_t);
53
55using return_readonly_numpy = return_value_policy<VectorRefToNumpy<WrapReadOnly>>;
57using return_readwrite_numpy = return_value_policy<VectorRefToNumpy<WrapReadWrite>>;
58
59//------------------------------- Overload macros ---------------------------
60GNU_DIAG_OFF("unused-local-typedef")
61// Ignore -Wconversion warnings coming from boost::python
62// Seen with GCC 7.1.1 and Boost 1.63.0
63GNU_DIAG_OFF("conversion")
64// Overloads for yIndexOfX function which has 2 optional argument
65BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(MatrixWorkspace_yIndexOfXOverloads, MatrixWorkspace::yIndexOfX, 1, 3)
66// Overloads for YUnitLabel which has 1 optional argument
67BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(MatrixWorkspace_YUnitLabelOverloads, YUnitLabel, 0, 2)
68GNU_DIAG_ON("conversion")
69GNU_DIAG_ON("unused-local-typedef")
70
71
80void setSpectrumFromPyObject(MatrixWorkspace &self, data_modifier accessor, const size_t wsIndex,
81 const boost::python::object &values) {
82 if (NDArray::check(values)) {
83 NDArrayToVector<double> converter(values);
84 converter.copyTo((self.*accessor)(wsIndex));
85 } else {
86 PySequenceToVector<double> converter(values);
87 converter.copyTo((self.*accessor)(wsIndex));
88 }
89}
90
97void setMonitorWorkspace(MatrixWorkspace &self, const boost::python::object &value) {
99 std::dynamic_pointer_cast<MatrixWorkspace>(Mantid::PythonInterface::ExtractSharedPtr<Workspace>(value)());
100 self.setMonitorWorkspace(monWS);
101}
107std::weak_ptr<Workspace> getMonitorWorkspace(MatrixWorkspace &self) {
108 return std::weak_ptr<Workspace>(self.monitorWorkspace());
109}
115void clearMonitorWorkspace(MatrixWorkspace &self) {
117 self.setMonitorWorkspace(monWS);
118}
119
125list getSpectrumNumbers(const MatrixWorkspace &self) {
126 const auto &spectrumNums = self.indexInfo().spectrumNumbers();
127 list spectra;
128
129 for (const auto &index : spectrumNums) {
130 spectra.append(static_cast<int32_t>(index));
131 }
132
133 return spectra;
134}
135
142void setXFromPyObject(MatrixWorkspace &self, const size_t wsIndex, const boost::python::object &values) {
143 setSpectrumFromPyObject(self, &MatrixWorkspace::dataX, wsIndex, values);
144}
145
152void setYFromPyObject(MatrixWorkspace &self, const size_t wsIndex, const boost::python::object &values) {
153 setSpectrumFromPyObject(self, &MatrixWorkspace::dataY, wsIndex, values);
154}
155
162void setEFromPyObject(MatrixWorkspace &self, const size_t wsIndex, const NDArray &values) {
163 setSpectrumFromPyObject(self, &MatrixWorkspace::dataE, wsIndex, values);
164}
165
172void setDxFromPyObject(MatrixWorkspace &self, const size_t wsIndex, const boost::python::object &values) {
173 setSpectrumFromPyObject(self, &MatrixWorkspace::dataDx, wsIndex, values);
174}
175
182Mantid::API::Run &getSampleDetailsDeprecated(MatrixWorkspace &self) {
183 PyErr_Warn(PyExc_DeprecationWarning, "``getSampleDetails`` is deprecated, use ``getRun`` instead.");
184 return self.mutableRun();
185}
186
193std::size_t getNumberBinsDeprecated(MatrixWorkspace &self) {
194 PyErr_Warn(PyExc_DeprecationWarning, "``getNumberBins`` is deprecated, use ``blocksize`` instead.");
195 return self.blocksize();
196}
197
208std::size_t binIndexOfDeprecated(MatrixWorkspace &self, const double xValue, const std::size_t index = 0) {
209 PyErr_Warn(PyExc_DeprecationWarning, "``binIndexOf`` is deprecated, use ``yIndexOfX`` instead.");
210 return self.yIndexOfX(xValue, index);
211}
212
213GNU_DIAG_OFF("unused-local-typedef")
214// Ignore -Wconversion warnings coming from boost::python
215// Seen with GCC 7.1.1 and Boost 1.63.0
216GNU_DIAG_OFF("conversion")
217// Overloads for binIndexOfDeprecated function which has 1 optional argument
218BOOST_PYTHON_FUNCTION_OVERLOADS(binIndexOfDeprecatedOverloads, binIndexOfDeprecated, 2, 3)
219GNU_DIAG_ON("conversion")
220GNU_DIAG_ON("unused-local-typedef")
221
222
229std::vector<size_t> maskedBinsIndices(MatrixWorkspace &self, const int i) { return self.maskedBinsIndices(i); }
230
238void pythonReplaceAxis(MatrixWorkspace &self, const std::size_t &axisIndex, Axis *newAxis) {
239 self.replaceAxis(axisIndex, std::unique_ptr<Axis>(newAxis->clone(&self)));
240}
241
249object getSignalAtCoord(MatrixWorkspace &self, const NDArray &npCoords,
250 const Mantid::API::MDNormalization &normalization) {
251 if (npCoords.get_shape()[1] != 2) {
252 throw std::invalid_argument("MatrixWorkspace::getSignalAtCoord - Input "
253 "array must have shape (n, 2)");
254 }
255 // Create our output array
256 Py_intptr_t length = len(npCoords);
257 auto *signalValues = new Mantid::signal_t[length];
258
259 // Convert coords to a vector
260 std::vector<Mantid::coord_t> coords = NDArrayToVector<Mantid::coord_t>(npCoords)();
261
262 // Fill output array
263 for (int i = 0; i < length; ++i) {
264 std::array<Mantid::coord_t, 2> coord = {{coords[2 * i], coords[2 * i + 1]}};
265 signalValues[i] = self.getSignalAtCoord(coord.data(), normalization);
266 }
267 PyObject *npSignalArray =
268 Impl::wrapWithNDArray(signalValues, 1, &length, NumpyWrapMode::ReadOnly, OwnershipMode::Python);
269 return object(handle<>(npSignalArray));
270}
271
272boost::python::tuple findY(MatrixWorkspace &self, double value, tuple start) {
273 int64_t first = extract<int64_t>(start[0]);
274 int64_t second = extract<int64_t>(start[1]);
275 auto idx = self.findY(value, std::make_pair(first, second));
276 return make_tuple(idx.first, idx.second);
277}
278
287void applyBinEdgesFromAnotherWorkspace(MatrixWorkspace &self, const MatrixWorkspace &ws, const size_t getIndex,
288 const size_t setIndex) {
289 self.setBinEdges(setIndex, ws.binEdges(getIndex));
290}
291
300void applyPointsFromAnotherWorkspace(MatrixWorkspace &self, const MatrixWorkspace &ws, const size_t getIndex,
301 const size_t setIndex) {
302 self.setPoints(setIndex, ws.points(getIndex));
303}
304
305std::vector<size_t> getIndicesFromDetectorIDs(MatrixWorkspace &self, const boost::python::list &detIDs) {
307}
308
309} // namespace
310
315
316 class_<MatrixWorkspace, boost::python::bases<ExperimentInfo, IMDWorkspace>, boost::noncopyable>("MatrixWorkspace",
317 no_init)
318 //--------------------------------------- Meta information
319 //-----------------------------------------------------------------------
320 .def("isRaggedWorkspace", &MatrixWorkspace::isRaggedWorkspace, arg("self"),
321 "Returns true if the workspace is ragged (has differently sized "
322 "spectra).")
323 .def("blocksize", &MatrixWorkspace::blocksize, arg("self"), "Returns size of the Y data array")
324 .def("getNumberBins", &MatrixWorkspace::getNumberBins, (arg("self"), arg("index")),
325 "Returns the number of bins for a given histogram index.")
326 .def("getNumberBins", &getNumberBinsDeprecated, arg("self"),
327 "Returns size of the Y data array (deprecated, use "
328 ":class:`~mantid.api.MatrixWorkspace.blocksize` "
329 "instead)")
330 .def("getMaxNumberBins", &MatrixWorkspace::getMaxNumberBins, arg("self"),
331 "Returns the maximum number of bins in a workspace (works on ragged "
332 "data).")
333 .def("getNumberHistograms", &MatrixWorkspace::getNumberHistograms, arg("self"),
334 "Returns the number of spectra in the workspace")
335 .def("getSpectrumNumbers", &getSpectrumNumbers, arg("self"),
336 "Returns a list of all spectrum numbers in the workspace")
337 .def("yIndexOfX", &MatrixWorkspace::yIndexOfX,
338 MatrixWorkspace_yIndexOfXOverloads((arg("self"), arg("xvalue"), arg("workspaceIndex"), arg("tolerance")),
339 "Returns the y index which corresponds to the X Value provided. "
340 "The workspace_index [default=0] and tolerance [default=0.0] is "
341 "optional."))
342 .def("detectorTwoTheta", &MatrixWorkspace::detectorTwoTheta, (arg("self"), arg("det")),
343 "Returns the two theta value for a given detector")
344 .def("detectorSignedTwoTheta", &MatrixWorkspace::detectorSignedTwoTheta, (arg("self"), arg("det")),
345 "Returns the signed two theta value for given detector")
346 .def("getSpectrum", (ISpectrum & (MatrixWorkspace::*)(const size_t)) & MatrixWorkspace::getSpectrum,
347 (arg("self"), arg("workspaceIndex")), return_internal_reference<>(),
348 "Return the spectra at the given workspace index.")
349 .def("getIndexFromSpectrumNumber", &MatrixWorkspace::getIndexFromSpectrumNumber, (arg("self"), arg("spec_no")),
350 "Returns workspace index correspondent to the given spectrum "
351 "number. Throws if no such spectrum is present in the workspace")
352 .def("getIndicesFromDetectorIDs", &getIndicesFromDetectorIDs, (arg("self"), arg("detID_list")),
353 "Returns a list of workspace indices from the corrresponding "
354 "detector IDs.")
355 .def("getDetector", &MatrixWorkspace::getDetector, return_value_policy<RemoveConstSharedPtr>(),
356 (arg("self"), arg("workspaceIndex")),
357 "Return the :class:`~mantid.geometry.Detector` or "
358 ":class:`~mantid.geometry.DetectorGroup` that is linked to "
359 "the given workspace index")
360 .def("getRun", &MatrixWorkspace::mutableRun, arg("self"), return_internal_reference<>(),
361 "Return the :class:`~mantid.api.Run` object for this workspace")
362 .def("axes", &MatrixWorkspace::axes, arg("self"), "Returns the number of axes attached to the workspace")
363 .def("getAxis", &MatrixWorkspace::getAxis, (arg("self"), arg("axis_index")), return_internal_reference<>(),
364 "Get a pointer to a workspace axis")
365 .def("isHistogramData", &MatrixWorkspace::isHistogramData, arg("self"),
366 "Returns ``True`` if this is considered to be binned data.")
367 .def("isDistribution", (bool (MatrixWorkspace::*)() const) & MatrixWorkspace::isDistribution, arg("self"),
368 "Returns the status of the distribution flag")
369 .def("YUnit", &MatrixWorkspace::YUnit, arg("self"),
370 "Returns the current Y unit for the data (Y axis) in the workspace")
371 .def("YUnitLabel", &MatrixWorkspace::YUnitLabel,
372 MatrixWorkspace_YUnitLabelOverloads((arg("self"), arg("useLatex"), arg("plotAsDistribution")),
373 "Returns the caption for the Y axis"))
374 .def("hasAnyMaskedBins", &MatrixWorkspace::hasAnyMaskedBins, (arg("self")),
375 "Returns true if any of the bins in this workspace are masked.")
376 .def("hasMaskedBins", &MatrixWorkspace::hasMaskedBins, (arg("self"), arg("workspaceIndex")),
377 "Returns true if this spectrum contains any masked bins")
378 .def("maskedBinsIndices", &maskedBinsIndices, (arg("self"), arg("workspaceIndex")),
379 "Returns all the masked bins' indices at the workspace index. "
380 ":class:`~mantid.api.MatrixWorkspace.hasMaskedBins` MUST be called "
381 "first to check if any bins are "
382 "masked, otherwise an exception will be thrown")
383 .def("findY", &findY, (arg("self"), arg("value"), arg("start") = make_tuple(0, 0)),
384 "Find first index in Y equal to value. Start may be specified to "
385 "begin at a specifc index. Returns tuple with the "
386 "histogram and bin indices.")
387 .def("getSampleDetails", &getSampleDetailsDeprecated, arg("self"), return_internal_reference<>(),
388 "Return the Run object for this workspace (deprecated, use "
389 ":class:`~mantid.api.MatrixWorkspace.getRun` "
390 "instead)")
391 .def("binIndexOf", &binIndexOfDeprecated,
392 binIndexOfDeprecatedOverloads((arg("self"), arg("xvalue"), arg("workspaceIndex")),
393 "Returns the index of the bin containing the given xvalue "
394 "(deprecated, use "
395 ":class:`~mantid.api.MatrixWorkspace.yIndexOfX` instead)"))
396
397 //--------------------------------------- Setters
398 //------------------------------------
399 .def("setYUnitLabel", &MatrixWorkspace::setYUnitLabel, (arg("self"), arg("newLabel")),
400 "Sets a new caption for the data (Y axis) in the workspace")
401 .def("setYUnit", &MatrixWorkspace::setYUnit, (arg("self"), arg("newUnit")),
402 "Sets a new unit for the data (Y axis) in the workspace")
403 .def("setDistribution", &MatrixWorkspace::setDistribution, (arg("self"), arg("newVal")),
404 "Set distribution flag. If True the workspace has been divided by "
405 "the bin-width.")
406 .def("replaceAxis", &pythonReplaceAxis, (arg("self"), arg("axisIndex"), arg("newAxis")),
407 "Replaces one of the workspace's axes with the new one provided. "
408 "The axis is cloned.")
409 .def("applyBinEdgesFromAnotherWorkspace", &applyBinEdgesFromAnotherWorkspace,
410 (arg("self"), arg("ws"), arg("getIndex"), arg("setIndex")),
411 "Sets the bin edges at setIndex to be the bin edges of ws at "
412 "getIndex.")
413 .def("applyPointsFromAnotherWorkspace", &applyPointsFromAnotherWorkspace,
414 (arg("self"), arg("ws"), arg("getIndex"), arg("setIndex")),
415 "Sets the points at setIndex to be the points of ws at getIndex.")
416
417 //--------------------------------------- Read spectrum data
418 //-------------------------
419 .def("readX", &MatrixWorkspace::readX, (arg("self"), arg("workspaceIndex")), return_readonly_numpy(),
420 "Creates a read-only numpy wrapper "
421 "around the original X data at the "
422 "given index")
423 .def("readY", &MatrixWorkspace::readY, return_readonly_numpy(), args("self", "workspaceIndex"),
424 "Creates a read-only numpy wrapper "
425 "around the original Y data at the "
426 "given index")
427 .def("readE", &MatrixWorkspace::readE, return_readonly_numpy(), args("self", "workspaceIndex"),
428 "Creates a read-only numpy wrapper "
429 "around the original E data at the "
430 "given index")
431 .def("readDx", &MatrixWorkspace::readDx, return_readonly_numpy(), args("self", "workspaceIndex"),
432 "Creates a read-only numpy wrapper "
433 "around the original Dx data at the "
434 "given index")
435 .def("hasDx", &MatrixWorkspace::hasDx, args("self", "workspaceIndex"),
436 "Returns True if the spectrum uses the DX (X Error) array, else "
437 "False.")
438 //--------------------------------------- Write spectrum data
439 //------------------------
440 .def("dataX", (data_modifier)&MatrixWorkspace::dataX, return_readwrite_numpy(), args("self", "workspaceIndex"),
441 "Creates a writable numpy wrapper around the original X data at the "
442 "given index")
443 .def("dataY", (data_modifier)&MatrixWorkspace::dataY, return_readwrite_numpy(), args("self", "workspaceIndex"),
444 "Creates a writable numpy wrapper around the original Y data at the "
445 "given index")
446 .def("dataE", (data_modifier)&MatrixWorkspace::dataE, return_readwrite_numpy(), args("self", "workspaceIndex"),
447 "Creates a writable numpy wrapper around the original E data at the "
448 "given index")
449 .def("dataDx", (data_modifier)&MatrixWorkspace::dataDx, return_readwrite_numpy(), args("self", "workspaceIndex"),
450 "Creates a writable numpy wrapper around the original Dx data at "
451 "the given index")
452 .def("setX", &setXFromPyObject, args("self", "workspaceIndex", "x"),
453 "Set X values from a python list or numpy array. It performs a "
454 "simple copy into the array.")
455 .def("setY", &setYFromPyObject, args("self", "workspaceIndex", "y"),
456 "Set Y values from a python list or numpy array. It performs a "
457 "simple copy into the array.")
458 .def("setE", &setEFromPyObject, args("self", "workspaceIndex", "e"),
459 "Set E values from a python list or numpy array. It performs a "
460 "simple copy into the array.")
461 .def("setDx", &setDxFromPyObject, args("self", "workspaceIndex", "dX"),
462 "Set Dx values from a python list or numpy array. It performs a "
463 "simple copy into the array.")
464
465 // --------------------------------------- Extract data
466 // ------------------------------
467 .def("extractX", Mantid::PythonInterface::cloneX, args("self"),
468 "Extracts (copies) the X data from the workspace into a 2D numpy "
469 "array. "
470 "Note: This can fail for large workspaces as numpy will require a "
471 "block "
472 "of memory free that will fit all of the data.")
473 .def("extractY", Mantid::PythonInterface::cloneY, args("self"),
474 "Extracts (copies) the Y data from the workspace into a 2D numpy "
475 "array. "
476 "Note: This can fail for large workspaces as numpy will require a "
477 "block "
478 "of memory free that will fit all of the data.")
479 .def("extractE", Mantid::PythonInterface::cloneE, args("self"),
480 "Extracts (copies) the E data from the workspace into a 2D numpy "
481 "array. "
482 "Note: This can fail for large workspaces as numpy will require a "
483 "block "
484 "of memory free that will fit all of the data.")
485 .def("extractDx", Mantid::PythonInterface::cloneDx, args("self"),
486 "Extracts (copies) the E data from the workspace into a 2D numpy "
487 "array. "
488 "Note: This can fail for large workspaces as numpy will require a "
489 "block "
490 "of memory free that will fit all of the data.")
491 .def("getSignalAtCoord", &getSignalAtCoord, args("self", "coords", "normalization"),
492 "Return signal for array of coordinates")
493 //-------------------------------------- Operators
494 //-----------------------------------
495 .def("equals", &Mantid::API::equals, args("self", "other", "tolerance"),
496 "Performs a comparison operation on two workspaces, using the "
497 "CompareWorkspaces algorithm")
498 //--------- monitor workspace --------------------------------------
499 .def("getMonitorWorkspace", &getMonitorWorkspace, args("self"),
500 "Return internal monitor workspace bound to current workspace.")
501 .def("setMonitorWorkspace", &setMonitorWorkspace, args("self", "MonitorWS"),
502 "Set specified workspace as monitor workspace for"
503 "current workspace. "
504 "Note: The workspace does not have to contain monitors though "
505 "some subsequent algorithms may expect it to be "
506 "monitor workspace later.")
507 .def("clearMonitorWorkspace", &clearMonitorWorkspace, args("self"),
508 "Forget about monitor workspace, attached to the current workspace")
509 .def("isCommonBins", &MatrixWorkspace::isCommonBins, "Returns true if the workspace has common X bins.")
510 .def("isCommonLogBins", &MatrixWorkspace::isCommonLogBins,
511 "Returns true if the workspace has common X bins with log spacing.");
512
514}
double value
The value of the point.
Definition: FitMW.cpp:51
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition: GetPointer.h:17
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
void export_MatrixWorkspace()
Python exports of the Mantid::API::MatrixWorkspace class.
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(valueAsPrettyStrOverloader, valueAsPrettyStr, 0, 2) void export_Property()
Definition: Property.cpp:102
#define GNU_DIAG_ON(x)
#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.
Definition: Axis.h:30
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:
Definition: ISpectrum.h:39
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.
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.
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.
double detectorSignedTwoTheta(const Geometry::IDetector &det) const
Returns the signed 2Theta scattering angle for a detector.
const MantidVec & readDx(size_t const index) const
Deprecated, use dx() instead.
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.
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.
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.
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::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.
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 MantidVec & readY(std::size_t const index) const
Deprecated, use y() instead.
virtual Axis * getAxis(const std::size_t &axisIndex) const
Get a non owning pointer to a workspace axis.
virtual std::size_t getNumberBins(const std::size_t &index) const =0
Returns the number of bins for a given histogram 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.
void replaceAxis(const std::size_t &axisIndex, std::unique_ptr< Axis > newAxis)
Replaces one of the workspace's axes with the new one provided.
std::string YUnit() const
Returns the units of the data in the workspace.
virtual MantidVec & dataY(const std::size_t index)
Deprecated, use mutableY() instead. Returns the y data.
void setYUnitLabel(const std::string &newLabel)
Sets a new caption for the data (Y axis) in the workspace.
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.
Definition: Run.h:38
Thin object wrapper around a numpy array.
Definition: NDArray.h:31
static bool check(const boost::python::object &obj)
Check if a python object points to an array type object.
Definition: NDArray.cpp:49
Py_intptr_t const * get_shape() const
Definition: NDArray.cpp:61
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.
Definition: IMDIterator.h:25
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)
{ Create a numpy array from the X values of the given workspace reference
double signal_t
Typedef for the signal recorded in a MDBox, etc.
Definition: MDTypes.h:36
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
Definition: cow_ptr.h:172
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...