Loading [MathJax]/extensions/tex2jax.js
LSST Applications g04dff08e69+fafbcb10e2,g0d33ba9806+3d21495239,g0fba68d861+4a282a2c93,g1ec0fe41b4+f536777771,g1fd858c14a+ae46bc2a71,g35bb328faa+fcb1d3bbc8,g4af146b050+9c38a215af,g4d2262a081+36f1e108ba,g53246c7159+fcb1d3bbc8,g5a012ec0e7+b20b785ecb,g60b5630c4e+3d21495239,g6273192d42+d9e7b43dd0,g67b6fd64d1+4086c0989b,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g87b7deb4dc+2198278b84,g8852436030+54b48a5987,g89139ef638+4086c0989b,g9125e01d80+fcb1d3bbc8,g94187f82dc+3d21495239,g989de1cb63+4086c0989b,g9d31334357+3d21495239,g9f33ca652e+83205baa3c,gabe3b4be73+1e0a283bba,gabf8522325+fa80ff7197,gb1101e3267+85d1f90f4c,gb58c049af0+f03b321e39,gb89ab40317+4086c0989b,gc0bb628dac+d11454dffd,gcf25f946ba+54b48a5987,gd6cbbdb0b4+af3c3595f5,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+a74c3eaa38,ge278dab8ac+d65b3c2b70,ge410e46f29+4086c0989b,gf23fb2af72+b3e27b8ebc,gf67bdafdda+4086c0989b,v29.0.0.rc6
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
astrometryTransform.cc
Go to the documentation of this file.
1// -*- LSST-C++ -*-
2/*
3 * This file is part of jointcal.
4 *
5 * Developed for the LSST Data Management System.
6 * This product includes software developed by the LSST Project
7 * (https://www.lsst.org).
8 * See the COPYRIGHT file at the top-level directory of this distribution
9 * for details of code ownership.
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
25#include "pybind11/pybind11.h"
26#include "pybind11/eigen.h"
28
29#include "lsst/jointcal/Frame.h"
31#include "lsst/jointcal/Point.h"
32
33namespace py = pybind11;
34using namespace pybind11::literals;
35
36namespace lsst {
37namespace jointcal {
38namespace {
39
40void declareAstrometryTransform(lsst::cpputils::python::WrapperCollection &wrappers) {
41 using PyAstrometryTransform = py::class_<AstrometryTransform, std::shared_ptr<AstrometryTransform>>;
42
43 wrappers.wrapType(PyAstrometryTransform(wrappers.module, "AstrometryTransform"), [](auto &mod, auto &cls) {
44 cls.def("apply",
45 (jointcal::Point(AstrometryTransform::*)(const jointcal::Point &) const) &
46 AstrometryTransform::apply,
47 "inPos"_a);
48 cls.def("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);
57 return derivative;
58 });
59
60 cpputils::python::addOutputOp(cls, "__str__");
61 });
62}
63
64void declareAstrometryTransformIdentity(lsst::cpputils::python::WrapperCollection &wrappers) {
65 using PyAstrometryTransformIdentity =
66 py::class_<AstrometryTransformIdentity, std::shared_ptr<AstrometryTransformIdentity>, AstrometryTransform>;
67
68 wrappers.wrapType(PyAstrometryTransformIdentity(wrappers.module, "AstrometryTransformIdentity"),
69 [](auto &mod, auto &cls) {});
70}
71
72void declareAstrometryTransformPolynomial(lsst::cpputils::python::WrapperCollection &wrappers) {
73 using PyAstrometryTransformPolynomial = py::class_<AstrometryTransformPolynomial, std::shared_ptr<AstrometryTransformPolynomial>,
75
76 wrappers.wrapType(
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; });
87 cls.def("determinant", &AstrometryTransformPolynomial::determinant);
88 cls.def("getNpar", &AstrometryTransformPolynomial::getNpar);
89 cls.def("toAstMap", &AstrometryTransformPolynomial::toAstMap);
90 cls.def("write", [](AstrometryTransformPolynomial const &self) {
92 self.write(result);
93 return result.str();
94 });
95 cls.def("read", [](AstrometryTransformPolynomial &self, std::string const &str) {
96 std::istringstream istr(str);
97 self.read(istr);
98 });
99 });
100}
101
102void declareAstrometryTransformLinear(lsst::cpputils::python::WrapperCollection &wrappers) {
103 using PyAstrometryTransformLinear = py::class_<AstrometryTransformLinear, std::shared_ptr<AstrometryTransformLinear>,
104 AstrometryTransformPolynomial>;
105
106 wrappers.wrapType(
107 PyAstrometryTransformLinear(wrappers.module, "AstrometryTransformLinear"), [](auto &mod, auto &cls) {
108 cls.def(py::init<>());
109 });
110}
111
112void declareAstrometryTransformLinearShift(lsst::cpputils::python::WrapperCollection &wrappers) {
113 using PyAstrometryTransformLinearShift = py::class_<AstrometryTransformLinearShift,
114 std::shared_ptr<AstrometryTransformLinearShift>, AstrometryTransformLinear>;
115
116 wrappers.wrapType(PyAstrometryTransformLinearShift(wrappers.module, "AstrometryTransformLinearShift"),
117 [](auto &mod, auto &cls) {});
118}
119
120void declareAstrometryTransformLinearRot(lsst::cpputils::python::WrapperCollection &wrappers) {
121 using PyAstrometryTransformLinearRot =
122 py::class_<AstrometryTransformLinearRot,
123 std::shared_ptr<AstrometryTransformLinearRot>, AstrometryTransformLinear>;
124
125 wrappers.wrapType(
126 PyAstrometryTransformLinearRot(wrappers.module, "AstrometryTransformLinearRot"),
127 [](auto &mod, auto &cls) {});
128}
129
130void declareAstrometryTransformLinearScale(lsst::cpputils::python::WrapperCollection &wrappers) {
131 using PyAstrometryTransformLinearScale =
132 py::class_<AstrometryTransformLinearScale, std::shared_ptr<AstrometryTransformLinearScale>,
133 AstrometryTransformLinear>;
134
135 wrappers.wrapType(
136 PyAstrometryTransformLinearScale(wrappers.module, "AstrometryTransformLinearScale"),
137 [](auto &mod, auto &cls) {});
138}
139
140void declareAstrometryTransformSkyWcs(lsst::cpputils::python::WrapperCollection &wrappers) {
141 using PyAstrometryTransformSkyWcs =
142 py::class_<AstrometryTransformSkyWcs, std::shared_ptr<AstrometryTransformSkyWcs>, AstrometryTransform>;
143
144 wrappers.wrapType(
145 PyAstrometryTransformSkyWcs(wrappers.module, "AstrometryTransformSkyWcs"), [](auto &mod, auto &cls) {
146 cls.def("getSkyWcs", &AstrometryTransformSkyWcs::getSkyWcs);
147 });
148}
149
150void declareBaseTanWcs(lsst::cpputils::python::WrapperCollection &wrappers) {
151 using PyBaseTanWcs = py::class_<BaseTanWcs, std::shared_ptr<BaseTanWcs>, AstrometryTransform> ;
152
153 wrappers.wrapType(PyBaseTanWcs(wrappers.module, "BaseTanWcs"), [](auto &mod, auto &cls) {});
154}
155
156void declareTanPixelToRaDec(lsst::cpputils::python::WrapperCollection &wrappers) {
157 using PyTanPixelToRaDec = py::class_<TanPixelToRaDec, std::shared_ptr<TanPixelToRaDec>, AstrometryTransform>;
158
159 wrappers.wrapType(PyTanPixelToRaDec(wrappers.module, "TanPixelToRaDec"), [](auto &mod, auto &cls) {});
160}
161
162void declareTanRaDecToPixel(lsst::cpputils::python::WrapperCollection &wrappers) {
163 using PyTanRaDecToPixel = py::class_<TanRaDecToPixel, std::shared_ptr<TanRaDecToPixel>, AstrometryTransform>;
164
165 wrappers.wrapType(PyTanRaDecToPixel(wrappers.module, "TanRaDecToPixel"), [](auto &mod, auto &cls) {});
166}
167
168void declareTanSipPixelToRaDec(lsst::cpputils::python::WrapperCollection &wrappers) {
169 using PyTanSipPixelToRaDec = py::class_<TanSipPixelToRaDec, std::shared_ptr<TanSipPixelToRaDec>, BaseTanWcs>;
170
171 wrappers.wrapType(PyTanSipPixelToRaDec(wrappers.module, "TanSipPixelToRaDec"), [](auto &mod, auto &cls) {});
172}
173} // namespace
174
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);
188
189 // utility functions
190 wrappers.module.def("inversePolyTransform", &inversePolyTransform, "forward"_a, "domain"_a, "precision"_a,
191 "maxOrder"_a = 9, "nSteps"_a = 50);
192}
193
194} // namespace jointcal
195} // namespace lsst
A helper class for subdividing pybind11 module across multiple translation units (i....
Definition python.h:242
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...
Definition python.h:391
pybind11::module module
The module object passed to the PYBIND11_MODULE block that contains this WrapperCollection.
Definition python.h:448
a virtual (interface) class for geometric transformations.
std::shared_ptr< ast::Mapping > toAstMap(jointcal::Frame const &domain) const override
Create an equivalent AST mapping for this transformation, including an analytic inverse if possible.
std::size_t getNpar() const override
total number of parameters
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
Definition python.h:87
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)