25#include "pybind11/pybind11.h"
26#include "pybind11/eigen.h"
34using namespace pybind11::literals;
41 using PyAstrometryTransform = py::class_<AstrometryTransform, std::shared_ptr<AstrometryTransform>>;
43 wrappers.
wrapType(PyAstrometryTransform(wrappers.module,
"AstrometryTransform"), [](
auto &mod,
auto &cls) {
45 (jointcal::Point(AstrometryTransform::*)(const jointcal::Point &) const) &
46 AstrometryTransform::apply,
49 (jointcal::Frame(AstrometryTransform::*)(Frame const &, bool) const) &AstrometryTransform::apply,
50 "inputframe"_a,
"inscribed"_a);
51 cls.def(
"getNpar", &AstrometryTransform::getNpar);
52 cls.def(
"offsetParams", &AstrometryTransform::offsetParams);
53 cls.def(
"linearApproximation", &AstrometryTransform::linearApproximation);
54 cls.def(
"computeDerivative", [](AstrometryTransform const &self, Point const &where, double const step) {
55 AstrometryTransformLinear derivative;
56 self.computeDerivative(where, derivative, step);
65 using PyAstrometryTransformIdentity =
66 py::class_<AstrometryTransformIdentity, std::shared_ptr<AstrometryTransformIdentity>, AstrometryTransform>;
68 wrappers.
wrapType(PyAstrometryTransformIdentity(wrappers.module,
"AstrometryTransformIdentity"),
69 [](
auto &mod,
auto &cls) {});
73 using PyAstrometryTransformPolynomial = py::class_<AstrometryTransformPolynomial, std::shared_ptr<AstrometryTransformPolynomial>,
77 PyAstrometryTransformPolynomial(wrappers.module,
"AstrometryTransformPolynomial"),
78 [](
auto &mod,
auto &cls) {
79 cls.def(py::init<const unsigned>(),
"order"_a);
80 cls.def(
"getOrder", &AstrometryTransformPolynomial::getOrder);
81 cls.def(
"getCoefficient", py::overload_cast<std::size_t, std::size_t, std::size_t>(
82 &AstrometryTransformPolynomial::getCoefficient, py::const_));
83 cls.def(
"setCoefficient",
84 [](AstrometryTransformPolynomial &self, std::size_t powX, std::size_t powY,
85 std::size_t whichCoord,
86 double value) { self.getCoefficient(powX, powY, whichCoord) = value; });
90 cls.def(
"write", [](AstrometryTransformPolynomial
const &self) {
95 cls.def(
"read", [](AstrometryTransformPolynomial &self,
std::string const &str) {
103 using PyAstrometryTransformLinear = py::class_<AstrometryTransformLinear, std::shared_ptr<AstrometryTransformLinear>,
104 AstrometryTransformPolynomial>;
107 PyAstrometryTransformLinear(wrappers.module,
"AstrometryTransformLinear"), [](
auto &mod,
auto &cls) {
108 cls.def(py::init<>());
113 using PyAstrometryTransformLinearShift = py::class_<AstrometryTransformLinearShift,
116 wrappers.
wrapType(PyAstrometryTransformLinearShift(wrappers.module,
"AstrometryTransformLinearShift"),
117 [](
auto &mod,
auto &cls) {});
121 using PyAstrometryTransformLinearRot =
122 py::class_<AstrometryTransformLinearRot,
126 PyAstrometryTransformLinearRot(wrappers.module,
"AstrometryTransformLinearRot"),
127 [](
auto &mod,
auto &cls) {});
131 using PyAstrometryTransformLinearScale =
132 py::class_<AstrometryTransformLinearScale, std::shared_ptr<AstrometryTransformLinearScale>,
133 AstrometryTransformLinear>;
136 PyAstrometryTransformLinearScale(wrappers.module,
"AstrometryTransformLinearScale"),
137 [](
auto &mod,
auto &cls) {});
141 using PyAstrometryTransformSkyWcs =
142 py::class_<AstrometryTransformSkyWcs, std::shared_ptr<AstrometryTransformSkyWcs>, AstrometryTransform>;
145 PyAstrometryTransformSkyWcs(wrappers.module,
"AstrometryTransformSkyWcs"), [](
auto &mod,
auto &cls) {
146 cls.def(
"getSkyWcs", &AstrometryTransformSkyWcs::getSkyWcs);
151 using PyBaseTanWcs = py::class_<BaseTanWcs, std::shared_ptr<BaseTanWcs>, AstrometryTransform> ;
153 wrappers.
wrapType(PyBaseTanWcs(wrappers.module,
"BaseTanWcs"), [](
auto &mod,
auto &cls) {});
157 using PyTanPixelToRaDec = py::class_<TanPixelToRaDec, std::shared_ptr<TanPixelToRaDec>, AstrometryTransform>;
159 wrappers.
wrapType(PyTanPixelToRaDec(wrappers.module,
"TanPixelToRaDec"), [](
auto &mod,
auto &cls) {});
163 using PyTanRaDecToPixel = py::class_<TanRaDecToPixel, std::shared_ptr<TanRaDecToPixel>, AstrometryTransform>;
165 wrappers.
wrapType(PyTanRaDecToPixel(wrappers.module,
"TanRaDecToPixel"), [](
auto &mod,
auto &cls) {});
169 using PyTanSipPixelToRaDec = py::class_<TanSipPixelToRaDec, std::shared_ptr<TanSipPixelToRaDec>, BaseTanWcs>;
171 wrappers.
wrapType(PyTanSipPixelToRaDec(wrappers.module,
"TanSipPixelToRaDec"), [](
auto &mod,
auto &cls) {});
176 declareAstrometryTransform(wrappers);
177 declareAstrometryTransformIdentity(wrappers);
178 declareAstrometryTransformPolynomial(wrappers);
179 declareAstrometryTransformLinear(wrappers);
180 declareAstrometryTransformLinearShift(wrappers);
181 declareAstrometryTransformLinearRot(wrappers);
182 declareAstrometryTransformLinearScale(wrappers);
183 declareAstrometryTransformSkyWcs(wrappers);
184 declareBaseTanWcs(wrappers);
185 declareTanPixelToRaDec(wrappers);
186 declareTanRaDecToPixel(wrappers);
187 declareTanSipPixelToRaDec(wrappers);
190 wrappers.module.def(
"inversePolyTransform", &
inversePolyTransform,
"forward"_a,
"domain"_a,
"precision"_a,
191 "maxOrder"_a = 9,
"nSteps"_a = 50);
A helper class for subdividing pybind11 module across multiple translation units (i....
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
std::shared_ptr< AstrometryTransformPolynomial > inversePolyTransform(AstrometryTransform const &forward, Frame const &domain, double precision, std::size_t maxOrder=9, std::size_t nSteps=50)
Approximate the inverse by a polynomial, to some precision.
void wrapAstrometryTransform(WrapperCollection &wrappers)