lsst.afw  13.0-94-ga1c444047
cameraSys.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * See COPYRIGHT file at the top of the source tree.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
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 
23 #include <string>
24 
25 #include <pybind11/pybind11.h>
26 //#include <pybind11/stl.h>
27 
31 
32 namespace py = pybind11;
33 using namespace py::literals;
34 
35 namespace lsst {
36 namespace afw {
37 namespace cameraGeom {
38 
39 namespace {
46 template <typename CppClass, typename PyClass>
47 void declareCommonSysMethods(PyClass &cls) {
48  /* Operators */
49  cls.def("__eq__", [](CppClass const &self, CppClass const &other) { return self == other; },
50  py::is_operator());
51  cls.def("__ne__", [](CppClass const &self, CppClass const &other) { return self != other; },
52  py::is_operator());
53  cls.def("__str__", [](CppClass const &self) {
54  std::ostringstream os;
55  os << self;
56  return os.str();
57  });
58  cls.def("__repr__", [](CppClass const &self) {
59  std::ostringstream os;
60  os << self;
61  return os.str();
62  });
63 
64  /* Methods */
65  cls.def("getSysName", &CppClass::getSysName);
66 }
67 }
68 
70  py::module mod("_cameraSys", "Python wrapper for afw _cameraSys library");
71 
72  /* Module level */
73  py::class_<CameraSysPrefix> clsCameraSysPrefix(mod, "CameraSysPrefix");
74  py::class_<CameraSys> clsCameraSys(mod, "CameraSys");
75 
76  geom::python::declareTransformMap<CameraSys>(mod, "Camera");
77 
78  // The following must come after the associated pybind11 class is declared
79  // (e.g. FOCAL_PLANE is a CameraSys, so clsCameraSys must have been declared
80  mod.attr("FOCAL_PLANE") = py::cast(FOCAL_PLANE);
81  mod.attr("PUPIL") = py::cast(PUPIL);
82  mod.attr("PIXELS") = py::cast(PIXELS);
83  mod.attr("TAN_PIXELS") = py::cast(TAN_PIXELS);
84  mod.attr("ACTUAL_PIXELS") = py::cast(ACTUAL_PIXELS);
85 
86  /* Member types and enums */
87  declareCommonSysMethods<CameraSysPrefix>(clsCameraSysPrefix);
88  declareCommonSysMethods<CameraSys>(clsCameraSys);
89 
90  /* Constructors */
91  clsCameraSysPrefix.def(py::init<std::string const &>(), "sysName"_a);
92  clsCameraSys.def(py::init<std::string const &, std::string const &>(), "sysName"_a,
93  "detectorName"_a = "");
94  clsCameraSys.def(py::init<CameraSysPrefix const &, std::string const &>(), "sysPrefix"_a,
95  "detectorName"_a = "");
96 
97  /* Operators */
98 
99  /* Members */
100  clsCameraSys.def("getDetectorName", &CameraSys::getDetectorName);
101  clsCameraSys.def("hasDetectorName", &CameraSys::hasDetectorName);
102 
103  return mod.ptr();
104 }
105 }
106 }
107 }
CameraSysPrefix const PIXELS
Nominal pixels on the detector (unbinned) This ignores manufacturing imperfections, "tree ring" distortions and all other such effects.
Definition: CameraSys.cc:33
CameraSys const PUPIL
Pupil coordinates: Angular x,y offset from the vertex at the pupil (radians).
Definition: CameraSys.cc:31
CameraSysPrefix const ACTUAL_PIXELS
The actual pixels where the photon lands and electrons are generated (unbinned) This takes into accou...
Definition: CameraSys.cc:37
PYBIND11_PLUGIN(_cameraSys)
Definition: cameraSys.cc:69
A base class for image defects.
Definition: cameraGeom.dox:3
CameraSysPrefix const TAN_PIXELS
Tangent-plane pixels on the detector (unbinned)
Definition: CameraSys.cc:35
CameraSys const FOCAL_PLANE
Focal plane coordinates: Rectilinear x, y (and z when talking about the location of a detector) on th...
Definition: CameraSys.cc:29