26 #include "pybind11/pybind11.h"
27 #include "pybind11/stl.h"
29 #include "ndarray/pybind11.h"
41 using namespace py::literals;
45 namespace cameraGeom {
49 using PyDetectorBase = py::class_<DetectorBase, std::shared_ptr<DetectorBase>>;
50 using PyDetector = py::class_<Detector, DetectorBase, std::shared_ptr<Detector>, typehandling::Storable>;
51 using PyDetectorBuilder = py::class_<Detector::Builder, DetectorBase, std::shared_ptr<Detector::Builder>>;
52 using PyDetectorPartialRebuilder = py::class_<Detector::PartialRebuilder, Detector::Builder,
54 using PyDetectorInCameraBuilder = py::class_<Detector::InCameraBuilder, Detector::Builder,
58 template <
typename SysT,
typename PyClass>
65 cls.def(
"hasTransform", (
bool (Detector::*)(SysT
const &)
const) & Detector::hasTransform,
"cameraSys"_a);
70 template <
typename FromSysT,
typename ToSysT,
typename PyClass>
72 cls.def(
"getTransform",
75 Detector::getTransform,
76 "fromSys"_a,
"toSys"_a);
80 "point"_a,
"fromSys"_a,
"toSys"_a);
83 ToSysT
const &)
const) &
85 "points"_a,
"fromSys"_a,
"toSys"_a);
89 PyDetectorBase
cls(mod,
"DetectorBase");
90 cls.def(
"getName", &DetectorBase::getName);
91 cls.def(
"getId", &DetectorBase::getId);
92 cls.def(
"getType", &DetectorBase::getType);
93 cls.def(
"getPhysicalType", &DetectorBase::getPhysicalType);
94 cls.def(
"getSerial", &DetectorBase::getSerial);
95 cls.def(
"getBBox", &DetectorBase::getBBox);
96 cls.def(
"getOrientation", &DetectorBase::getOrientation);
97 cls.def(
"getPixelSize", &DetectorBase::getPixelSize);
98 cls.def(
"hasCrosstalk", &DetectorBase::hasCrosstalk);
99 cls.def(
"getCrosstalk", &DetectorBase::getCrosstalk);
100 cls.def(
"getNativeCoordSys", &DetectorBase::getNativeCoordSys);
101 cls.def(
"makeCameraSys",
102 py::overload_cast<CameraSys const &>(&DetectorBase::makeCameraSys, py::const_),
104 cls.def(
"makeCameraSys",
105 py::overload_cast<CameraSysPrefix const &>(&DetectorBase::makeCameraSys, py::const_),
106 "cameraSysPrefix"_a);
109 void declareDetectorBuilder(PyDetector & parent);
110 void declareDetectorPartialRebuilder(PyDetector & parent);
111 void declareDetectorInCameraBuilder(PyDetector & parent);
114 py::module::import(
"lsst.afw.typehandling");
115 PyDetector
cls(mod,
"Detector");
116 declareDetectorBuilder(
cls);
117 declareDetectorPartialRebuilder(
cls);
118 declareDetectorInCameraBuilder(
cls);
119 cls.def(
"rebuild", &Detector::rebuild);
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 cls.def(
"getTransformMap", &Detector::getTransformMap);
127 cls.def(
"getAmplifiers", &Detector::getAmplifiers);
129 cls.def(
"__getitem__",
134 cls.def(
"__getitem__",
135 py::overload_cast<std::string const &>(&Detector::operator[], py::const_),
137 cls.def(
"__len__", &Detector::size);
141 void declareDetectorBuilder(PyDetector & parent) {
142 PyDetectorBuilder
cls(parent,
"Builder");
143 cls.def(
"setBBox", &Detector::Builder::setBBox);
144 cls.def(
"setType", &Detector::Builder::setType);
145 cls.def(
"setSerial", &Detector::Builder::setSerial);
146 cls.def(
"setPhysicalType", &Detector::Builder::setPhysicalType);
147 cls.def(
"setCrosstalk", &Detector::Builder::setCrosstalk);
148 cls.def(
"unsetCrosstalk", &Detector::Builder::unsetCrosstalk);
149 cls.def(
"getAmplifiers", &Detector::Builder::getAmplifiers);
151 cls.def(
"__getitem__",
156 cls.def(
"__getitem__",
157 py::overload_cast<std::string const &>(&Detector::Builder::operator[], py::const_),
160 cls.def(
"clear", &Detector::Builder::clear);
161 cls.def(
"__len__", &Detector::Builder::size);
164 void declareDetectorPartialRebuilder(PyDetector & parent) {
165 PyDetectorPartialRebuilder
cls(parent,
"PartialRebuilder");
166 cls.def(py::init<Detector const &>(),
"detector"_a);
167 cls.def(
"finish", &Detector::PartialRebuilder::finish);
170 void declareDetectorInCameraBuilder(PyDetector & parent) {
171 PyDetectorInCameraBuilder
cls(parent,
"InCameraBuilder");
172 cls.def(
"setOrientation", &Detector::InCameraBuilder::setOrientation);
173 cls.def(
"setPixelSize", &Detector::InCameraBuilder::setPixelSize);
174 cls.def(
"setTransformFromPixelsTo",
175 py::overload_cast<CameraSysPrefix
const &,
177 &Detector::InCameraBuilder::setTransformFromPixelsTo
179 "toSys"_a,
"transform"_a);
180 cls.def(
"setTransformFromPixelsTo",
181 py::overload_cast<CameraSys
const &,
183 &Detector::InCameraBuilder::setTransformFromPixelsTo
185 "toSys"_a,
"transform"_a);
186 cls.def(
"discardTransformFromPixelsTo",
187 py::overload_cast<CameraSysPrefix const &>(
188 &Detector::InCameraBuilder::discardTransformFromPixelsTo
191 cls.def(
"discardTransformFromPixelsTo",
192 py::overload_cast<CameraSys const &>(
193 &Detector::InCameraBuilder::discardTransformFromPixelsTo
199 py::enum_<DetectorType>(mod,
"DetectorType")
200 .value(
"SCIENCE", DetectorType::SCIENCE)
201 .value(
"FOCUS", DetectorType::FOCUS)
202 .value(
"GUIDER", DetectorType::GUIDER)
203 .value(
"WAVEFRONT", DetectorType::WAVEFRONT)
205 declareDetectorBase(mod);
206 declareDetector(mod);