LSST Applications 24.1.6,g063fba187b+e7121a6b04,g0f08755f38+4e0faf0f7f,g12f32b3c4e+7915c4de30,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g28da252d5a+94d9f37a33,g2bbee38e9b+ae03bbfc84,g2bc492864f+ae03bbfc84,g3156d2b45e+6e55a43351,g347aa1857d+ae03bbfc84,g35bb328faa+a8ce1bb630,g3a166c0a6a+ae03bbfc84,g3e281a1b8c+c5dd892a6c,g414038480c+6b9177ef31,g41af890bb2+9e154f3e8d,g6b1c1869cb+adc49b6f1a,g781aacb6e4+a8ce1bb630,g7af13505b9+3363a39af3,g7f202ee025+406ba613a5,g80478fca09+8fbba356e2,g82479be7b0+0d223595df,g858d7b2824+4e0faf0f7f,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,g9726552aa6+414189b318,ga5288a1d22+32d6120315,gacef1a1666+7f85da65db,gb58c049af0+d64f4d3760,gbcfae0f0a0+a8c62e8bb6,gc28159a63d+ae03bbfc84,gcf0d15dbbd+412a8a6f35,gda6a2b7d83+412a8a6f35,gdaeeff99f8+1711a396fd,ge79ae78c31+ae03bbfc84,gf0baf85859+c1f95f4921,gfa517265be+4e0faf0f7f,gfa999e8aa5+17cd334064,gfb92a5be7c+4e0faf0f7f
LSST Data Management Base Package
Loading...
Searching...
No Matches
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>,
74 AstrometryTransform>;
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
py::object result
Definition _schema.cc:429
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
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)
T write(T... args)