Loading [MathJax]/extensions/tex2jax.js
LSST Applications g0000d66e7c+ce78115f25,g0485b4d2cb+c8d56b10d4,g0fba68d861+fcbc158cd0,g1ec0fe41b4+3e153770da,g1fd858c14a+57ee4e1624,g2440f9efcc+8c5ae1fdc5,g35bb328faa+8c5ae1fdc5,g4d2262a081+1e04cc5a47,g53246c7159+8c5ae1fdc5,g55585698de+7a33f081c8,g56a49b3a55+b9d5cac73f,g60b5630c4e+7a33f081c8,g67b6fd64d1+035c836e50,g78460c75b0+7e33a9eb6d,g786e29fd12+668abc6043,g7ac00fbb6c+b938379438,g8352419a5c+8c5ae1fdc5,g8852436030+5ba78a36c9,g89139ef638+035c836e50,g94187f82dc+7a33f081c8,g989de1cb63+035c836e50,g9d31334357+7a33f081c8,g9f33ca652e+e34120223a,ga815be3f0b+911242149a,gabe3b4be73+8856018cbb,gabf8522325+21619da9f3,gb1101e3267+0b44b44611,gb89ab40317+035c836e50,gc91f06edcd+e59fb3c9bc,gcf25f946ba+5ba78a36c9,gd6cbbdb0b4+958adf5c1f,gde0f65d7ad+6c98dcc924,ge278dab8ac+83c63f4893,ge410e46f29+035c836e50,gf35d7ec915+97dd712d81,gf5e32f922b+8c5ae1fdc5,gf67bdafdda+035c836e50,gf6800124b1+1714c04baa,w.2025.19
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
sipTransform.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"
24#include "pybind11/stl.h"
25
26#include "lsst/geom/Point.h"
30
31namespace py = pybind11;
32using namespace pybind11::literals;
33
34namespace lsst {
35namespace meas {
36namespace astrom {
37namespace {
38
39void declareSipTransformBase(lsst::cpputils::python::WrapperCollection &wrappers) {
40 using PySipTransformBase = py::class_<SipTransformBase, std::shared_ptr<SipTransformBase>>;
41
42 wrappers.wrapType(PySipTransformBase(wrappers.module, "_SipTransformBase"), [](auto &mod, auto &cls) {
43 cls.def("getPixelOrigin", &SipTransformBase::getPixelOrigin, py::return_value_policy::copy);
44 cls.def("getCdMatrix", &SipTransformBase::getCdMatrix, py::return_value_policy::copy);
45 cls.def("getPoly", &SipTransformBase::getPoly, py::return_value_policy::copy);
46 });
47}
48
49void declareSipForwardTransform(lsst::cpputils::python::WrapperCollection &wrappers) {
50 using PySipForwardTransform =
51 py::class_<SipForwardTransform, std::shared_ptr<SipForwardTransform>, SipTransformBase>;
52
53 wrappers.wrapType(PySipForwardTransform(wrappers.module, "SipForwardTransform"), [](auto &mod, auto &cls) {
54 cls.def(py::init<geom::Point2D const &, geom::LinearTransform const &, PolynomialTransform const &>(),
55 "pixelOrigin"_a, "cdMatrix"_a, "forwardSipPoly"_a);
56 cls.def(py::init<SipForwardTransform const &>(), "other"_a);
57
58 cls.def_static("convert",
59 (SipForwardTransform(*)(PolynomialTransform const &, geom::Point2D const &,
60 geom::LinearTransform const &)) &
61 SipForwardTransform::convert,
62 "poly"_a, "pixelOrigin"_a, "cdMatrix"_a);
63 cls.def_static("convert",
64 (SipForwardTransform(*)(ScaledPolynomialTransform const &, geom::Point2D const &,
65 geom::LinearTransform const &)) &
66 SipForwardTransform::convert,
67 "scaled"_a, "pixelOrigin"_a, "cdMatrix"_a);
68 cls.def_static("convert",
69 (SipForwardTransform(*)(ScaledPolynomialTransform const &)) &SipForwardTransform::convert,
70 "scaled"_a);
71
72 cls.def("__call__", &SipForwardTransform::operator(), "in"_a);
73 cls.def("transformPixels", &SipForwardTransform::transformPixels, "s"_a);
74
75 cls.def("linearize", &SipForwardTransform::linearize);
76 });
77}
78
79void declareSipReverseTransform(lsst::cpputils::python::WrapperCollection &wrappers) {
80 using PySipReverseTransform =
81 py::class_<SipReverseTransform, std::shared_ptr<SipReverseTransform>, SipTransformBase>;
82
83 wrappers.wrapType(PySipReverseTransform(wrappers.module, "SipReverseTransform"), [](auto &mod, auto &cls) {
84 cls.def(py::init<geom::Point2D const &, geom::LinearTransform const &, PolynomialTransform const &>(),
85 "pixelOrigin"_a, "cdMatrix"_a, "reverseSipPoly"_a);
86 cls.def(py::init<SipReverseTransform const &>(), "other"_a);
87
88 cls.def_static("convert",
89 (SipReverseTransform(*)(PolynomialTransform const &, geom::Point2D const &,
90 geom::LinearTransform const &)) &
91 SipReverseTransform::convert,
92 "poly"_a, "pixelOrigin"_a, "cdMatrix"_a);
93 cls.def_static("convert",
94 (SipReverseTransform(*)(ScaledPolynomialTransform const &, geom::Point2D const &,
95 geom::LinearTransform const &)) &
96 SipReverseTransform::convert,
97 "scaled"_a, "pixelOrigin"_a, "cdMatrix"_a);
98 cls.def_static("convert",
99 (SipReverseTransform(*)(ScaledPolynomialTransform const &)) &SipReverseTransform::convert,
100 "scaled"_a);
101
102 cls.def("__call__", &SipReverseTransform::operator(), "in"_a);
103 cls.def("transformPixels", &SipReverseTransform::transformPixels, "s"_a);
104
105 cls.def("linearize", &SipReverseTransform::linearize);
106 });
107}
108
109} // namespace
110
112 declareSipTransformBase(wrappers);
113 declareSipForwardTransform(wrappers);
114 declareSipReverseTransform(wrappers);
115
116 wrappers.module.def("makeWcs", makeWcs, "sipForward"_a, "sipReverse"_a, "skyOrigin"_a);
117 wrappers.module.def("transformWcsPixels", transformWcsPixels, "wcs"_a, "s"_a);
118 wrappers.module.def("rotateWcsPixelsBy90", rotateWcsPixelsBy90, "wcs"_a, "nQuarter"_a, "dimensions"_a);
119}
120
121} // namespace astrom
122} // namespace meas
123} // 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
Base class for SIP transform objects.
std::shared_ptr< afw::geom::SkyWcs > transformWcsPixels(afw::geom::SkyWcs const &wcs, geom::AffineTransform const &s)
Create a new SkyWcs whose pixel coordinate system has been transformed via an affine transform.
void wrapSipTransform(WrapperCollection &wrappers)
std::shared_ptr< afw::geom::SkyWcs > rotateWcsPixelsBy90(afw::geom::SkyWcs const &wcs, int nQuarter, geom::Extent2I const &dimensions)
Return a new SkyWcs that represents a rotation of the image it corresponds to about the image's cente...
std::shared_ptr< afw::geom::SkyWcs > makeWcs(SipForwardTransform const &sipForward, SipReverseTransform const &sipReverse, geom::SpherePoint const &skyOrigin)
Create a new TAN SIP Wcs from a pair of SIP transforms and the sky origin.