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
photometryTransfo.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"
27 #include "ndarray/pybind11.h"
28 #include "ndarray/eigen.h"
29 #include "Eigen/Core"
30 
31 #include "lsst/utils/python.h"
32 
34 
35 namespace py = pybind11;
36 using namespace pybind11::literals;
37 
38 namespace lsst {
39 namespace jointcal {
40 namespace {
41 
42 void declarePhotometryTransfo(py::module &mod) {
43  py::class_<PhotometryTransfo, std::shared_ptr<PhotometryTransfo>> cls(mod, "PhotometryTransfo");
44 
45  cls.def("transform",
46  (double (PhotometryTransfo::*)(double, double, double) const) & PhotometryTransfo::transform,
47  "x"_a, "y"_a, "value"_a);
48  cls.def("transformError",
49  (double (PhotometryTransfo::*)(double, double, double, double) const) &
50  PhotometryTransfo::transformError,
51  "x"_a, "y"_a, "value"_a, "valueErr"_a);
52  cls.def("offsetParams", &PhotometryTransfo::offsetParams);
53  cls.def("clone", &PhotometryTransfo::clone);
54  cls.def("getNpar", &PhotometryTransfo::getNpar);
55  cls.def("getParameters", &PhotometryTransfo::getParameters);
56  cls.def("computeParameterDerivatives",
57  [](PhotometryTransfo const &self, double x, double y, double instFlux) {
58  Eigen::VectorXd derivatives(self.getNpar());
59  self.computeParameterDerivatives(x, y, instFlux, derivatives);
60  return derivatives;
61  });
62 
63  utils::python::addOutputOp(cls, "__str__");
64 }
65 
66 void declarePhotometryTransfoSpatiallyInvariant(py::module &mod) {
67  py::class_<PhotometryTransfoSpatiallyInvariant, std::shared_ptr<PhotometryTransfoSpatiallyInvariant>,
68  PhotometryTransfo>
69  cls(mod, "PhotometryTransfoSpatiallyInvariant");
70 }
71 
72 void declareFluxTransfoSpatiallyInvariant(py::module &mod) {
73  py::class_<FluxTransfoSpatiallyInvariant, std::shared_ptr<FluxTransfoSpatiallyInvariant>,
74  PhotometryTransfoSpatiallyInvariant, PhotometryTransfo>
75  cls(mod, "FluxTransfoSpatiallyInvariant");
76 
77  cls.def(py::init<double>(), "value"_a = 1);
78 }
79 
80 void declareMagnitudeTransfoSpatiallyInvariant(py::module &mod) {
81  py::class_<MagnitudeTransfoSpatiallyInvariant, std::shared_ptr<MagnitudeTransfoSpatiallyInvariant>,
82  PhotometryTransfoSpatiallyInvariant, PhotometryTransfo>
83  cls(mod, "MagnitudeTransfoSpatiallyInvariant");
84 
85  cls.def(py::init<double>(), "value"_a = 0);
86 }
87 
88 void declarePhotometryTransfoChebyshev(py::module &mod) {
89  py::class_<PhotometryTransfoChebyshev, std::shared_ptr<PhotometryTransfoChebyshev>, PhotometryTransfo>
90  cls(mod, "PhotometryTransfoChebyshev");
91 
92  cls.def("getCoefficients", &PhotometryTransfoChebyshev::getCoefficients);
93  cls.def("getOrder", &PhotometryTransfoChebyshev::getOrder);
94  cls.def("getBBox", &PhotometryTransfoChebyshev::getBBox);
95 }
96 
97 void declareFluxTransfoChebyshev(py::module &mod) {
98  py::class_<FluxTransfoChebyshev, std::shared_ptr<FluxTransfoChebyshev>, PhotometryTransfoChebyshev> cls(
99  mod, "FluxTransfoChebyshev");
100 
101  cls.def(py::init<size_t, afw::geom::Box2D const &>(), "order"_a, "bbox"_a);
102  cls.def(py::init<ndarray::Array<double, 2, 2> const &, afw::geom::Box2D const &>(), "coefficients"_a,
103  "bbox"_a);
104 }
105 
106 void declareMagnitudeTransfoChebyshev(py::module &mod) {
107  py::class_<MagnitudeTransfoChebyshev, std::shared_ptr<MagnitudeTransfoChebyshev>,
108  PhotometryTransfoChebyshev>
109  cls(mod, "MagnitudeTransfoChebyshev");
110 
111  cls.def(py::init<size_t, afw::geom::Box2D const &>(), "order"_a, "bbox"_a);
112  cls.def(py::init<ndarray::Array<double, 2, 2> const &, afw::geom::Box2D const &>(), "coefficients"_a,
113  "bbox"_a);
114 }
115 
117  declarePhotometryTransfo(mod);
118 
119  declarePhotometryTransfoSpatiallyInvariant(mod);
120  declareFluxTransfoSpatiallyInvariant(mod);
121  declareMagnitudeTransfoSpatiallyInvariant(mod);
122  declarePhotometryTransfoChebyshev(mod);
123  declareFluxTransfoChebyshev(mod);
124  declareMagnitudeTransfoChebyshev(mod);
125 }
126 
127 } // namespace
128 } // namespace jointcal
129 } // namespace lsst
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
Definition: python.h:87
def init()
Definition: tests.py:75
PYBIND11_MODULE(camera, mod)
Definition: camera.cc:34
int y
Definition: SpanSet.cc:49
A base class for image defects.
Definition: cameraGeom.dox:3
double x
table::Key< int > transform