12#include "MantidTypes/SpectrumDefinition.h"
14#include <boost/python/class.hpp>
15#include <boost/python/copy_const_reference.hpp>
16#include <boost/python/list.hpp>
17#include <boost/python/return_value_policy.hpp>
18#include <boost/python/tuple.hpp>
20using Mantid::SpectrumDefinition;
36 return incref(make_tuple(angles.first, angles.second).ptr());
42 return observer.is_none() ? self.
samplePosition() : extract<V3D>(observer)();
48 return extract<V3D>(axis)();
50 if (beamLine.nullVector())
56 if (observer.is_none() && axis.is_none())
58 return self.
twoTheta(
index, observerOrSample(self, observer), axisOrBeam(self, axis));
61double signedTwoTheta(
const SpectrumInfo &self,
const size_t index,
const object &observer,
const object &axis,
62 const object &instrumentUp) {
63 if (observer.is_none() && axis.is_none() && instrumentUp.is_none())
65 if (instrumentUp.is_none())
66 return self.
signedTwoTheta(
index, observerOrSample(self, observer), axisOrBeam(self, axis));
68 extract<V3D>(instrumentUp)());
74 class_<SpectrumInfo, boost::noncopyable>(
"SpectrumInfo", no_init)
79 "Returns True if the detector(s) associated with the spectrum are "
82 "Returns True if the detector(s) associated with the spectrum are "
85 "Set the mask flag of the spectrum with the given index.")
86 .def(
"twoTheta", &twoTheta, (arg(
"self"), arg(
"index"), arg(
"observer") =
object(), arg(
"axis") =
object()),
87 "Returns the average angle in radians between the vectors from the observer to the detector(s) and the "
88 "axis. The observer defaults to the sample position and the axis to the beam direction, giving the "
89 "scattering angle 2 theta. With both defaults, monitors raise an error.")
90 .def(
"signedTwoTheta", &signedTwoTheta,
91 (arg(
"self"), arg(
"index"), arg(
"observer") =
object(), arg(
"axis") =
object(),
92 arg(
"instrumentUp") =
object()),
93 "Returns the average signed angle in radians between the vectors from the observer to the detector(s) and "
94 "the axis. The observer defaults to the sample position, the axis to the beam direction and instrumentUp "
95 "to the instrument's theta-sign axis, giving the signed scattering angle 2 theta. With all defaults, "
96 "monitors raise an error.")
98 "Returns the out-of-plane angle in radians angle w.r.t. to "
99 "vecPointingHorizontal "
102 "Returns the angle in radians of the spectrum position about the lab-frame z axis, atan2(y, x).")
104 "Returns phi reflected about the offset (radians): offset - phi for phi >= 0, otherwise "
107 "Returns the latitude and longitude for given spectrum index. "
108 "The returned value is a pair of (latitude, longitude)")
109 .def(
"l1", &
SpectrumInfo::l1, arg(
"self"),
"Returns the distance from the source to the sample.")
111 "Returns the distance from the sample to the spectrum.")
113 "Returns True if the spectrum is associated with detectors in the "
116 "Returns True if the spectrum is associated with exactly one "
119 "Returns the absolute position of the spectrum with the given "
124 (arg(
"self"), arg(
"index")),
125 "Returns the SpectrumDefinition of the spectrum with the given "
128 "Returns the total number of detectors used across spectrum info.")
130 "Return the uncalibrated difc diffractometer constant")
131 .def(
"diffractometerConstants",
133 (arg(
"self"), arg(
"index")),
"Return the diffractometer constants");
std::map< DeltaEMode::Type, std::string > index
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....
double signedTwoTheta(const size_t index) const
Returns the signed scattering angle 2 theta in radians (angle w.r.t.
double phiOffset(const size_t index, const double offset) const
Returns phi() reflected about offset (radians): offset - phi for phi >= 0 and -(offset + phi) otherwi...
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.
double phi(const size_t index) const
Returns the angle of the spectrum position about the lab-frame z axis, atan2(y, x),...
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.
Exception for errors associated with the instrument definition.
SpectrumInfoPythonIterator.
std::unordered_map< UnitParams, double > UnitParametersMap