23 #include "pybind11/pybind11.h"
41 using namespace py::literals;
48 using PyExposureInfo = py::class_<ExposureInfo, std::shared_ptr<ExposureInfo>>;
52 void declareGenericMethods(PyExposureInfo &
cls) {
54 cls.def(
"setComponent",
56 self.setComponent(typehandling::makeKey<T>(
key),
object);
61 void declareGenericMethodsMerged(PyExposureInfo &
cls) {
62 using typehandling::Storable;
64 cls.def(
"hasComponent",
69 cls.def(
"getComponent",
71 auto sharedKey = typehandling::makeKey<std::shared_ptr<Storable const>>(
key);
73 if (
self.hasComponent(sharedKey)) {
74 return py::cast(
self.getComponent(sharedKey));
80 cls.def(
"removeComponent",
88 py::module::import(
"lsst.daf.base");
89 py::module::import(
"lsst.afw.geom.skyWcs");
90 py::module::import(
"lsst.afw.cameraGeom.detector");
91 py::module::import(
"lsst.afw.detection");
92 py::module::import(
"lsst.afw.image.photoCalib");
93 py::module::import(
"lsst.afw.image.apCorrMap");
94 py::module::import(
"lsst.afw.image.coaddInputs");
95 py::module::import(
"lsst.afw.image.filter");
96 py::module::import(
"lsst.afw.image.filterLabel");
97 py::module::import(
"lsst.afw.image.visitInfo");
100 PyExposureInfo
cls(mod,
"ExposureInfo");
120 cls.def(py::init<>());
121 cls.def(py::init<ExposureInfo>(),
"other"_a);
122 cls.def(py::init<ExposureInfo, bool>(),
"other"_a,
"copyMetadata"_a);
125 cls.attr(
"KEY_WCS") = ExposureInfo::KEY_WCS.getId();
126 cls.def(
"hasWcs", &ExposureInfo::hasWcs);
128 cls.def(
"setWcs", &ExposureInfo::setWcs,
"wcs"_a);
130 cls.attr(
"KEY_DETECTOR") = ExposureInfo::KEY_DETECTOR.getId();
131 cls.def(
"hasDetector", &ExposureInfo::hasDetector);
132 cls.def(
"getDetector", &ExposureInfo::getDetector);
133 cls.def(
"setDetector",
134 [](ExposureInfo &
self, py::object
detector) {
136 self.setDetector(nullptr);
138 self.setDetector(py::cast<std::shared_ptr<afw::cameraGeom::Detector>>(detector));
143 cls.def(
"getFilter", &ExposureInfo::getFilter);
144 cls.def(
"setFilter", &ExposureInfo::setFilter,
"filter"_a);
146 cls.attr(
"KEY_FILTER") = ExposureInfo::KEY_FILTER.getId();
147 cls.def(
"hasFilterLabel", &ExposureInfo::hasFilterLabel);
148 cls.def(
"getFilterLabel", &ExposureInfo::getFilterLabel);
149 cls.def(
"setFilterLabel", &ExposureInfo::setFilterLabel,
"filterLabel"_a);
151 declareGenericMethods<std::shared_ptr<typehandling::Storable const>>(
cls);
152 declareGenericMethodsMerged(
cls);
154 cls.attr(
"KEY_PHOTO_CALIB") = ExposureInfo::KEY_PHOTO_CALIB.getId();
155 cls.def(
"hasPhotoCalib", &ExposureInfo::hasPhotoCalib);
156 cls.def(
"getPhotoCalib", &ExposureInfo::getPhotoCalib);
157 cls.def(
"setPhotoCalib", &ExposureInfo::setPhotoCalib,
"photoCalib"_a);
159 cls.def(
"getMetadata", &ExposureInfo::getMetadata);
160 cls.def(
"setMetadata", &ExposureInfo::setMetadata,
"metadata"_a);
162 cls.attr(
"KEY_PSF") = ExposureInfo::KEY_PSF.getId();
163 cls.def(
"hasPsf", &ExposureInfo::hasPsf);
164 cls.def(
"getPsf", &ExposureInfo::getPsf);
166 [](ExposureInfo &
self, py::object
psf) {
167 if (
psf.is(py::none())) {
168 self.setPsf(nullptr);
170 self.setPsf(py::cast<std::shared_ptr<afw::detection::Psf>>(psf));
175 cls.attr(
"KEY_VALID_POLYGON") = ExposureInfo::KEY_VALID_POLYGON.getId();
176 cls.def(
"hasValidPolygon", &ExposureInfo::hasValidPolygon);
177 cls.def(
"getValidPolygon", &ExposureInfo::getValidPolygon);
178 cls.def(
"setValidPolygon",
179 [](ExposureInfo &
self, py::object polygon) {
180 if (polygon.is(py::none())) {
181 self.setValidPolygon(nullptr);
183 self.setValidPolygon(py::cast<std::shared_ptr<afw::geom::polygon::Polygon>>(polygon));
188 cls.attr(
"KEY_AP_CORR_MAP") = ExposureInfo::KEY_AP_CORR_MAP.getId();
189 cls.def(
"hasApCorrMap", &ExposureInfo::hasApCorrMap);
191 cls.def(
"setApCorrMap", &ExposureInfo::setApCorrMap,
"apCorrMap"_a);
192 cls.def(
"initApCorrMap", &ExposureInfo::initApCorrMap);
194 cls.attr(
"KEY_COADD_INPUTS") = ExposureInfo::KEY_COADD_INPUTS.getId();
195 cls.def(
"hasCoaddInputs", &ExposureInfo::hasCoaddInputs);
196 cls.def(
"getCoaddInputs", &ExposureInfo::getCoaddInputs);
197 cls.def(
"setCoaddInputs", &ExposureInfo::setCoaddInputs,
"coaddInputs"_a);
199 cls.def(
"hasVisitInfo", &ExposureInfo::hasVisitInfo);
200 cls.def(
"getVisitInfo", &ExposureInfo::getVisitInfo);
201 cls.def(
"setVisitInfo", &ExposureInfo::setVisitInfo,
"visitInfo"_a);
203 cls.attr(
"KEY_TRANSMISSION_CURVE") = ExposureInfo::KEY_TRANSMISSION_CURVE.getId();
204 cls.def(
"hasTransmissionCurve", &ExposureInfo::hasTransmissionCurve);
205 cls.def(
"getTransmissionCurve", &ExposureInfo::getTransmissionCurve);
206 cls.def(
"setTransmissionCurve", &ExposureInfo::setTransmissionCurve,
"transmissionCurve"_a);