Mantid
Loading...
Searching...
No Matches
IPeak.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 +
14#include <boost/python/class.hpp>
15#include <boost/python/register_ptr_to_python.hpp>
16#include <optional>
17
20using namespace Mantid::PythonInterface;
21using namespace boost::python;
23
25
26namespace {
27using namespace Mantid::PythonInterface;
28Mantid::Geometry::PeakShape_sptr getPeakShape(const IPeak &peak) {
29 // Use clone to make a copy of the PeakShape.
31}
32void setPeakShape(IPeak &peak, Mantid::Geometry::PeakShape_sptr shape) { peak.setPeakShape(shape->clone()); }
33void setQLabFrame1(IPeak &peak, Mantid::Kernel::V3D qLabFrame) {
34 // Set the q lab frame. No explicit detector distance.
35 return peak.setQLabFrame(qLabFrame, std::nullopt);
36}
37void setQLabFrame2(IPeak &peak, Mantid::Kernel::V3D qLabFrame, double distance) {
38 // Set the q lab frame. Detector distance specified.
39 return peak.setQLabFrame(qLabFrame, distance);
40}
41
42void setQSampleFrame1(IPeak &peak, Mantid::Kernel::V3D qSampleFrame) {
43 // Set the qsample frame. No explicit detector distance.
44 return peak.setQSampleFrame(qSampleFrame, std::nullopt);
45}
46
47void setQSampleFrame2(IPeak &peak, Mantid::Kernel::V3D qSampleFrame, double distance) {
48 // Set the qsample frame. Detector distance specified.
49 return peak.setQSampleFrame(qSampleFrame, distance);
50}
51
52void setGoniometerMatrix(IPeak &self, const object &data) {
54}
55
56} // namespace
57
59 // return_value_policy for read-only numpy array
60 using return_copy_to_numpy = return_value_policy<Policies::MatrixToNumpy>;
61
62 register_ptr_to_python<IPeak *>();
63
64 class_<IPeak, boost::noncopyable>("IPeak", no_init)
65 .def("getRunNumber", &IPeak::getRunNumber, arg("self"), "Return the run number this peak was measured at")
66 .def("getIntMNP", &IPeak::getIntMNP, arg("self"), "Return the modulated scructure for this peak")
67 .def("getPeakNumber", &IPeak::getPeakNumber, arg("self"), "Return the peak number for this peak")
68 .def("setRunNumber", &IPeak::setRunNumber, (arg("self"), arg("run_number")),
69 "Set the run number that measured this peak")
70 .def("setIntMNP", &IPeak::setIntMNP, (arg("self"), arg("modulated_structure")),
71 "Set the modulated structure for this peak")
72 .def("setPeakNumber", &IPeak::setPeakNumber, (arg("self"), arg("peak_number")),
73 "Set the peak number for this peak")
74 .def("getMonitorCount", &IPeak::getMonitorCount, arg("self"), "Get the monitor count set for this peak")
75 .def("setMonitorCount", &IPeak::setMonitorCount, (arg("self"), arg("monitor_count")),
76 "Set the monitor count for this peak")
77 .def("getH", &IPeak::getH, arg("self"), "Get the H index of the peak")
78 .def("getK", &IPeak::getK, arg("self"), "Get the K index of the peak")
79 .def("getL", &IPeak::getL, arg("self"), "Get the L index of the peak")
80 .def("getHKL", &IPeak::getHKL, arg("self"), "Get HKL as a :class:`~mantid.kernel.V3D` object")
81 .def("getIntHKL", &IPeak::getIntHKL, arg("self"), "Get HKL as a :class:`~mantid.kernel.V3D` object")
82 .def("setIntHKL", &IPeak::setIntHKL, (arg("self"), arg("hkl")), "Set the integer HKL for this peak")
83 .def("getSamplePos", &IPeak::getSamplePos, arg("self"),
84 "Get the cached samplePos as a :class:`~mantid.kernel.V3D` object")
85 .def("setHKL", (void (IPeak::*)(double, double, double))&IPeak::setHKL,
86 (arg("self"), arg("h"), arg("k"), arg("l")), "Set the HKL values of this peak")
87 .def("setSamplePos", (void (IPeak::*)(double, double, double))&IPeak::setSamplePos,
88 (arg("self"), arg("samX"), arg("samY"), arg("samZ")),
89 "Set the samplePos value of this peak. It does not set the "
90 "instrument sample position.")
91 .def("setSamplePos", (void (IPeak::*)(const Mantid::Kernel::V3D &))&IPeak::setSamplePos,
92 (arg("self"), arg("newPos")),
93 "Set the samplePos value of this peak. It does not set the "
94 "instrument sample position.")
95 .def("setH", &IPeak::setH, (arg("self"), arg("h")), "Get the H index of the peak")
96 .def("setK", &IPeak::setK, (arg("self"), arg("k")), "Get the K index of the peak")
97 .def("setL", &IPeak::setL, (arg("self"), arg("l")), "Get the L index of the peak")
98 .def("getQLabFrame", &IPeak::getQLabFrame, arg("self"),
99 "Return the Q change (of the lattice, k_i - k_f) for this peak.\n"
100 "The Q is in the Lab frame: the "
101 ":class:`~mantid.geometry.Goniometer` rotation was NOT taken "
102 "out.\n"
103 "Note: There is no 2*pi factor used, so \\|Q| = 1/wavelength.")
104 .def("getQSampleFrame", &IPeak::getQSampleFrame, arg("self"),
105 "Return the Q change (of the lattice, k_i - k_f) for this peak."
106 "The Q is in the Sample frame: the "
107 ":class:`~mantid.geometry.Goniometer` rotation WAS taken "
108 "out. ")
109 .def("setQLabFrame", setQLabFrame1, (arg("self"), arg("qlab_frame")),
110 "Set the peak using the peak's "
111 "position in reciprocal space, in "
112 "the lab frame.")
113 .def("setQLabFrame", setQLabFrame2, (arg("self"), arg("qlab_frame"), arg("distance")),
114 "Set the peak using the peak's position in reciprocal space, in the "
115 "lab frame. :class:`~mantid.geometry.Detector` distance explicitly "
116 "supplied.") // two argument
117 // overload
118 .def("setQSampleFrame", setQSampleFrame1, (arg("self"), arg("qsample_frame")),
119 "Set the peak using the peak's "
120 "position in reciprocal space, "
121 "in the sample frame.")
122 .def("setQSampleFrame", setQSampleFrame2, (arg("self"), arg("qsample_frame"), arg("distance")),
123 "Set the peak using the peak's position in reciprocal space, in the "
124 "sample frame. :class:`~mantid.geometry.Detector` distance "
125 "explicitly supplied.")
126 .def("setWavelength", &IPeak::setWavelength, (arg("self"), arg("wave_length")),
127 "Set the incident wavelength of the neutron. Calculates the energy "
128 "from this assuming elastic scattering.")
129 .def("getWavelength", &IPeak::getWavelength, arg("self"), "Return the incident wavelength")
130 .def("getScattering", &IPeak::getScattering, arg("self"), "Calculate the scattering angle of the peak")
131 .def("getAzimuthal", &IPeak::getAzimuthal, arg("self"), "Calculate the azimuthal angle of the peak")
132 .def("getDSpacing", &IPeak::getDSpacing, arg("self"), "Calculate the d-spacing of the peak, in 1/Angstroms")
133 .def("getTOF", &IPeak::getTOF, arg("self"),
134 "Calculate the time of flight (in "
135 "microseconds) of the neutrons for this "
136 "peak")
137 .def("getInitialEnergy", &IPeak::getInitialEnergy, arg("self"),
138 "Get the initial (incident) neutron energy in meV.")
139 .def("getFinalEnergy", &IPeak::getFinalEnergy, arg("self"), "Get the final neutron energy in meV.")
140 .def("getEnergyTransfer", &IPeak::getEnergyTransfer, arg("self"),
141 "Get the initial neutron energy minus the final neutron energy in "
142 "meV."
143 "\n\n.. versionadded:: 3.12.0")
144 .def("setInitialEnergy", &IPeak::setInitialEnergy, (arg("self"), arg("initial_energy")),
145 "Set the initial (incident) neutron energy in meV.")
146 .def("setFinalEnergy", &IPeak::setFinalEnergy, (arg("self"), arg("final_energy")),
147 "Set the final neutron energy in meV.")
148 .def("getIntensity", &IPeak::getIntensity, arg("self"), "Return the integrated peak intensity")
149 .def("getSigmaIntensity", &IPeak::getSigmaIntensity, arg("self"),
150 "Return the error on the integrated peak intensity")
151 .def("getIntensityOverSigma", &IPeak::getIntensityOverSigma, arg("self"),
152 "Return the error on the integrated peak intensity divided by the "
153 "error in intensity.\n\n.. versionadded:: 3.12.0")
154 .def("setIntensity", &IPeak::setIntensity, (arg("self"), arg("intensity")), "Set the integrated peak intensity")
155 .def("setSigmaIntensity", &IPeak::setSigmaIntensity, (arg("self"), arg("sigma_intensity")),
156 "Set the error on the integrated peak intensity")
157 .def("setAbsorptionWeightedPathLength", &IPeak::setAbsorptionWeightedPathLength, (arg("self"), arg("pathLength")),
158 "Set the absorption weighted path length")
159 .def("getBinCount", &IPeak::getBinCount, arg("self"), "Return the # of counts in the bin at its peak")
160 .def("setBinCount", &IPeak::setBinCount, (arg("self"), arg("bin_count")),
161 "Set the # of counts in the bin at its peak")
162 .def("getGoniometerMatrix", &IPeak::getGoniometerMatrix, arg("self"), return_copy_to_numpy(),
163 "Get the :class:`~mantid.geometry.Goniometer` rotation matrix of "
164 "this peak."
165 "\n\n.. versionadded:: 3.12.0")
166 .def("setGoniometerMatrix", &setGoniometerMatrix, (arg("self"), arg("goniometerMatrix")),
167 "Set the :class:`~mantid.geometry.Goniometer` rotation matrix of "
168 "this peak.")
169 .def("getDetectorID", &IPeak::getDetectorID, arg("self"), "Return thhe pixel ID of the detector.")
170 .def("getRow", &IPeak::getRow, arg("self"),
171 "For :class:`~mantid.geometry.RectangularDetector` s only, returns "
172 "the row (y) of the pixel of the "
173 "detector.")
174 .def("getCol", &IPeak::getCol, arg("self"),
175 "For :class:`~mantid.geometry.RectangularDetector` s only, returns "
176 "the column (x) of the pixel of the "
177 ":class:`~mantid.geometry.Detector`.")
178 .def("getL1", &IPeak::getL1, arg("self"),
179 "Return the L1 flight path length (source to "
180 ":class:`~mantid.api.Sample`), in meters. ")
181 .def("getL2", &IPeak::getL2, arg("self"),
182 "Return the L2 flight path length (:class:`~mantid.api.Sample` to "
183 ":class:`~mantid.geometry.Detector`), in meters.")
184 .def("getPeakShape", getPeakShape, arg("self"), "Get the peak shape")
185 .def("setPeakShape", setPeakShape, (arg("self"), arg("shape")), "Set the peak shape")
186 .def("getAbsorptionWeightedPathLength", &IPeak::getAbsorptionWeightedPathLength, arg("self"),
187 "Get the absorption weighted path length")
188 .def("getReferenceFrame", (std::shared_ptr<const ReferenceFrame> (IPeak::*)())&IPeak::getReferenceFrame,
189 arg("self"), return_value_policy<RemoveConstSharedPtr>(),
190 "Returns the :class:`~mantid.geometry.ReferenceFrame` attached that "
191 "defines the instrument axes")
192 .def("getDetectorDirectionSampleFrame", &IPeak::getDetectorDirectionSampleFrame, arg("self"),
193 "Return the direction of the scattered beam for this peak."
194 "The direction is in the Sample frame: the "
195 ":class:`~mantid.geometry.Goniometer` rotation WAS taken "
196 "out. ")
197 .def("getSourceDirectionSampleFrame", &IPeak::getSourceDirectionSampleFrame, arg("self"),
198 "Return the direction of the reverse incident beam for this peak."
199 "The direction is in the Sample frame: the "
200 ":class:`~mantid.geometry.Goniometer` rotation WAS taken "
201 "out. ");
202}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition GetPointer.h:17
void export_IPeak()
Definition IPeak.cpp:58
Structure describing a single-crystal peak.
Definition IPeak.h:26
virtual double getH() const =0
virtual void setHKL(double H, double K, double L)=0
virtual void setIntensity(double m_Intensity)=0
virtual double getTOF() const =0
virtual void setK(double m_K)=0
virtual double getScattering() const =0
virtual Mantid::Kernel::Matrix< double > getGoniometerMatrix() const =0
virtual void setBinCount(double m_BinCount)=0
virtual void setQLabFrame(const Mantid::Kernel::V3D &QLabFrame, std::optional< double > detectorDistance)=0
virtual double getSigmaIntensity() const =0
virtual void setPeakShape(Mantid::Geometry::PeakShape *shape)=0
virtual int getDetectorID() const =0
virtual double getWavelength() const =0
virtual int getPeakNumber() const =0
virtual Mantid::Kernel::V3D getSamplePos() const =0
virtual void setH(double m_H)=0
virtual double getDSpacing() const =0
virtual void setGoniometerMatrix(const Mantid::Kernel::Matrix< double > &m_GoniometerMatrix)=0
virtual void setPeakNumber(int m_PeakNumber)=0
virtual double getBinCount() const =0
virtual Mantid::Kernel::V3D getIntHKL() const =0
virtual double getInitialEnergy() const =0
virtual double getK() const =0
virtual void setIntMNP(const Mantid::Kernel::V3D &MNP)=0
virtual int getRow() const =0
virtual double getEnergyTransfer() const =0
virtual double getAbsorptionWeightedPathLength() const =0
virtual double getL2() const =0
virtual void setAbsorptionWeightedPathLength(double pathLength)=0
virtual void setFinalEnergy(double m_FinalEnergy)=0
virtual int getCol() const =0
virtual std::shared_ptr< const Geometry::ReferenceFrame > getReferenceFrame() const =0
virtual void setInitialEnergy(double m_InitialEnergy)=0
virtual void setMonitorCount(double m_MonitorCount)=0
virtual int getRunNumber() const =0
virtual Mantid::Kernel::V3D getQSampleFrame() const =0
virtual double getIntensity() const =0
virtual double getL() const =0
virtual void setSigmaIntensity(double m_SigmaIntensity)=0
virtual const Mantid::Geometry::PeakShape & getPeakShape() const =0
virtual double getFinalEnergy() const =0
virtual double getAzimuthal() const =0
virtual void setL(double m_L)=0
virtual Mantid::Kernel::V3D getQLabFrame() const =0
virtual double getL1() const =0
virtual void setSamplePos(double samX, double samY, double samZ)=0
virtual void setRunNumber(int m_RunNumber)=0
virtual void setIntHKL(const Mantid::Kernel::V3D &HKL)=0
virtual Mantid::Kernel::V3D getHKL() const =0
virtual Mantid::Kernel::V3D getIntMNP() const =0
virtual void setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame, std::optional< double > detectorDistance)=0
virtual double getIntensityOverSigma() const =0
virtual Mantid::Kernel::V3D getDetectorDirectionSampleFrame() const =0
virtual Mantid::Kernel::V3D getSourceDirectionSampleFrame() const =0
virtual void setWavelength(double wavelength)=0
virtual double getMonitorCount() const =0
virtual PeakShape * clone() const =0
Deep copy this.
ReferenceFrame : Holds reference frame information from the geometry description file.
Class for 3D vectors.
Definition V3D.h:34
std::shared_ptr< PeakShape > PeakShape_sptr
Definition PeakShape.h:42
Takes a Python object and if it supports indexing and is two dimensional it attempts to convert it to...
Implements the RemoveConstSharedPtr policy.