lsst.meas.base  14.0-12-g233aa8e+9
python.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * See COPYRIGHT file at the top of the source tree.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <http://www.lsstcorp.org/LegalNotices/>.
22  */
23 
24 #ifndef LSST_MEAS_BASE_PYTHON_H
25 #define LSST_MEAS_BASE_PYTHON_H
26 
27 #include "pybind11/pybind11.h"
28 
29 #include <string>
30 
31 #include "ndarray.h"
32 #include "lsst/afw/image/Calib.h"
33 #include "lsst/afw/image/Wcs.h"
34 #include "lsst/afw/table/fwd.h"
35 #include "lsst/afw/table/Schema.h"
37 
38 namespace lsst {
39 namespace meas {
40 namespace base {
41 namespace python {
42 
43 namespace py = pybind11;
44 using namespace pybind11::literals;
45 
54 template <class Algorithm, class PyAlg>
56  cls.def(py::init<typename Algorithm::Control const &,
57  std::string const &,
58  afw::table::Schema &>(),
59  "ctrl"_a, "name"_a, "schema"_a);
60 }
72 template <class Algorithm, class PyAlg>
74 }
75 
87 template <class Algorithm, class PyAlg>
88 void declareAlgorithm(PyAlg & clsAlgorithm) {
89  /* Member types and enums */
90 
91  /* Constructors */
92  declareAlgorithmConstructor<Algorithm>(clsAlgorithm);
93 
94  /* Operators */
95 
96  /* Members */
97  clsAlgorithm.def("fail", &Algorithm::fail, "measRecord"_a, "error"_a=NULL);
98  clsAlgorithm.def("measure", &Algorithm::measure, "record"_a, "exposure"_a);
99 }
100 
116 template <class Algorithm, class Control, class PyAlg, class PyCtrl>
117 void declareAlgorithm(PyAlg & clsAlgorithm, PyCtrl & clsControl) {
118  declareAlgorithm<Algorithm>(clsAlgorithm);
119 
120  /* Member types and enums */
121 
122  /* Constructors */
123  clsControl.def(py::init<>());
124 
125  /* Operators */
126 
127  /* Members */
128 }
129 
148 template <class Algorithm, class Control, class Transform, class PyAlg, class PyCtrl, class PyXform>
149 void declareAlgorithm(PyAlg & clsAlgorithm, PyCtrl & clsControl, PyXform & clsTransform) {
150  declareAlgorithm<Algorithm, Control>(clsAlgorithm, clsControl);
151 
152  /* Member types and enums */
153 
154  /* Constructors */
155  clsTransform.def(py::init<typename Transform::Control const &,
156  std::string const &,
158  "ctrl"_a, "name"_a, "mapper"_a);
159 
160  /* Operators */
161  clsTransform.def("__call__", [](Transform const & self,
162  afw::table::SourceCatalog const & inputCatalog,
163  afw::table::BaseCatalog & outputCatalog,
164  afw::image::Wcs const & wcs,
165  afw::image::Calib const &calib) {
166  return self(inputCatalog, outputCatalog, wcs, calib);
167  }, "inputCatalog"_a, "outputCatalog"_a, "wcs"_a, "calib"_a);
168 
169  /* Members */
170 }
171 
172 }}}} // lsst::meas::base::
173 
174 #endif
175 
STL class.
void declareAlgorithm(PyAlg &clsAlgorithm)
Wrap the implicit API used by meas_base&#39;s algorithms.
Definition: python.h:88
std::enable_if<!std::is_abstract< Algorithm >::value, void >::type declareAlgorithmConstructor(PyAlg &cls)
Wrap the standard algorithm constructor.
Definition: python.h:55