Mantid
Loading...
Searching...
No Matches
Instrument.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 +
13
14#include <boost/python/class.hpp>
15#include <boost/python/overloads.hpp>
16#include <boost/python/register_ptr_to_python.hpp>
17
18using namespace Mantid::Geometry;
19using Mantid::detid_t;
20using namespace boost::python;
22
24
25namespace {
26
27// Ignore -Wconversion warnings coming from boost::python
28// Seen with GCC 7.1.1 and Boost 1.63.0
29GNU_DIAG_OFF("conversion")
30
31BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Instrument_getNumberDetectors, Instrument::getNumberDetectors, 0, 1)
32
33GNU_DIAG_ON("conversion")
34
35} // namespace
36
38 register_ptr_to_python<std::shared_ptr<Instrument>>();
39
40 class_<Instrument, bases<CompAssembly>, boost::noncopyable>("Instrument", no_init)
41 .def("getSample", &Instrument::getSample, arg("self"), return_value_policy<RemoveConstSharedPtr>(),
42 "Return the :class:`~mantid.geometry.Component` object that "
43 "represents the sample")
44
45 .def("getSource", &Instrument::getSource, arg("self"), return_value_policy<RemoveConstSharedPtr>(),
46 "Return the :class:`~mantid.geometry.Component` object that "
47 "represents the source")
48
49 .def("getComponentByName",
50 (std::shared_ptr<const IComponent>(Instrument::*)(const std::string &, int) const) &
51 Instrument::getComponentByName,
52 (arg("self"), arg("cname"), arg("nlevels") = 0), "Returns the named :class:`~mantid.geometry.Component`")
53
54 .def("getDetector",
55 (std::shared_ptr<const IDetector>(Instrument::*)(const detid_t &) const) & Instrument::getDetector,
56 (arg("self"), arg("detector_id")), "Returns the :class:`~mantid.geometry.Detector` with the given ID")
57
58 .def("getNumberDetectors", &Instrument::getNumberDetectors,
59 Instrument_getNumberDetectors((arg("self"), arg("skipMonitors") = false)))
60
61 .def("getReferenceFrame",
62 (std::shared_ptr<const ReferenceFrame>(Instrument::*)()) & Instrument::getReferenceFrame, arg("self"),
63 return_value_policy<RemoveConstSharedPtr>(),
64 "Returns the :class:`~mantid.geometry.ReferenceFrame` attached that "
65 "defines the instrument "
66 "axes")
67
68 .def("getValidFromDate", &Instrument::getValidFromDate, arg("self"),
69 "Return the valid from :class:`~mantid.kernel.DateAndTime` of the "
70 "instrument")
71
72 .def("getValidToDate", &Instrument::getValidToDate, arg("self"),
73 "Return the valid to :class:`~mantid.kernel.DateAndTime` of the "
74 "instrument")
75
76 .def("getBaseInstrument", &Instrument::baseInstrument, arg("self"), return_value_policy<RemoveConstSharedPtr>(),
77 "Return reference to the base instrument")
78
79 .def("findRectDetectors", &Instrument::findRectDetectors, arg("self"), "Return a list of rectangular detectors.");
80}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition: GetPointer.h:17
void export_Instrument()
Definition: Instrument.cpp:37
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.
Base Instrument Class.
Definition: Instrument.h:47
std::size_t getNumberDetectors(bool skipMonitors=false) const
Definition: Instrument.cpp:222
IComponent_const_sptr getSource() const
Gets a pointer to the source.
Definition: Instrument.cpp:322
std::shared_ptr< const Instrument > baseInstrument() const
Pointer to the 'real' instrument, for parametrized instruments.
Definition: Instrument.cpp:124
std::vector< RectangularDetector_const_sptr > findRectDetectors() const
Types::Core::DateAndTime getValidFromDate() const
Definition: Instrument.h:169
std::shared_ptr< const ReferenceFrame > getReferenceFrame() const
Get refernce Frame.
IDetector_const_sptr getDetector(const detid_t &detector_id) const
Gets a pointer to the detector from its ID Note that for getting the detector associated with a spect...
Definition: Instrument.cpp:461
Types::Core::DateAndTime getValidToDate() const
Definition: Instrument.h:172
IComponent_const_sptr getSample() const
Gets a pointer to the Sample Position.
Definition: Instrument.cpp:348
int32_t detid_t
Typedef for a detector ID.
Definition: SpectrumInfo.h:21
Implements the RemoveConstSharedPtr policy.
Definition: RemoveConst.h:119