LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
polynomialTransform.cc
Go to the documentation of this file.
1/*
2 * LSST Data Management System
3 *
4 * This product includes software developed by the
5 * LSST Project (http://www.lsst.org/).
6 * See the COPYRIGHT file
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the LSST License Statement and
19 * the GNU General Public License along with this program. If not,
20 * see <https://www.lsstcorp.org/LegalNotices/>.
21 */
22#include "pybind11/pybind11.h"
23#include "pybind11/stl.h"
24
25#include <memory>
26
27#include "ndarray/pybind11.h"
28
32
33namespace py = pybind11;
34using namespace pybind11::literals;
35
36namespace lsst {
37namespace meas {
38namespace astrom {
39
40namespace {
41
42static void declarePolynomialTransform(py::module &mod) {
43 py::class_<PolynomialTransform, std::shared_ptr<PolynomialTransform>> cls(mod, "PolynomialTransform");
44
45 cls.def(py::init<ndarray::Array<double const, 2, 0> const &,
46 ndarray::Array<double const, 2, 0> const &>(),
47 "xCoeffs"_a, "yCoeffs"_a);
48 cls.def(py::init<PolynomialTransform const &>(), "other"_a);
49
50 cls.def_static("convert",
51 (PolynomialTransform(*)(ScaledPolynomialTransform const &)) & PolynomialTransform::convert,
52 "other"_a);
53 cls.def_static("convert",
54 (PolynomialTransform(*)(SipForwardTransform const &)) & PolynomialTransform::convert,
55 "other"_a);
56 cls.def_static("convert",
57 (PolynomialTransform(*)(SipReverseTransform const &)) & PolynomialTransform::convert,
58 "other"_a);
59
60 cls.def("__call__", &PolynomialTransform::operator(), "in"_a);
61
62 cls.def("getOrder", &PolynomialTransform::getOrder);
63 cls.def("getXCoeffs", &PolynomialTransform::getXCoeffs);
64 cls.def("getYCoeffs", &PolynomialTransform::getYCoeffs);
65 cls.def("linearize", &PolynomialTransform::linearize);
66}
67
68static void declareScaledPolynomialTransform(py::module &mod) {
69 py::class_<ScaledPolynomialTransform, std::shared_ptr<ScaledPolynomialTransform>> cls(
70 mod, "ScaledPolynomialTransform");
71
72 cls.def(py::init<PolynomialTransform const &, geom::AffineTransform const &,
73 geom::AffineTransform const &>(),
74 "poly"_a, "inputScaling"_a, "outputScalingInverse"_a);
75 cls.def(py::init<ScaledPolynomialTransform const &>(), "other"_a);
76
77 cls.def_static(
78 "convert",
79 (ScaledPolynomialTransform(*)(PolynomialTransform const &)) & ScaledPolynomialTransform::convert,
80 "other"_a);
81 cls.def_static(
82 "convert",
83 (ScaledPolynomialTransform(*)(SipForwardTransform const &)) & ScaledPolynomialTransform::convert,
84 "other"_a);
85 cls.def_static(
86 "convert",
87 (ScaledPolynomialTransform(*)(SipReverseTransform const &)) & ScaledPolynomialTransform::convert,
88 "other"_a);
89
90 cls.def("__call__", &ScaledPolynomialTransform::operator(), "in"_a);
91
92 cls.def("getPoly", &ScaledPolynomialTransform::getPoly, py::return_value_policy::reference_internal);
93 cls.def("getInputScaling", &ScaledPolynomialTransform::getInputScaling,
94 py::return_value_policy::reference_internal);
95 cls.def("getOutputScalingInverse", &ScaledPolynomialTransform::getOutputScalingInverse,
96 py::return_value_policy::reference_internal);
97 cls.def("linearize", &ScaledPolynomialTransform::linearize);
98}
99
100} // namespace
101
102PYBIND11_MODULE(polynomialTransform, mod) {
103 declarePolynomialTransform(mod);
104 declareScaledPolynomialTransform(mod);
105
106 mod.def("compose",
108 "t1"_a, "t2"_a);
109 mod.def("compose",
111 "t1"_a, "t2"_a);
112}
113
114} // namespace astrom
115} // namespace meas
116} // namespace lsst
An affine coordinate transformation consisting of a linear transformation and an offset.
A 2-d coordinate transform represented by a pair of standard polynomials (one for each coordinate).
static PolynomialTransform convert(ScaledPolynomialTransform const &other)
Convert a ScaledPolynomialTransform to an equivalent PolynomialTransform.
geom::AffineTransform linearize(geom::Point2D const &in) const
Return an approximate affine transform at the given point.
ndarray::Array< double const, 2, 2 > getXCoeffs() const
2-D polynomial coefficients that compute the output x coordinate.
ndarray::Array< double const, 2, 2 > getYCoeffs() const
2-D polynomial coefficients that compute the output x coordinate.
int getOrder() const
Return the order of the polynomials.
geom::AffineTransform const & getOutputScalingInverse() const
Return the affine transform applied to points after the polynomial transform.
geom::AffineTransform linearize(geom::Point2D const &in) const
Return an approximate affine transform at the given point.
static ScaledPolynomialTransform convert(PolynomialTransform const &poly)
Convert a PolynomialTransform to an equivalent ScaledPolynomialTransform.
PolynomialTransform const & getPoly() const
Return the polynomial transform applied after the input scaling.
geom::AffineTransform const & getInputScaling() const
Return the first affine transform applied to input points.
PYBIND11_MODULE(makeMatchStatistics, mod)
PolynomialTransform compose(geom::AffineTransform const &t1, PolynomialTransform const &t2)
Return a PolynomialTransform that is equivalent to the composition t1(t2())
A base class for image defects.