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 +
12
13#include <boost/python/class.hpp>
14#include <boost/python/copy_const_reference.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 // cppcheck-suppress cstyleCast
56 (std::shared_ptr<const IDetector> (Instrument::*)(const detid_t &) const) & Instrument::getDetector,
57 (arg("self"), arg("detector_id")), "Returns the :class:`~mantid.geometry.Detector` with the given ID")
58
59 .def("getDefaultView", &Instrument::getDefaultView, arg("self"), return_value_policy<copy_const_reference>(),
60 "Return the name of the preferred view in instrument view.")
61
62 .def("getNumberDetectors", &Instrument::getNumberDetectors,
63 Instrument_getNumberDetectors((arg("self"), arg("skipMonitors") = false)))
64
65 .def("getReferenceFrame", (std::shared_ptr<const ReferenceFrame> (Instrument::*)())&Instrument::getReferenceFrame,
66 arg("self"), return_value_policy<RemoveConstSharedPtr>(),
67 "Returns the :class:`~mantid.geometry.ReferenceFrame` attached that "
68 "defines the instrument "
69 "axes")
70
71 .def("getValidFromDate", &Instrument::getValidFromDate, arg("self"),
72 "Return the valid from :class:`~mantid.kernel.DateAndTime` of the "
73 "instrument")
74
75 .def("getValidToDate", &Instrument::getValidToDate, arg("self"),
76 "Return the valid to :class:`~mantid.kernel.DateAndTime` of the "
77 "instrument")
78
79 .def("getFilename", &Instrument::getFilename, arg("self"), return_value_policy<copy_const_reference>(),
80 "Return the name of the file that the original IDF was from")
81
82 .def("setFilename", &Instrument::setFilename, (arg("self"), arg("filename")),
83 "Set the name of the file that the original IDF was from")
84
85 .def("getBaseInstrument", &Instrument::baseInstrument, arg("self"), return_value_policy<RemoveConstSharedPtr>(),
86 "Return reference to the base instrument")
87
88 .def("findRectDetectors", &Instrument::findRectDetectors, arg("self"), "Return a list of rectangular detectors.")
89 .def("findGridDetectors", &Instrument::findGridDetectors, arg("self"), "Return a list of grid detectors.");
90}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition GetPointer.h:17
void export_Instrument()
#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
IComponent_const_sptr getSource() const
Gets a pointer to the source.
std::vector< GridDetector_const_sptr > findGridDetectors() const
Definition Instrument.h:211
std::shared_ptr< const Instrument > baseInstrument() const
Pointer to the 'real' instrument, for parametrized instruments.
std::vector< RectangularDetector_const_sptr > findRectDetectors() const
Definition Instrument.h:208
const std::string & getFilename() const
const std::string & getDefaultView() const
Get the default type of the instrument view.
Definition Instrument.h:147
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...
void setFilename(const std::string &filename)
Set the path to the original IDF .xml file that was loaded for this instrument.
Types::Core::DateAndTime getValidToDate() const
Definition Instrument.h:172
IComponent_const_sptr getSample() const
Gets a pointer to the Sample Position.
int32_t detid_t
Typedef for a detector ID.
Implements the RemoveConstSharedPtr policy.