lsst.afw  13.0-95-g793934f
 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"
35 #include "lsst/afw/table/AmpInfo.h"
38 
39 namespace py = pybind11;
40 using namespace py::literals;
41 
42 namespace lsst {
43 namespace afw {
44 namespace cameraGeom {
45 
46 PYBIND11_PLUGIN(_detector) {
47  py::module mod("_detector", "Python wrapper for afw _detector library");
48 
49  /* Module level */
50  py::class_<Detector, std::shared_ptr<Detector>> cls(mod, "Detector");
51 
52  /* Member types and enums */
53  py::enum_<DetectorType>(mod, "DetectorType")
54  .value("SCIENCE", DetectorType::SCIENCE)
55  .value("FOCUS", DetectorType::FOCUS)
56  .value("GUIDER", DetectorType::GUIDER)
57  .value("WAVEFRONT", DetectorType::WAVEFRONT)
58  .export_values();
59 
60  /* Constructors */
61  cls.def(py::init<std::string const &, int, DetectorType, std::string const &, geom::Box2I const &,
62  table::AmpInfoCatalog const &, Orientation const &, geom::Extent2D const &,
63  TransformMap::Transforms const &>(),
64  "name"_a, "id"_a, "type"_a, "serial"_a, "bbox"_a, "ampInfoCatalog"_a, "orientation"_a,
65  "pixelSize"_a, "transforms"_a);
66 
67  /* Operators */
68  cls.def("__getitem__",
69  (std::shared_ptr<table::AmpInfoRecord const>(Detector::*)(int) const) & Detector::_get, "i"_a);
70  cls.def("__getitem__",
71  (std::shared_ptr<table::AmpInfoRecord const>(Detector::*)(std::string const &) const) &
72  Detector::_get,
73  "name"_a);
74  cls.def("__len__", &Detector::size);
75 
76  /* Members */
77  cls.def("getName", &Detector::getName);
78  cls.def("getId", &Detector::getId);
79  cls.def("getType", &Detector::getType);
80  cls.def("getSerial", &Detector::getSerial);
81  cls.def("getBBox", &Detector::getBBox);
82  cls.def("getCorners",
83  (std::vector<geom::Point2D>(Detector::*)(CameraSys const &) const) & Detector::getCorners,
84  "cameraSys"_a);
85  cls.def("getCorners",
86  (std::vector<geom::Point2D>(Detector::*)(CameraSysPrefix const &) const) & Detector::getCorners,
87  "cameraSysPrefix"_a);
88  cls.def("getCenter", (CameraPoint(Detector::*)(CameraSys const &) const) & Detector::getCenter,
89  "getCenter"_a);
90  cls.def("getCenter", (CameraPoint(Detector::*)(CameraSysPrefix const &) const) & Detector::getCenter,
91  "getCenterPrefix"_a);
92  cls.def("getAmpInfoCatalog", &Detector::getAmpInfoCatalog);
93  cls.def("getOrientation", &Detector::getOrientation);
94  cls.def("getPixelSize", &Detector::getPixelSize);
95  cls.def("getTransformMap", &Detector::getTransformMap);
96  cls.def("hasTransform", (bool (Detector::*)(CameraSys const &) const) & Detector::hasTransform,
97  "cameraSys"_a);
98  cls.def("hasTransform", (bool (Detector::*)(CameraSysPrefix const &) const) & Detector::hasTransform,
99  "cameraSysPrefix"_a);
100  cls.def("getTransform",
101  (std::shared_ptr<geom::TransformPoint2ToPoint2>(Detector::*)(CameraSys const &, CameraSys const &)
102  const) &
103  Detector::getTransform,
104  "fromSys"_a, "toSys"_a);
105  cls.def("getTransform",
106  (std::shared_ptr<geom::TransformPoint2ToPoint2>(Detector::*)(CameraSys const &,
107  CameraSysPrefix const &) const) &
108  Detector::getTransform,
109  "fromSys"_a, "toSys"_a);
110  cls.def("getTransform",
111  (std::shared_ptr<geom::TransformPoint2ToPoint2>(Detector::*)(CameraSysPrefix const &,
112  CameraSys const &) const) &
113  Detector::getTransform,
114  "fromSys"_a, "toSys"_a);
115  cls.def("getTransform",
116  (std::shared_ptr<geom::TransformPoint2ToPoint2>(Detector::*)(CameraSysPrefix const &,
117  CameraSysPrefix const &) const) &
118  Detector::getTransform,
119  "fromSys"_a, "toSys"_a);
120  cls.def("getNativeCoordSys", &Detector::getNativeCoordSys);
121  cls.def("makeCameraPoint",
122  (CameraPoint(Detector::*)(geom::Point2D const &, CameraSys const &) const) &
123  Detector::makeCameraPoint,
124  "point"_a, "cameraSys"_a);
125  cls.def("makeCameraPoint",
126  (CameraPoint(Detector::*)(geom::Point2D const &, CameraSysPrefix const &) const) &
127  Detector::makeCameraPoint,
128  "point"_a, "cameraSysPrefix"_a);
129  cls.def("makeCameraSys",
130  (CameraSys const (Detector::*)(CameraSys const &) const) & Detector::makeCameraSys,
131  "cameraSys"_a);
132  cls.def("makeCameraSys",
133  (CameraSys const (Detector::*)(CameraSysPrefix const &) const) & Detector::makeCameraSys,
134  "cameraSysPrefix"_a);
135  cls.def("transform",
136  (CameraPoint(Detector::*)(CameraPoint const &, CameraSys const &) const) & Detector::transform,
137  "fromCameraPoint"_a, "toSys"_a);
138  cls.def("transform",
139  (CameraPoint(Detector::*)(CameraPoint const &, CameraSysPrefix const &) const) &
140  Detector::transform,
141  "fromCameraPoint"_a, "toSys"_a);
142 
143  return mod.ptr();
144 }
145 } // namespace cameraGeom
146 } // namespace afw
147 } // namespace lsst
Camera coordinate system; used as a key in in TransformMap.
Definition: CameraSys.h:77
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
PYBIND11_PLUGIN(_cameraPoint)
Definition: cameraPoint.cc:35
double const _a
Definition: RandomImage.cc:77
Camera coordinate system prefix.
Definition: CameraSys.h:44
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
std::unordered_map< CameraSys, std::shared_ptr< geom::TransformPoint2ToPoint2 >> Transforms
Definition: TransformMap.h:65