24#include "pybind11/pybind11.h"
42using namespace py::literals;
49using PyExposureInfo = py::class_<ExposureInfo, std::shared_ptr<ExposureInfo>>;
53void declareGenericMethods(PyExposureInfo &cls) {
58 self.setComponent(typehandling::makeKey<T>(key),
object);
63void declareGenericMethodsMerged(PyExposureInfo &cls) {
64 using typehandling::Storable;
74 [](Class
const &
self,
std::string const &key) -> py::object {
75 auto sharedKey = typehandling::makeKey<std::shared_ptr<Storable const>>(key);
77 if (
self.hasComponent(sharedKey)) {
78 return py::cast(
self.getComponent(sharedKey));
92void declareExposureInfo(lsst::utils::python::WrapperCollection &wrappers) {
93 wrappers.wrapType(PyExposureInfo(wrappers.module,
"ExposureInfo"), [](
auto &mod,
auto &cls) {
95 cls.def(py::init<std::shared_ptr<geom::SkyWcs const> const &,
96 std::shared_ptr<detection::Psf const> const &,
97 std::shared_ptr<PhotoCalib const> const &,
98 std::shared_ptr<cameraGeom::Detector const> const &,
99 std::shared_ptr<geom::polygon::Polygon const> const &,
100 std::shared_ptr<daf::base::PropertySet> const &,
101 std::shared_ptr<CoaddInputs> const &, std::shared_ptr<ApCorrMap> const &,
102 std::shared_ptr<VisitInfo const> const &,
103 std::shared_ptr<TransmissionCurve const> const &>(),
104 "wcs"_a = std::shared_ptr<geom::SkyWcs const>(),
105 "psf"_a = std::shared_ptr<detection::Psf const>(),
106 "photoCalib"_a = std::shared_ptr<PhotoCalib const>(),
107 "detector"_a = std::shared_ptr<cameraGeom::Detector const>(),
108 "polygon"_a = std::shared_ptr<geom::polygon::Polygon const>(),
109 "metadata"_a = std::shared_ptr<daf::base::PropertySet>(),
110 "coaddInputs"_a = std::shared_ptr<CoaddInputs>(),
111 "apCorrMap"_a = std::shared_ptr<ApCorrMap>(),
112 "visitInfo"_a = std::shared_ptr<VisitInfo const>(),
"transmissionCurve"_a = nullptr);
113 cls.def(py::init<>());
114 cls.def(py::init<ExposureInfo>(),
"other"_a);
115 cls.def(py::init<ExposureInfo, bool>(),
"other"_a,
"copyMetadata"_a);
118 cls.attr(
"KEY_WCS") = ExposureInfo::KEY_WCS.getId();
119 cls.def(
"hasWcs", &ExposureInfo::hasWcs);
120 cls.def(
"getWcs", (std::shared_ptr<geom::SkyWcs>(ExposureInfo::*)()) & ExposureInfo::getWcs);
121 cls.def(
"setWcs", &ExposureInfo::setWcs,
"wcs"_a);
123 cls.attr(
"KEY_DETECTOR") = ExposureInfo::KEY_DETECTOR.getId();
124 cls.def(
"hasDetector", &ExposureInfo::hasDetector);
125 cls.def(
"getDetector", &ExposureInfo::getDetector);
128 [](ExposureInfo &self, py::object detector) {
129 if (detector.is(py::none())) {
130 self.setDetector(nullptr);
132 self.setDetector(py::cast<std::shared_ptr<afw::cameraGeom::Detector>>(detector));
145 declareGenericMethods<std::shared_ptr<typehandling::Storable const>>(cls);
146 declareGenericMethodsMerged(cls);
156 auto getId = [](ExposureInfo
const &
self) -> py::object {
158 return py::cast(
self.getId());
159 }
catch (pex::exceptions::NotFoundError
const &) {
163 auto setId = [](ExposureInfo &
self, py::object
id) {
167 self.setId(
id.cast<table::RecordId>());
170 cls.def(
"getId", getId);
171 cls.def(
"setId", setId,
"id"_a);
173 cls.def_property(
"id", getId, setId);
183 [](ExposureInfo &
self, py::object
psf) {
184 if (
psf.is(py::none())) {
185 self.setPsf(
nullptr);
197 [](ExposureInfo &
self, py::object polygon) {
198 if (polygon.is(py::none())) {
199 self.setValidPolygon(
nullptr);
229 wrappers.addSignatureDependency(
"lsst.daf.base");
230 wrappers.addSignatureDependency(
"lsst.afw.geom");
231 wrappers.addSignatureDependency(
"lsst.afw.cameraGeom");
232 wrappers.addSignatureDependency(
"lsst.afw.detection");
233 declareExposureInfo(wrappers);
Implementation of the Photometric Calibration class.
bool hasCoaddInputs() const
Does this exposure have coadd provenance catalogs?
void setFilterLabel(std::shared_ptr< FilterLabel const > filterLabel)
Set the exposure's filter information.
bool hasTransmissionCurve() const
Does this exposure have a transmission curve?
bool hasPsf() const
Does this exposure have a Psf?
void setVisitInfo(std::shared_ptr< image::VisitInfo const > const visitInfo)
Set the exposure's visit info.
bool hasPhotoCalib() const
Does this exposure have a photometric calibration?
bool hasApCorrMap() const
Return true if the exposure has an aperture correction map.
std::shared_ptr< PhotoCalib const > getPhotoCalib() const
Return the exposure's photometric calibration.
std::shared_ptr< ApCorrMap const > getApCorrMap() const
Return the exposure's aperture correction map (null pointer if !hasApCorrMap())
std::shared_ptr< FilterLabel const > getFilterLabel() const
Return the exposure's filter information.
void setApCorrMap(std::shared_ptr< ApCorrMap const > apCorrMap)
Set the exposure's aperture correction map (null pointer if !hasApCorrMap())
void setPhotoCalib(std::shared_ptr< PhotoCalib const > photoCalib)
Set the Exposure's PhotoCalib object.
static typehandling::Key< std::string, std::shared_ptr< geom::polygon::Polygon const > > const KEY_VALID_POLYGON
Standard key for looking up the valid polygon.
bool hasValidPolygon() const
Does this exposure have a valid Polygon.
std::shared_ptr< FilterLabel const > getFilter() const
Return the exposure's filter information.
static typehandling::Key< std::string, std::shared_ptr< PhotoCalib const > > const KEY_PHOTO_CALIB
Standard key for looking up the photometric calibration.
void setCoaddInputs(std::shared_ptr< CoaddInputs const > coaddInputs)
Set the exposure's coadd provenance catalogs.
bool hasFilterLabel() const
Does this exposure have filter information?
void clearId() noexcept
Unset the exposure ID, if any.
void setMetadata(std::shared_ptr< daf::base::PropertySet > metadata)
Set the flexible metadata.
void setFilter(std::shared_ptr< FilterLabel const > filter)
Set the exposure's filter information.
bool hasVisitInfo() const
Does this exposure have visit info?
static typehandling::Key< std::string, std::shared_ptr< TransmissionCurve const > > const KEY_TRANSMISSION_CURVE
Standard key for looking up the transmission curve.
void initApCorrMap()
Set the exposure's aperture correction map to a new, empty map.
static typehandling::Key< std::string, std::shared_ptr< CoaddInputs const > > const KEY_COADD_INPUTS
Standard key for looking up coadd provenance catalogs.
static typehandling::Key< std::string, std::shared_ptr< detection::Psf const > > const KEY_PSF
Standard key for looking up the point-spread function.
std::shared_ptr< CoaddInputs const > getCoaddInputs() const
Return a pair of catalogs that record the inputs, if this Exposure is a coadd (otherwise null).
bool hasFilter() const
Does this exposure have filter information?
std::shared_ptr< geom::polygon::Polygon const > getValidPolygon() const
Return the valid Polygon.
std::shared_ptr< daf::base::PropertySet > getMetadata() const
Return flexible metadata.
static typehandling::Key< std::string, std::shared_ptr< ApCorrMap const > > const KEY_AP_CORR_MAP
Standard key for looking up the aperture correction map.
std::shared_ptr< image::VisitInfo const > getVisitInfo() const
Return the exposure's visit info.
static typehandling::Key< std::string, std::shared_ptr< FilterLabel const > > const KEY_FILTER
Standard key for looking up filter information.
bool hasId() const noexcept
Does this Exposure have an exposure id?
void setTransmissionCurve(std::shared_ptr< TransmissionCurve const > tc)
Set the exposure's transmission curve.
std::shared_ptr< detection::Psf const > getPsf() const
Return the exposure's point-spread function.
std::shared_ptr< TransmissionCurve const > getTransmissionCurve() const
Return the exposure's transmission curve.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
void wrapExposureInfo(lsst::utils::python::WrapperCollection &wrappers)
constexpr Key< K, V > makeKey(K const &id)
Factory function for Key, to enable type parameter inference.
A base class for image defects.