Mantid
Loading...
Searching...
No Matches
SpectrumInfo.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 "MantidTypes/SpectrumDefinition.h"
12
13#include <boost/python/class.hpp>
14#include <boost/python/copy_const_reference.hpp>
15#include <boost/python/list.hpp>
16#include <boost/python/return_value_policy.hpp>
17#include <boost/python/tuple.hpp>
18
19using Mantid::SpectrumDefinition;
25using namespace boost::python;
26
27// Helper method to make the python iterator
29 return SpectrumInfoPythonIterator(spectrumInfo);
30}
31
32PyObject *geographicalAngles(const SpectrumInfo &spectrumInfo, const size_t index) {
33 const auto angles = spectrumInfo.geographicalAngles(index);
34 return incref(make_tuple(angles.first, angles.second).ptr());
35}
36
37// Export SpectrumInfo
39 class_<SpectrumInfo, boost::noncopyable>("SpectrumInfo", no_init)
40 .def("__iter__", make_pyiterator)
41 .def("__len__", &SpectrumInfo::size, arg("self"), "Returns the number of spectra.")
42 .def("size", &SpectrumInfo::size, arg("self"), "Returns the number of spectra.")
43 .def("isMonitor", &SpectrumInfo::isMonitor, (arg("self"), arg("index")),
44 "Returns True if the detector(s) associated with the spectrum are "
45 "monitors.")
46 .def("isMasked", &SpectrumInfo::isMasked, (arg("self"), arg("index")),
47 "Returns True if the detector(s) associated with the spectrum are "
48 "masked.")
49 .def("setMasked", &SpectrumInfo::setMasked, (arg("self"), arg("index"), arg("masked")),
50 "Set the mask flag of the spectrum with the given index.")
51 .def("twoTheta", &SpectrumInfo::twoTheta, (arg("self"), arg("index")),
52 "Returns the scattering angle 2 theta in radians w.r.t. beam "
53 "direction.")
54 .def("signedTwoTheta", &SpectrumInfo::signedTwoTheta, (arg("self"), arg("index")),
55 "Returns the signed scattering angle 2 theta in radians w.r.t. beam "
56 "direction.")
57 .def("azimuthal", &SpectrumInfo::azimuthal, (arg("self"), arg("index")),
58 "Returns the out-of-plane angle in radians angle w.r.t. to "
59 "vecPointingHorizontal "
60 "direction.")
61 .def("geographicalAngles", &geographicalAngles, (arg("self"), arg("index")),
62 "Returns the latitude and longitude for given spectrum index. "
63 "The returned value is a pair of (latitude, longitude)")
64 .def("l1", &SpectrumInfo::l1, arg("self"), "Returns the distance from the source to the sample.")
65 .def("l2", &SpectrumInfo::l2, (arg("self"), arg("index")),
66 "Returns the distance from the sample to the spectrum.")
67 .def("hasDetectors", &SpectrumInfo::hasDetectors, (arg("self")),
68 "Returns True if the spectrum is associated with detectors in the "
69 "instrument.")
70 .def("hasUniqueDetector", &SpectrumInfo::hasUniqueDetector, (arg("self"), arg("index")),
71 "Returns True if the spectrum is associated with exactly one "
72 "detector.")
73 .def("position", &SpectrumInfo::position, (arg("self"), arg("index")),
74 "Returns the absolute position of the spectrum with the given "
75 "index.")
76 .def("sourcePosition", &SpectrumInfo::sourcePosition, arg("self"), "Returns the absolute source position.")
77 .def("samplePosition", &SpectrumInfo::samplePosition, arg("self"), "Returns the absolute sample position.")
78 .def("getSpectrumDefinition", &SpectrumInfo::spectrumDefinition, return_value_policy<return_by_value>(),
79 (arg("self"), arg("index")),
80 "Returns the SpectrumDefinition of the spectrum with the given "
81 "index.")
82 .def("detectorCount", &SpectrumInfo::detectorCount, arg("self"),
83 "Returns the total number of detectors used across spectrum info.")
84 .def("difcUncalibrated", &SpectrumInfo::difcUncalibrated, (arg("self"), arg("index")),
85 "Return the uncalibrated difc diffractometer constant")
86 .def("diffractometerConstants",
87 (UnitParametersMap(SpectrumInfo::*)(const size_t) const) & SpectrumInfo::diffractometerConstants,
88 (arg("self"), arg("index")), "Return the diffractometer constants");
89}
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
PyObject * geographicalAngles(const SpectrumInfo &spectrumInfo, const size_t index)
void export_SpectrumInfo()
SpectrumInfoPythonIterator make_pyiterator(SpectrumInfo &spectrumInfo)
API::SpectrumInfo is an intermediate step towards a SpectrumInfo that is part of Instrument-2....
Definition: SpectrumInfo.h:53
double signedTwoTheta(const size_t index) const
Returns the signed scattering angle 2 theta in radians (angle w.r.t.
bool isMonitor(const size_t index) const
Returns true if the detector(s) associated with the spectrum are monitors.
Kernel::V3D sourcePosition() const
Returns the source position.
Kernel::UnitParametersMap diffractometerConstants(const size_t index, std::vector< detid_t > &uncalibratedDets) const
Calculate average diffractometer constants (DIFA, DIFC, TZERO) of detectors associated with this spec...
void setMasked(const size_t index, bool masked)
Set the mask flag of the spectrum with given index.
Kernel::V3D samplePosition() const
Returns the sample position.
bool hasDetectors(const size_t index) const
Returns true if the spectrum is associated with detectors in the instrument.
double twoTheta(const size_t index) const
Returns the scattering angle 2 theta in radians (angle w.r.t.
double difcUncalibrated(const size_t index) const
Calculate average uncalibrated DIFC value of detectors associated with this spectrum.
Kernel::V3D position(const size_t index) const
Returns the position of the spectrum with given index.
double l2(const size_t index) const
Returns L2 (distance from sample to spectrum).
double azimuthal(const size_t index) const
Returns the out-of-plane angle in radians (angle w.r.t.
bool isMasked(const size_t index) const
Returns true if the detector(s) associated with the spectrum are masked.
bool hasUniqueDetector(const size_t index) const
Returns true if the spectrum is associated with exactly one detector.
const SpectrumDefinition & spectrumDefinition(const size_t index) const
Returns a const reference to the SpectrumDefinition of the spectrum.
size_t size() const
Returns the size of the SpectrumInfo, i.e., the number of spectra.
double l1() const
Returns L1 (distance from source to sample).
size_t detectorCount() const
std::pair< double, double > geographicalAngles(const size_t index) const
Calculate latitude and longitude for given spectrum index.
std::unordered_map< UnitParams, double > UnitParametersMap
Definition: Unit.h:30