23 #include "pybind11/pybind11.h"
40 using namespace py::literals;
47 using PyExposureInfo = py::class_<ExposureInfo, std::shared_ptr<ExposureInfo>>;
51 void declareGenericMethods(PyExposureInfo &
cls) {
53 cls.def(
"setComponent",
55 self.setComponent(typehandling::makeKey<T>(
key),
object);
60 void declareGenericMethodsMerged(PyExposureInfo &
cls) {
61 using typehandling::Storable;
63 cls.def(
"hasComponent",
68 cls.def(
"getComponent",
70 auto sharedKey = typehandling::makeKey<std::shared_ptr<Storable const>>(
key);
72 if (
self.hasComponent(sharedKey)) {
73 return py::cast(
self.getComponent(sharedKey));
79 cls.def(
"removeComponent",
87 py::module::import(
"lsst.daf.base");
88 py::module::import(
"lsst.afw.geom.skyWcs");
89 py::module::import(
"lsst.afw.cameraGeom.detector");
90 py::module::import(
"lsst.afw.detection");
91 py::module::import(
"lsst.afw.image.photoCalib");
92 py::module::import(
"lsst.afw.image.apCorrMap");
93 py::module::import(
"lsst.afw.image.coaddInputs");
94 py::module::import(
"lsst.afw.image.filter");
95 py::module::import(
"lsst.afw.image.visitInfo");
98 PyExposureInfo
cls(mod,
"ExposureInfo");
118 cls.def(py::init<>());
119 cls.def(py::init<ExposureInfo>(),
"other"_a);
120 cls.def(py::init<ExposureInfo, bool>(),
"other"_a,
"copyMetadata"_a);
123 cls.attr(
"KEY_WCS") = ExposureInfo::KEY_WCS.getId();
124 cls.def(
"hasWcs", &ExposureInfo::hasWcs);
126 cls.def(
"setWcs", &ExposureInfo::setWcs,
"wcs"_a);
128 cls.attr(
"KEY_DETECTOR") = ExposureInfo::KEY_DETECTOR.getId();
129 cls.def(
"hasDetector", &ExposureInfo::hasDetector);
130 cls.def(
"getDetector", &ExposureInfo::getDetector);
131 cls.def(
"setDetector",
132 [](ExposureInfo &
self, py::object
detector) {
134 self.setDetector(nullptr);
136 self.setDetector(py::cast<std::shared_ptr<afw::cameraGeom::Detector>>(detector));
141 cls.def(
"getFilter", &ExposureInfo::getFilter);
142 cls.def(
"setFilter", &ExposureInfo::setFilter,
"filter"_a);
144 declareGenericMethods<std::shared_ptr<typehandling::Storable const>>(
cls);
145 declareGenericMethodsMerged(
cls);
147 cls.attr(
"KEY_PHOTO_CALIB") = ExposureInfo::KEY_PHOTO_CALIB.getId();
148 cls.def(
"hasPhotoCalib", &ExposureInfo::hasPhotoCalib);
149 cls.def(
"getPhotoCalib", &ExposureInfo::getPhotoCalib);
150 cls.def(
"setPhotoCalib", &ExposureInfo::setPhotoCalib,
"photoCalib"_a);
152 cls.def(
"getMetadata", &ExposureInfo::getMetadata);
153 cls.def(
"setMetadata", &ExposureInfo::setMetadata,
"metadata"_a);
155 cls.attr(
"KEY_PSF") = ExposureInfo::KEY_PSF.getId();
156 cls.def(
"hasPsf", &ExposureInfo::hasPsf);
157 cls.def(
"getPsf", &ExposureInfo::getPsf);
159 [](ExposureInfo &
self, py::object
psf) {
160 if (
psf.is(py::none())) {
161 self.setPsf(nullptr);
163 self.setPsf(py::cast<std::shared_ptr<afw::detection::Psf>>(psf));
168 cls.attr(
"KEY_VALID_POLYGON") = ExposureInfo::KEY_VALID_POLYGON.getId();
169 cls.def(
"hasValidPolygon", &ExposureInfo::hasValidPolygon);
170 cls.def(
"getValidPolygon", &ExposureInfo::getValidPolygon);
171 cls.def(
"setValidPolygon",
172 [](ExposureInfo &
self, py::object polygon) {
173 if (polygon.is(py::none())) {
174 self.setValidPolygon(nullptr);
176 self.setValidPolygon(py::cast<std::shared_ptr<afw::geom::polygon::Polygon>>(polygon));
181 cls.attr(
"KEY_AP_CORR_MAP") = ExposureInfo::KEY_AP_CORR_MAP.getId();
182 cls.def(
"hasApCorrMap", &ExposureInfo::hasApCorrMap);
184 cls.def(
"setApCorrMap", &ExposureInfo::setApCorrMap,
"apCorrMap"_a);
185 cls.def(
"initApCorrMap", &ExposureInfo::initApCorrMap);
187 cls.attr(
"KEY_COADD_INPUTS") = ExposureInfo::KEY_COADD_INPUTS.getId();
188 cls.def(
"hasCoaddInputs", &ExposureInfo::hasCoaddInputs);
189 cls.def(
"getCoaddInputs", &ExposureInfo::getCoaddInputs);
190 cls.def(
"setCoaddInputs", &ExposureInfo::setCoaddInputs,
"coaddInputs"_a);
192 cls.def(
"hasVisitInfo", &ExposureInfo::hasVisitInfo);
193 cls.def(
"getVisitInfo", &ExposureInfo::getVisitInfo);
194 cls.def(
"setVisitInfo", &ExposureInfo::setVisitInfo,
"visitInfo"_a);
196 cls.attr(
"KEY_TRANSMISSION_CURVE") = ExposureInfo::KEY_TRANSMISSION_CURVE.getId();
197 cls.def(
"hasTransmissionCurve", &ExposureInfo::hasTransmissionCurve);
198 cls.def(
"getTransmissionCurve", &ExposureInfo::getTransmissionCurve);
199 cls.def(
"setTransmissionCurve", &ExposureInfo::setTransmissionCurve,
"transmissionCurve"_a);