LSSTApplications  15.0+21,16.0+1,16.0+3,16.0+4,16.0+8,16.0-1-g2115a9e+2,16.0-1-g4515a79+6,16.0-1-g5c6f5ee+4,16.0-1-g7bb14cc,16.0-1-g80120d7+4,16.0-1-g98efed3+4,16.0-1-gb7f560d+1,16.0-14-gb4f0cd2fa,16.0-2-g1ad129e+1,16.0-2-g2ed7261+1,16.0-2-g311bfd2,16.0-2-g568a347+3,16.0-2-g852da13+6,16.0-2-gd4c87cb+3,16.0-3-g099ede0,16.0-3-g150e024+3,16.0-3-g1f513a6,16.0-3-g958ce35,16.0-4-g08dccf71+4,16.0-4-g128aaef,16.0-4-g84f75fb+5,16.0-4-gcfd1396+4,16.0-4-gde8cee2,16.0-4-gdfb0d14+1,16.0-5-g7bc0afb+3,16.0-5-g86fb31a+3,16.0-6-g2dd73041+4,16.0-7-g95fb7bf,16.0-7-gc37dbc2+4,w.2018.28
LSSTDataManagementBasePackage
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 "ndarray/pybind11.h"
30 
33 #include "lsst/geom.h"
34 #include "lsst/afw/table/AmpInfo.h"
37 
38 namespace py = pybind11;
39 using namespace py::literals;
40 
41 namespace lsst {
42 namespace afw {
43 namespace cameraGeom {
44 
45 // Declare Detector methods overloaded on one coordinate system class
46 template <typename SysT, typename PyClass>
47 void declare1SysMethods(PyClass &cls) {
48  cls.def("getCorners",
49  (std::vector<lsst::geom::Point2D>(Detector::*)(SysT const &) const) & Detector::getCorners,
50  "cameraSys"_a);
51  cls.def("getCenter", (lsst::geom::Point2D(Detector::*)(SysT const &) const) & Detector::getCenter,
52  "cameraSys"_a);
53  cls.def("hasTransform", (bool (Detector::*)(SysT const &) const) & Detector::hasTransform, "cameraSys"_a);
54  cls.def("makeCameraSys", (CameraSys const (Detector::*)(SysT const &) const) & Detector::makeCameraSys,
55  "cameraSys"_a);
56 }
57 
58 // Declare Detector methods templated on two coordinate system classes
59 template <typename FromSysT, typename ToSysT, typename PyClass>
60 void declare2SysMethods(PyClass &cls) {
61  cls.def("getTransform",
62  (std::shared_ptr<geom::TransformPoint2ToPoint2>(Detector::*)(FromSysT const &, ToSysT const &)
63  const) &
64  Detector::getTransform,
65  "fromSys"_a, "toSys"_a);
66  cls.def("transform",
67  (lsst::geom::Point2D(Detector::*)(lsst::geom::Point2D const &, FromSysT const &, ToSysT const &) const) &
69  "point"_a, "fromSys"_a, "toSys"_a);
70  cls.def("transform",
72  ToSysT const &) const) &
73  Detector::transform,
74  "points"_a, "fromSys"_a, "toSys"_a);
75 }
76 
77 PYBIND11_PLUGIN(_detector) {
78  py::module mod("_detector", "Python wrapper for afw _detector library");
79 
80  /* Module level */
81  py::class_<Detector, std::shared_ptr<Detector>> cls(mod, "Detector");
82 
83  /* Member types and enums */
84  py::enum_<DetectorType>(mod, "DetectorType")
85  .value("SCIENCE", DetectorType::SCIENCE)
86  .value("FOCUS", DetectorType::FOCUS)
87  .value("GUIDER", DetectorType::GUIDER)
88  .value("WAVEFRONT", DetectorType::WAVEFRONT)
89  .export_values();
90 
91  /* Constructors */
92  cls.def(py::init<std::string const &, int, DetectorType, std::string const &, lsst::geom::Box2I const &,
93  table::AmpInfoCatalog const &, Orientation const &, lsst::geom::Extent2D const &,
95  "name"_a, "id"_a, "type"_a, "serial"_a, "bbox"_a, "ampInfoCatalog"_a, "orientation"_a,
96  "pixelSize"_a, "transforms"_a, "crosstalk"_a = Detector::CrosstalkMatrix());
97 
98  /* Operators */
99  cls.def("__getitem__",
100  (std::shared_ptr<table::AmpInfoRecord const>(Detector::*)(int) const) & Detector::_get, "i"_a);
101  cls.def("__getitem__",
103  Detector::_get,
104  "name"_a);
105  cls.def("__len__", &Detector::size);
106 
107  /* Members */
108  cls.def("getName", &Detector::getName);
109  cls.def("getId", &Detector::getId);
110  cls.def("getType", &Detector::getType);
111  cls.def("getSerial", &Detector::getSerial);
112  cls.def("getBBox", &Detector::getBBox);
113  cls.def("getAmpInfoCatalog", &Detector::getAmpInfoCatalog);
114  cls.def("getOrientation", &Detector::getOrientation);
115  cls.def("getPixelSize", &Detector::getPixelSize);
116  cls.def("hasCrosstalk", &Detector::hasCrosstalk);
117  cls.def("getCrosstalk", &Detector::getCrosstalk);
118  cls.def("getTransformMap", &Detector::getTransformMap);
119  cls.def("getNativeCoordSys", &Detector::getNativeCoordSys);
120  declare1SysMethods<CameraSys>(cls);
121  declare1SysMethods<CameraSysPrefix>(cls);
122  declare2SysMethods<CameraSys, CameraSys>(cls);
123  declare2SysMethods<CameraSys, CameraSysPrefix>(cls);
124  declare2SysMethods<CameraSysPrefix, CameraSys>(cls);
125  declare2SysMethods<CameraSysPrefix, CameraSysPrefix>(cls);
126 
127  return mod.ptr();
128 }
129 } // namespace cameraGeom
130 } // namespace afw
131 } // namespace lsst
Camera coordinate system; used as a key in in TransformMap.
Definition: CameraSys.h:83
void declare1SysMethods(PyClass &cls)
Definition: detector.cc:47
def init()
Definition: tests.py:79
table::Key< int > transform
void declare2SysMethods(PyClass &cls)
Definition: detector.cc:60
Describe a detector&#39;s orientation in the focal plane.
Definition: Orientation.h:52
STL class.
A base class for image defects.
Definition: cameraGeom.dox:3
STL class.
Information about a CCD or other imaging detector.
Definition: Detector.h:64
PYBIND11_PLUGIN(_detector)
Definition: detector.cc:77
DetectorType
Type of imaging detector.
Definition: Detector.h:43
ndarray::Array< float const, 2 > CrosstalkMatrix
Definition: Detector.h:66
An integer coordinate rectangle.
Definition: Box.h:54