24 #include "pybind11/pybind11.h"
43 using namespace py::literals;
50 using PyExposureInfo = py::class_<ExposureInfo, std::shared_ptr<ExposureInfo>>;
54 void declareGenericMethods(PyExposureInfo &cls) {
59 self.setComponent(typehandling::makeKey<T>(
key),
object);
64 void declareGenericMethodsMerged(PyExposureInfo &cls) {
65 using typehandling::Storable;
76 auto sharedKey = typehandling::makeKey<std::shared_ptr<Storable const>>(
key);
78 if (
self.hasComponent(sharedKey)) {
79 return py::cast(
self.getComponent(sharedKey));
94 wrappers.
wrapType(PyExposureInfo(wrappers.
module,
"ExposureInfo"), [](
auto &mod,
auto &cls) {
96 cls.def(py::init<std::shared_ptr<geom::SkyWcs const> const &,
97 std::shared_ptr<detection::Psf const> const &,
98 std::shared_ptr<PhotoCalib const> const &,
99 std::shared_ptr<cameraGeom::Detector const> const &,
100 std::shared_ptr<geom::polygon::Polygon const> const &, Filter const &,
101 std::shared_ptr<daf::base::PropertySet> const &,
102 std::shared_ptr<CoaddInputs> const &, std::shared_ptr<ApCorrMap> const &,
103 std::shared_ptr<VisitInfo const> const &,
104 std::shared_ptr<TransmissionCurve const> const &>(),
105 "wcs"_a = std::shared_ptr<geom::SkyWcs const>(),
106 "psf"_a = std::shared_ptr<detection::Psf const>(),
107 "photoCalib"_a = std::shared_ptr<PhotoCalib const>(),
108 "detector"_a = std::shared_ptr<cameraGeom::Detector const>(),
109 "polygon"_a = std::shared_ptr<geom::polygon::Polygon const>(),
"filter"_a = Filter(),
110 "metadata"_a = std::shared_ptr<daf::base::PropertySet>(),
111 "coaddInputs"_a = std::shared_ptr<CoaddInputs>(),
112 "apCorrMap"_a = std::shared_ptr<ApCorrMap>(),
113 "visitInfo"_a = std::shared_ptr<VisitInfo const>(),
"transmissionCurve"_a = nullptr);
114 cls.def(py::init<>());
115 cls.def(py::init<ExposureInfo>(),
"other"_a);
116 cls.def(py::init<ExposureInfo, bool>(),
"other"_a,
"copyMetadata"_a);
119 cls.attr(
"KEY_WCS") = ExposureInfo::KEY_WCS.getId();
120 cls.def(
"hasWcs", &ExposureInfo::hasWcs);
121 cls.def(
"getWcs", (std::shared_ptr<geom::SkyWcs>(ExposureInfo::*)()) & ExposureInfo::getWcs);
122 cls.def(
"setWcs", &ExposureInfo::setWcs,
"wcs"_a);
124 cls.attr(
"KEY_DETECTOR") = ExposureInfo::KEY_DETECTOR.getId();
125 cls.def(
"hasDetector", &ExposureInfo::hasDetector);
126 cls.def(
"getDetector", &ExposureInfo::getDetector);
129 [](ExposureInfo &self, py::object detector) {
130 if (detector.is(py::none())) {
131 self.setDetector(nullptr);
133 self.setDetector(py::cast<std::shared_ptr<afw::cameraGeom::Detector>>(detector));
141 cls.attr(
"KEY_FILTER") = ExposureInfo::KEY_FILTER.getId();
142 cls.def(
"hasFilterLabel", &ExposureInfo::hasFilterLabel);
143 cls.def(
"getFilterLabel", &ExposureInfo::getFilterLabel);
144 cls.def(
"setFilterLabel", &ExposureInfo::setFilterLabel,
"filterLabel"_a);
146 declareGenericMethods<std::shared_ptr<typehandling::Storable const>>(cls);
147 declareGenericMethodsMerged(cls);
149 cls.attr(
"KEY_PHOTO_CALIB") = ExposureInfo::KEY_PHOTO_CALIB.getId();
150 cls.def(
"hasPhotoCalib", &ExposureInfo::hasPhotoCalib);
151 cls.def(
"getPhotoCalib", &ExposureInfo::getPhotoCalib);
152 cls.def(
"setPhotoCalib", &ExposureInfo::setPhotoCalib,
"photoCalib"_a);
154 cls.def(
"getMetadata", &ExposureInfo::getMetadata);
155 cls.def(
"setMetadata", &ExposureInfo::setMetadata,
"metadata"_a);
157 cls.attr(
"KEY_PSF") = ExposureInfo::KEY_PSF.getId();
158 cls.def(
"hasPsf", &ExposureInfo::hasPsf);
159 cls.def(
"getPsf", &ExposureInfo::getPsf);
162 [](ExposureInfo &
self, py::object
psf) {
163 if (
psf.is(py::none())) {
164 self.setPsf(nullptr);
166 self.setPsf(py::cast<std::shared_ptr<afw::detection::Psf>>(psf));
171 cls.attr(
"KEY_VALID_POLYGON") = ExposureInfo::KEY_VALID_POLYGON.getId();
172 cls.def(
"hasValidPolygon", &ExposureInfo::hasValidPolygon);
173 cls.def(
"getValidPolygon", &ExposureInfo::getValidPolygon);
176 [](ExposureInfo &
self, py::object polygon) {
177 if (polygon.is(py::none())) {
178 self.setValidPolygon(nullptr);
180 self.setValidPolygon(py::cast<std::shared_ptr<afw::geom::polygon::Polygon>>(polygon));
185 cls.attr(
"KEY_AP_CORR_MAP") = ExposureInfo::KEY_AP_CORR_MAP.getId();
186 cls.def(
"hasApCorrMap", &ExposureInfo::hasApCorrMap);
188 cls.def(
"setApCorrMap", &ExposureInfo::setApCorrMap,
"apCorrMap"_a);
189 cls.def(
"initApCorrMap", &ExposureInfo::initApCorrMap);
191 cls.attr(
"KEY_COADD_INPUTS") = ExposureInfo::KEY_COADD_INPUTS.getId();
192 cls.def(
"hasCoaddInputs", &ExposureInfo::hasCoaddInputs);
193 cls.def(
"getCoaddInputs", &ExposureInfo::getCoaddInputs);
194 cls.def(
"setCoaddInputs", &ExposureInfo::setCoaddInputs,
"coaddInputs"_a);
196 cls.def(
"hasVisitInfo", &ExposureInfo::hasVisitInfo);
197 cls.def(
"getVisitInfo", &ExposureInfo::getVisitInfo);
198 cls.def(
"setVisitInfo", &ExposureInfo::setVisitInfo,
"visitInfo"_a);
200 cls.attr(
"KEY_TRANSMISSION_CURVE") = ExposureInfo::KEY_TRANSMISSION_CURVE.getId();
201 cls.def(
"hasTransmissionCurve", &ExposureInfo::hasTransmissionCurve);
202 cls.def(
"getTransmissionCurve", &ExposureInfo::getTransmissionCurve);
203 cls.def(
"setTransmissionCurve", &ExposureInfo::setTransmissionCurve,
"transmissionCurve"_a);
218 wrapExposureInfo(wrappers);
Implementation of the Photometric Calibration class.
A helper class for subdividing pybind11 module across multiple translation units (i....
pybind11::module module
The module object passed to the PYBIND11_MODULE block that contains this WrapperCollection.
void finish()
Invoke all deferred wrapper-declaring callables.
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...
void addSignatureDependency(std::string const &name)
Indicate an external module that provides a type used in function/method signatures.
PYBIND11_MODULE(imageUtils, mod)
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
constexpr Key< K, V > makeKey(K const &id)
Factory function for Key, to enable type parameter inference.
A base class for image defects.