Mantid
Loading...
Searching...
No Matches
Goniometer.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
14#include <boost/python/class.hpp>
15#include <boost/python/dict.hpp>
16#include <boost/python/overloads.hpp>
17
20using namespace Mantid::PythonInterface;
21using namespace boost::python;
22
23namespace //<unnamed>
24{
26GNU_DIAG_OFF("unused-local-typedef")
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// define overloaded functions
31// cppcheck-suppress unknownMacro
32BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getEulerAngles_overloads, Goniometer::getEulerAngles, 0, 1)
33GNU_DIAG_ON("conversion")
34GNU_DIAG_ON("unused-local-typedef")
36
38void setR(Goniometer &self, const object &data) { self.setR(Converters::PyObjectToMatrix(data)()); }
39
41void calcFromQSampleAndWavelength(Goniometer &self, const object &position, double wavelength, bool flip_x,
42 bool inner) {
43 self.calcFromQSampleAndWavelength(Converters::PyObjectToV3D(position)(), wavelength, flip_x, inner);
44}
45
46boost::python::dict getAxis(const Goniometer &self, size_t axisnumber) {
47 const auto &axis = self.getAxis(axisnumber);
48
49 boost::python::dict pythonAxis;
50 pythonAxis["rotationaxis"] = axis.rotationaxis;
51 pythonAxis["angle"] = axis.angle;
52 pythonAxis["sense"] = axis.sense;
53
54 return pythonAxis;
55}
56} // namespace
57
59
60 // return_value_policy for read-only numpy array
61 using return_readonly_numpy = return_value_policy<Policies::MatrixRefToNumpy<Converters::WrapReadOnly>>;
62
63 class_<Goniometer>("Goniometer", init<>(arg("self")))
64 .def(init<Goniometer const &>((arg("self"), arg("other"))))
65 .def(init<DblMatrix>((arg("self"), arg("rot"))))
66 .def("getEulerAngles", (&Goniometer::getEulerAngles),
67 getEulerAngles_overloads(args("self", "convention"), "Default convention is \'YZX\'. Universal "
68 "goniometer is \'YZY\'"))
69 .def("getR", &Goniometer::getR, arg("self"), return_readonly_numpy())
70 .def("setR", &setR, (arg("self"), arg("rot")))
71 .def("getNumberAxes", &Goniometer::getNumberAxes, arg("self"))
72 .def("getAxis", &getAxis, (arg("self"), arg("axisnumber")))
73 .def("calcFromQSampleAndWavelength", &calcFromQSampleAndWavelength,
74 (arg("self"), arg("positions"), arg("wavelength"), arg("flip_x") = false, arg("inner") = false))
75 .def("getConventionFromMotorAxes", &Goniometer::getConventionFromMotorAxes, arg("self"));
76}
double position
Definition GetAllEi.cpp:154
void export_Goniometer()
#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.
Class to represent a particular goniometer setting, which is described by the rotation matrix.
Definition Goniometer.h:55
std::vector< double > getEulerAngles(const std::string &convention="YZX")
Return Euler angles acording to a convention.
std::string getConventionFromMotorAxes() const
return the goniometer convention used determine from the motor axes
const Kernel::DblMatrix & getR() const
Return global rotation matrix.
void calcFromQSampleAndWavelength(const Mantid::Kernel::V3D &Q, double wavelength, bool flip_x=false, bool inner=false)
Calculate goniometer for rotation around y-asix for constant wavelength from Q Sample.
const GoniometerAxis & getAxis(size_t axisnumber) const
Get GoniometerAxis obfject using motor number.
double angle(const V3D &) const
Angle between this and another vector.
Definition V3D.cpp:162
Kernel::V3D rotationaxis
GoniometerAxis name.
Definition Goniometer.h:40
Takes a Python object and if it supports indexing and is two dimensional it attempts to convert it to...
Takes a Python object and if it supports indexing and is of length 3 then it will attempt to convert ...