lsst.afw  13.0-91-g2a3e2ee
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
detector.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 <memory>
24 #include <string>
25 
26 #include <pybind11/pybind11.h>
27 #include <pybind11/stl.h>
28 
32 #include "lsst/afw/geom/Box.h"
33 #include "lsst/afw/geom/Extent.h"
34 #include "lsst/afw/geom/Point.h"
37 #include "lsst/afw/table/AmpInfo.h"
39 
40 namespace py = pybind11;
41 using namespace py::literals;
42 
43 namespace lsst {
44 namespace afw {
45 namespace cameraGeom {
46 
47 PYBIND11_PLUGIN(_detector) {
48  py::module mod("_detector", "Python wrapper for afw _detector library");
49 
50  /* Module level */
51  py::class_<Detector, std::shared_ptr<Detector>> cls(mod, "Detector");
52 
53  /* Member types and enums */
54  py::enum_<DetectorType>(mod, "DetectorType")
55  .value("SCIENCE", DetectorType::SCIENCE)
56  .value("FOCUS", DetectorType::FOCUS)
57  .value("GUIDER", DetectorType::GUIDER)
58  .value("WAVEFRONT", DetectorType::WAVEFRONT)
59  .export_values();
60 
61  /* Constructors */
62  cls.def(py::init<std::string const &, int, DetectorType, std::string const &, geom::Box2I const &,
63  table::AmpInfoCatalog const &, Orientation const &, geom::Extent2D const &,
65  "name"_a, "id"_a, "type"_a, "serial"_a, "bbox"_a, "ampInfoCatalog"_a, "orientation"_a,
66  "pixelSize"_a, "transforms"_a);
67 
68  /* Operators */
69  cls.def("__getitem__",
70  (std::shared_ptr<table::AmpInfoRecord const>(Detector::*)(int) const) & Detector::_get, "i"_a);
71  cls.def("__getitem__",
72  (std::shared_ptr<table::AmpInfoRecord const>(Detector::*)(std::string const &) const) &
73  Detector::_get,
74  "name"_a);
75  cls.def("__len__", &Detector::size);
76 
77  /* Members */
78  cls.def("getName", &Detector::getName);
79  cls.def("getId", &Detector::getId);
80  cls.def("getType", &Detector::getType);
81  cls.def("getSerial", &Detector::getSerial);
82  cls.def("getBBox", &Detector::getBBox);
83  cls.def("getCorners",
84  (std::vector<geom::Point2D>(Detector::*)(CameraSys const &) const) & Detector::getCorners,
85  "cameraSys"_a);
86  cls.def("getCorners",
87  (std::vector<geom::Point2D>(Detector::*)(CameraSysPrefix const &) const) & Detector::getCorners,
88  "cameraSysPrefix"_a);
89  cls.def("getCenter", (CameraPoint(Detector::*)(CameraSys const &) const) & Detector::getCenter,
90  "getCenter"_a);
91  cls.def("getCenter", (CameraPoint(Detector::*)(CameraSysPrefix const &) const) & Detector::getCenter,
92  "getCenterPrefix"_a);
93  cls.def("getAmpInfoCatalog", &Detector::getAmpInfoCatalog);
94  cls.def("getOrientation", &Detector::getOrientation);
95  cls.def("getPixelSize", &Detector::getPixelSize);
96  cls.def("getTransformMap", &Detector::getTransformMap);
97  cls.def("hasTransform", (bool (Detector::*)(CameraSys const &) const) & Detector::hasTransform,
98  "cameraSys"_a);
99  cls.def("hasTransform", (bool (Detector::*)(CameraSysPrefix const &) const) & Detector::hasTransform,
100  "cameraSysPrefix"_a);
101  cls.def("getTransform",
102  (std::shared_ptr<geom::XYTransform const>(Detector::*)(CameraSys const &) const) &
103  Detector::getTransform,
104  "cameraSys"_a);
105  cls.def("getTransform",
106  (std::shared_ptr<geom::XYTransform const>(Detector::*)(CameraSysPrefix const &) const) &
107  Detector::getTransform,
108  "cameraSysPrefix"_a);
109  cls.def("makeCameraPoint",
110  (CameraPoint(Detector::*)(geom::Point2D const &, CameraSys const &) const) &
111  Detector::makeCameraPoint,
112  "point"_a, "cameraSys"_a);
113  cls.def("makeCameraPoint",
114  (CameraPoint(Detector::*)(geom::Point2D const &, CameraSysPrefix const &) const) &
115  Detector::makeCameraPoint,
116  "point"_a, "cameraSysPrefix"_a);
117  cls.def("makeCameraSys",
118  (CameraSys const (Detector::*)(CameraSys const &) const) & Detector::makeCameraSys,
119  "cameraSys"_a);
120  cls.def("makeCameraSys",
121  (CameraSys const (Detector::*)(CameraSysPrefix const &) const) & Detector::makeCameraSys,
122  "cameraSysPrefix"_a);
123  cls.def("transform",
124  (CameraPoint(Detector::*)(CameraPoint const &, CameraSys const &) const) & Detector::transform,
125  "fromCameraPoint"_a, "toSys"_a);
126  cls.def("transform",
127  (CameraPoint(Detector::*)(CameraPoint const &, CameraSysPrefix const &) const) &
128  Detector::transform,
129  "fromCameraPoint"_a, "toSys"_a);
130 
131  return mod.ptr();
132 }
133 } // namespace cameraGeom
134 } // namespace afw
135 } // namespace lsst
Camera coordinate system; used as a key in in TransformMap.
Definition: CameraSys.h:74
A custom container class for records, based on std::vector.
Definition: Catalog.h:96
An integer coordinate rectangle.
Definition: Box.h:55
Describe a detector&#39;s orientation in the focal plane.
Definition: Orientation.h:51
std::map< CameraSys, std::shared_ptr< XYTransform const > > Transforms
Definition: TransformMap.h:67
PYBIND11_PLUGIN(_cameraPoint)
Definition: cameraPoint.cc:35
double const _a
Definition: RandomImage.cc:77
Camera coordinate system prefix.
Definition: CameraSys.h:46
Information about a CCD or other imaging detector.
Definition: Detector.h:64
A Point2D with associated camera coordinate system.
Definition: CameraPoint.h:37
DetectorType
Type of imaging detector.
Definition: Detector.h:43