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