Mantid
Loading...
Searching...
No Matches
MDGeometry.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 +
11#include <boost/python/class.hpp>
12#include <boost/python/copy_const_reference.hpp>
13#include <boost/python/list.hpp>
14#include <boost/python/return_value_policy.hpp>
15
19using namespace boost::python;
20
21namespace {
30boost::python::list getNonIntegratedDimensionsAsPyList(const MDGeometry &self) {
31 auto dimensions = self.getNonIntegratedDimensions();
32
33 boost::python::list nonIntegrated;
34 for (auto &dimension : dimensions) {
35 nonIntegrated.append(std::const_pointer_cast<Mantid::Geometry::IMDDimension>(dimension));
36 }
37 return nonIntegrated;
38}
39} // namespace
40
42 class_<MDGeometry, boost::noncopyable>("MDGeometry", no_init)
43 .def("getNumDims", &MDGeometry::getNumDims, arg("self"), "Returns the number of dimensions present")
44 .def("getNumNonIntegratedDims", &MDGeometry::getNumDims, arg("self"),
45 "Returns the number of non-integrated dimensions present")
46 .def("getDimension", &MDGeometry::getDimension, (arg("self"), arg("index")),
47 return_value_policy<RemoveConstSharedPtr>(),
48 "Returns the description of the :class:`~mantid.api.IMDDimension` "
49 "at the given index "
50 "(starts from 0). Raises RuntimeError if index is out of range.")
51
52 .def("getDimensionWithId", &MDGeometry::getDimensionWithId, (arg("self"), arg("id")),
53 return_value_policy<RemoveConstSharedPtr>(),
54 "Returns the description of the :class:`~mantid.api.IMDDimension` "
55 "with the given id string. "
56 "Raises ValueError if the string is not a known id.")
57
58 .def("getDimensionIndexByName", &MDGeometry::getDimensionIndexByName, (arg("self"), arg("name")),
59 "Returns the index of the dimension with the given "
60 "name. Raises RuntimeError if the name does not "
61 "exist.")
62
63 .def("getDimensionIndexById", &MDGeometry::getDimensionIndexById, (arg("self"), arg("id")),
64 "Returns the index of the :class:`~mantid.api.IMDDimension` with "
65 "the given "
66 "ID. Raises RuntimeError if the name does not exist.")
67
68 .def("getNonIntegratedDimensions", &getNonIntegratedDimensionsAsPyList, arg("self"),
69 "Returns the description objects of the non-integrated dimension as "
70 "a python list of :class:`~mantid.api.IMDDimension`.")
71
72 .def("estimateResolution", &MDGeometry::estimateResolution, arg("self"), return_value_policy<VectorToNumpy>(),
73 "Returns a numpy array containing the width of the smallest bin in "
74 "each dimension")
75
76 .def("getXDimension", &MDGeometry::getXDimension, arg("self"), return_value_policy<RemoveConstSharedPtr>(),
77 "Returns the :class:`~mantid.api.IMDDimension` description mapped "
78 "to X")
79
80 .def("getYDimension", &MDGeometry::getYDimension, arg("self"), return_value_policy<RemoveConstSharedPtr>(),
81 "Returns the :class:`~mantid.api.IMDDimension` description mapped "
82 "to Y")
83
84 .def("getZDimension", &MDGeometry::getZDimension, arg("self"), return_value_policy<RemoveConstSharedPtr>(),
85 "Returns the :class:`~mantid.api.IMDDimension` description mapped "
86 "to Z")
87
88 .def("getTDimension", &MDGeometry::getTDimension, arg("self"), return_value_policy<RemoveConstSharedPtr>(),
89 "Returns the :class:`~mantid.api.IMDDimension` description mapped "
90 "to time")
91
92 .def("getGeometryXML", &MDGeometry::getGeometryXML, arg("self"),
93 "Returns an XML representation, as a string, of the geometry of the "
94 "workspace")
95
96 .def("getBasisVector", (const Mantid::Kernel::VMD &(MDGeometry::*)(size_t) const) & MDGeometry::getBasisVector,
97 (arg("self"), arg("index")), return_value_policy<copy_const_reference>(),
98 "Returns a :class:`~mantid.kernel.VMD` object defining the basis "
99 "vector for the specified "
100 "dimension")
101
102 .def("clearOriginalWorkspaces", &MDGeometry::clearOriginalWorkspaces, (arg("self")),
103 "Clear any attached original workspaces")
104
105 .def("hasOriginalWorkspace", &MDGeometry::hasOriginalWorkspace, (arg("self"), arg("index")),
106 "Returns True if there is a source workspace at the given index")
107
108 .def("numOriginalWorkspaces", &MDGeometry::numOriginalWorkspaces, arg("self"),
109 "Returns the number of source workspaces attached")
110
111 .def("getOriginalWorkspace", &MDGeometry::getOriginalWorkspace, (arg("self"), arg("index")),
112 "Returns the source workspace attached at the given index")
113
114 .def("getOrigin", (const Mantid::Kernel::VMD &(MDGeometry::*)() const) & MDGeometry::getOrigin, arg("self"),
115 return_value_policy<copy_const_reference>(),
116 "Returns the vector of the origin (in the original workspace) that "
117 "corresponds to 0,0,0... in this workspace")
118
119 .def("getNumberTransformsFromOriginal", &MDGeometry::getNumberTransformsFromOriginal, arg("self"),
120 "Returns the number of transformations from original workspace "
121 "coordinate systems")
122
123 .def("getNumberTransformsToOriginal", &MDGeometry::getNumberTransformsToOriginal, arg("self"),
124 "Returns the number of transformations to original workspace "
125 "coordinate systems")
126
127 ;
128}
void export_MDGeometry()
Definition: MDGeometry.cpp:41
Describes the geometry (i.e.
Definition: MDGeometry.h:37
Mantid::Kernel::VMD & getOrigin()
Definition: MDGeometry.h:92
std::shared_ptr< const Mantid::Geometry::IMDDimension > getTDimension() const
Get the t-dimension mapping.
Definition: MDGeometry.cpp:268
size_t getNumberTransformsToOriginal() const
Get the number of transforms defined to the original coordinate system.
Definition: MDGeometry.cpp:526
virtual std::shared_ptr< const Mantid::Geometry::IMDDimension > getDimension(size_t index) const
Get a dimension.
Definition: MDGeometry.cpp:161
std::vector< std::shared_ptr< const Geometry::IMDDimension > > getNonIntegratedDimensions() const
Get non-collapsed dimensions.
Definition: MDGeometry.cpp:186
size_t getDimensionIndexById(const std::string &id) const
Get the index of the dimension that matches the ID given.
Definition: MDGeometry.cpp:224
virtual std::shared_ptr< const Mantid::Geometry::IMDDimension > getDimensionWithId(std::string id) const
Get a dimension.
Definition: MDGeometry.cpp:172
size_t numOriginalWorkspaces() const
Definition: MDGeometry.cpp:327
virtual size_t getNumDims() const
Definition: MDGeometry.cpp:148
void clearOriginalWorkspaces()
Clear original workspaces.
Definition: MDGeometry.cpp:126
bool hasOriginalWorkspace(size_t index=0) const
Definition: MDGeometry.cpp:320
virtual std::vector< coord_t > estimateResolution() const
Definition: MDGeometry.cpp:196
std::string getGeometryXML() const
Definition: MDGeometry.cpp:496
std::shared_ptr< Workspace > getOriginalWorkspace(size_t index=0) const
Get the "original" workspace (the workspace that was the source for a binned MDWorkspace).
Definition: MDGeometry.cpp:340
Mantid::Kernel::VMD & getBasisVector(size_t index)
Get the basis vector (in the original workspace) for a dimension of this workspace.
Definition: MDGeometry.cpp:280
size_t getDimensionIndexByName(const std::string &name) const
Get the index of the dimension that matches the name given.
Definition: MDGeometry.cpp:210
std::shared_ptr< const Mantid::Geometry::IMDDimension > getXDimension() const
Get the x-dimension mapping.
Definition: MDGeometry.cpp:247
size_t getNumberTransformsFromOriginal() const
Get the number of transforms defined from the original coordinate system.
Definition: MDGeometry.cpp:532
std::shared_ptr< const Mantid::Geometry::IMDDimension > getYDimension() const
Get the y-dimension mapping.
Definition: MDGeometry.cpp:254
std::shared_ptr< const Mantid::Geometry::IMDDimension > getZDimension() const
Get the z-dimension mapping.
Definition: MDGeometry.cpp:261
Implements the RemoveConstSharedPtr policy.
Definition: RemoveConst.h:119
Implements a return value policy that returns a numpy array from a function returning a std::vector b...