lsst.afw  13.0-98-g5a654715e+2
 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 
29 #include "numpy/arrayobject.h"
30 #include "ndarray/pybind11.h"
31 
35 #include "lsst/afw/geom/Box.h"
36 #include "lsst/afw/geom/Extent.h"
37 #include "lsst/afw/geom/Point.h"
38 #include "lsst/afw/table/AmpInfo.h"
41 
42 namespace py = pybind11;
43 using namespace py::literals;
44 
45 namespace lsst {
46 namespace afw {
47 namespace cameraGeom {
48 
49 PYBIND11_PLUGIN(_detector) {
50  py::module mod("_detector", "Python wrapper for afw _detector library");
51 
52  // Need to import numpy for ndarray and eigen conversions
53  if (_import_array() < 0) {
54  PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
55  return nullptr;
56  }
57 
58  /* Module level */
59  py::class_<Detector, std::shared_ptr<Detector>> cls(mod, "Detector");
60 
61  /* Member types and enums */
62  py::enum_<DetectorType>(mod, "DetectorType")
63  .value("SCIENCE", DetectorType::SCIENCE)
64  .value("FOCUS", DetectorType::FOCUS)
65  .value("GUIDER", DetectorType::GUIDER)
66  .value("WAVEFRONT", DetectorType::WAVEFRONT)
67  .export_values();
68 
69  /* Constructors */
70  cls.def(py::init<std::string const &, int, DetectorType, std::string const &, geom::Box2I const &,
71  table::AmpInfoCatalog const &, Orientation const &, geom::Extent2D const &,
73  "name"_a, "id"_a, "type"_a, "serial"_a, "bbox"_a, "ampInfoCatalog"_a, "orientation"_a,
74  "pixelSize"_a, "transforms"_a, "crosstalk"_a=Detector::CrosstalkMatrix());
75 
76  /* Operators */
77  cls.def("__getitem__",
78  (std::shared_ptr<table::AmpInfoRecord const>(Detector::*)(int) const) & Detector::_get, "i"_a);
79  cls.def("__getitem__",
80  (std::shared_ptr<table::AmpInfoRecord const>(Detector::*)(std::string const &) const) &
81  Detector::_get,
82  "name"_a);
83  cls.def("__len__", &Detector::size);
84 
85  /* Members */
86  cls.def("getName", &Detector::getName);
87  cls.def("getId", &Detector::getId);
88  cls.def("getType", &Detector::getType);
89  cls.def("getSerial", &Detector::getSerial);
90  cls.def("getBBox", &Detector::getBBox);
91  cls.def("getCorners",
92  (std::vector<geom::Point2D>(Detector::*)(CameraSys const &) const) & Detector::getCorners,
93  "cameraSys"_a);
94  cls.def("getCorners",
95  (std::vector<geom::Point2D>(Detector::*)(CameraSysPrefix const &) const) & Detector::getCorners,
96  "cameraSysPrefix"_a);
97  cls.def("getCenter", (CameraPoint(Detector::*)(CameraSys const &) const) & Detector::getCenter,
98  "getCenter"_a);
99  cls.def("getCenter", (CameraPoint(Detector::*)(CameraSysPrefix const &) const) & Detector::getCenter,
100  "getCenterPrefix"_a);
101  cls.def("getAmpInfoCatalog", &Detector::getAmpInfoCatalog);
102  cls.def("getOrientation", &Detector::getOrientation);
103  cls.def("getPixelSize", &Detector::getPixelSize);
104  cls.def("hasCrosstalk", &Detector::hasCrosstalk);
105  cls.def("getCrosstalk", &Detector::getCrosstalk);
106  cls.def("getTransformMap", &Detector::getTransformMap);
107  cls.def("hasTransform", (bool (Detector::*)(CameraSys const &) const) & Detector::hasTransform,
108  "cameraSys"_a);
109  cls.def("hasTransform", (bool (Detector::*)(CameraSysPrefix const &) const) & Detector::hasTransform,
110  "cameraSysPrefix"_a);
111  cls.def("getTransform",
112  (std::shared_ptr<geom::TransformPoint2ToPoint2>(Detector::*)(CameraSys const &, CameraSys const &)
113  const) &
114  Detector::getTransform,
115  "fromSys"_a, "toSys"_a);
116  cls.def("getTransform",
117  (std::shared_ptr<geom::TransformPoint2ToPoint2>(Detector::*)(CameraSys const &,
118  CameraSysPrefix const &) const) &
119  Detector::getTransform,
120  "fromSys"_a, "toSys"_a);
121  cls.def("getTransform",
122  (std::shared_ptr<geom::TransformPoint2ToPoint2>(Detector::*)(CameraSysPrefix const &,
123  CameraSys const &) const) &
124  Detector::getTransform,
125  "fromSys"_a, "toSys"_a);
126  cls.def("getTransform",
127  (std::shared_ptr<geom::TransformPoint2ToPoint2>(Detector::*)(CameraSysPrefix const &,
128  CameraSysPrefix const &) const) &
129  Detector::getTransform,
130  "fromSys"_a, "toSys"_a);
131  cls.def("getNativeCoordSys", &Detector::getNativeCoordSys);
132  cls.def("makeCameraPoint",
133  (CameraPoint(Detector::*)(geom::Point2D const &, CameraSys const &) const) &
134  Detector::makeCameraPoint,
135  "point"_a, "cameraSys"_a);
136  cls.def("makeCameraPoint",
137  (CameraPoint(Detector::*)(geom::Point2D const &, CameraSysPrefix const &) const) &
138  Detector::makeCameraPoint,
139  "point"_a, "cameraSysPrefix"_a);
140  cls.def("makeCameraSys",
141  (CameraSys const (Detector::*)(CameraSys const &) const) & Detector::makeCameraSys,
142  "cameraSys"_a);
143  cls.def("makeCameraSys",
144  (CameraSys const (Detector::*)(CameraSysPrefix const &) const) & Detector::makeCameraSys,
145  "cameraSysPrefix"_a);
146  cls.def("transform",
147  (CameraPoint(Detector::*)(CameraPoint const &, CameraSys const &) const) & Detector::transform,
148  "fromCameraPoint"_a, "toSys"_a);
149  cls.def("transform",
150  (CameraPoint(Detector::*)(CameraPoint const &, CameraSysPrefix const &) const) &
151  Detector::transform,
152  "fromCameraPoint"_a, "toSys"_a);
153 
154  return mod.ptr();
155 }
156 } // namespace cameraGeom
157 } // namespace afw
158 } // 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
ndarray::Array< float const, 2 > CrosstalkMatrix
Definition: Detector.h:66
std::unordered_map< CameraSys, std::shared_ptr< geom::TransformPoint2ToPoint2 >> Transforms
Definition: TransformMap.h:65