LSSTApplications  16.0-10-g4f78f78+16,16.0-10-gc1446dd+42,16.0-11-g09ed895+1,16.0-13-g7649090,16.0-14-g0a28612+1,16.0-14-g6c7ed55+16,16.0-15-ga29f190+1,16.0-16-g89065d4+14,16.0-16-gd8e3590+16,16.0-16-ge6a35c8+6,16.0-17-g7e0e4ff+10,16.0-17-ga3d2e9f,16.0-19-gb830ed4e+16,16.0-2-g0febb12+21,16.0-2-g9d5294e+61,16.0-2-ga8830df+5,16.0-24-gc1c7f52+9,16.0-25-g07af9f2+1,16.0-3-ge00e371+21,16.0-36-g07840cb1,16.0-4-g18f3627+5,16.0-4-g5f3a788+20,16.0-4-ga3eb747+10,16.0-4-gabf74b7+16,16.0-4-gade8416+9,16.0-4-gb13d127+5,16.0-5-g6a53317+21,16.0-5-gb3f8a4b+74,16.0-5-gef99c9f+12,16.0-6-g9321be7+4,16.0-6-gcbc7b31+22,16.0-6-gf49912c+16,16.0-63-gae20905ba,16.0-7-gd2eeba5+31,16.0-8-g21fd5fe+16,16.0-8-g3a9f023+12,16.0-8-g4734f7a,16.0-9-g85d1a16+16,16.0-9-gf5c1f43,master-g07ce7b41a7,w.2018.48
LSSTDataManagementBasePackage
gtransfo.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 "astshim.h"
26 #include "pybind11/pybind11.h"
27 #include "pybind11/eigen.h"
28 #include "ndarray/pybind11.h"
29 #include "ndarray/eigen.h"
30 #include "Eigen/Core"
31 
32 #include "lsst/utils/python.h"
33 
34 #include "lsst/jointcal/Frame.h"
35 #include "lsst/jointcal/Gtransfo.h"
36 #include "lsst/jointcal/Point.h"
37 
38 namespace py = pybind11;
39 using namespace pybind11::literals;
40 
41 namespace lsst {
42 namespace jointcal {
43 namespace {
44 
45 void declareGtransfo(py::module &mod) {
46  py::class_<Gtransfo, std::shared_ptr<Gtransfo>> cls(mod, "Gtransfo");
47 
48  cls.def("apply", (jointcal::Point(Gtransfo::*)(const jointcal::Point &) const) & Gtransfo::apply,
49  "inPos"_a);
50  cls.def("apply", (jointcal::Frame(Gtransfo::*)(Frame const &, bool) const) & Gtransfo::apply,
51  "inputframe"_a, "inscribed"_a);
52  cls.def("getNpar", &Gtransfo::getNpar);
53  cls.def("offsetParams", &Gtransfo::offsetParams);
54  cls.def("linearApproximation", &Gtransfo::linearApproximation);
55  cls.def("computeDerivative", [](Gtransfo const &self, Point const &where, double const step) {
56  GtransfoLin derivative;
57  self.computeDerivative(where, derivative, step);
58  return derivative;
59  });
60 
61  utils::python::addOutputOp(cls, "__str__");
62 }
63 
64 void declareGtransfoIdentity(py::module &mod) {
65  py::class_<GtransfoIdentity, std::shared_ptr<GtransfoIdentity>, Gtransfo> cls(mod, "GtransfoIdentity");
66 }
67 
68 void declareGtransfoPoly(py::module &mod) {
69  py::class_<GtransfoPoly, std::shared_ptr<GtransfoPoly>, Gtransfo> cls(mod, "GtransfoPoly");
70 
71  cls.def(py::init<const unsigned>(), "order"_a);
72  cls.def("getOrder", &GtransfoPoly::getOrder);
73  cls.def("coeff", (double (GtransfoPoly::*)(unsigned const, unsigned const, unsigned const) const) &
75  cls.def("determinant", &GtransfoPoly::determinant);
76  cls.def("getNpar", &GtransfoPoly::getNpar);
77  cls.def("toAstMap", &GtransfoPoly::toAstMap);
78  cls.def("write", [](GtransfoPoly const &self) {
80  self.write(result);
81  return result.str();
82  });
83  cls.def("read", [](GtransfoPoly &self, std::string const &str) {
84  std::istringstream istr(str);
85  self.read(istr);
86  });
87 }
88 
89 void declareGtransfoLin(py::module &mod) {
90  py::class_<GtransfoLin, std::shared_ptr<GtransfoLin>, GtransfoPoly> cls(mod, "GtransfoLin");
91 }
92 
93 void declareGtransfoLinShift(py::module &mod) {
94  py::class_<GtransfoLinShift, std::shared_ptr<GtransfoLinShift>, GtransfoLin> cls(mod, "GtransfoLinShift");
95 }
96 
97 void declareGtransfoLinRot(py::module &mod) {
98  py::class_<GtransfoLinRot, std::shared_ptr<GtransfoLinRot>, GtransfoLin> cls(mod, "GtransfoLinRot");
99 }
100 
101 void declareGtransfoLinScale(py::module &mod) {
102  py::class_<GtransfoLinScale, std::shared_ptr<GtransfoLinScale>, GtransfoLin> cls(mod, "GtransfoLinScale");
103 }
104 
105 void declareGtransfoSkyWcs(py::module &mod) {
106  py::class_<GtransfoSkyWcs, std::shared_ptr<GtransfoSkyWcs>, Gtransfo> cls(mod, "GtransfoSkyWcs");
107  cls.def("getSkyWcs", &GtransfoSkyWcs::getSkyWcs);
108 }
109 
110 void declareBaseTanWcs(py::module &mod) {
111  py::class_<BaseTanWcs, std::shared_ptr<BaseTanWcs>, Gtransfo> cls(mod, "BaseTanWcs");
112 }
113 
114 void declareTanPixelToRaDec(py::module &mod) {
115  py::class_<TanPixelToRaDec, std::shared_ptr<TanPixelToRaDec>, Gtransfo> cls(mod, "TanPixelToRaDec");
116 }
117 
118 void declareTanRaDecToPixel(py::module &mod) {
119  py::class_<TanRaDecToPixel, std::shared_ptr<TanRaDecToPixel>, Gtransfo> cls(mod, "TanRaDecToPixel");
120 }
121 
122 void declareTanSipPixelToRaDec(py::module &mod) {
123  py::class_<TanSipPixelToRaDec, std::shared_ptr<TanSipPixelToRaDec>, BaseTanWcs> cls(mod,
124  "TanSipPixelToRaDec");
125 }
126 
128  py::module::import("astshim.mapping");
129  py::module::import("lsst.jointcal.frame");
130  py::module::import("lsst.jointcal.star");
131  declareGtransfo(mod);
132  declareGtransfoIdentity(mod);
133  declareGtransfoPoly(mod);
134  declareGtransfoLin(mod);
135  declareGtransfoLinShift(mod);
136  declareGtransfoLinRot(mod);
137  declareGtransfoLinScale(mod);
138  declareGtransfoSkyWcs(mod);
139  declareBaseTanWcs(mod);
140  declareTanPixelToRaDec(mod);
141  declareTanRaDecToPixel(mod);
142  declareTanSipPixelToRaDec(mod);
143 
144  // utility functions
145  mod.def("inversePolyTransfo", &inversePolyTransfo, "forward"_a, "domain"_a, "precision"_a,
146  "maxOrder"_a = 9, "nSteps"_a = 50);
147 }
148 } // namespace
149 } // namespace jointcal
150 } // namespace lsst
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
Definition: python.h:87
A point in a plane.
Definition: Point.h:36
PYBIND11_MODULE(camera, mod)
Definition: camera.cc:34
py::object result
Definition: schema.cc:284
std::shared_ptr< GtransfoPoly > inversePolyTransfo(Gtransfo const &forward, Frame const &domain, double const precision, int const maxOrder=9, unsigned const nSteps=50)
Approximate the inverse by a polynomial, to some precision.
Definition: Gtransfo.cc:1096
STL class.
rectangle with sides parallel to axes.
Definition: Frame.h:38
A base class for image defects.
Definition: cameraGeom.dox:3
int const step
T str(T... args)
table::Key< table::Array< double > > coeff
Definition: PsfexPsf.cc:362