LSST Applications g180d380827+0f66a164bb,g2079a07aa2+86d27d4dc4,g2305ad1205+7d304bc7a0,g29320951ab+500695df56,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+e42ea45bea,g48712c4677+36a86eeaa5,g487adcacf7+2dd8f347ac,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+c70619cc9d,g5a732f18d5+53520f316c,g5ea96fc03c+341ea1ce94,g64a986408d+f7cd9c7162,g858d7b2824+f7cd9c7162,g8a8a8dda67+585e252eca,g99cad8db69+469ab8c039,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+c92fc63c7e,gbd866b1f37+f7cd9c7162,gc120e1dc64+02c66aa596,gc28159a63d+0e5473021a,gc3e9b769f7+b0068a2d9f,gcf0d15dbbd+e42ea45bea,gdaeeff99f8+f9a426f77a,ge6526c86ff+84383d05b3,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+f7cd9c7162,w.2024.17
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 utils::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
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)