LSSTApplications  21.0.0+75b29a8a7f,21.0.0+e70536a077,21.0.0-1-ga51b5d4+62c747d40b,21.0.0-11-ga6ea59e8e+47cba9fc36,21.0.0-2-g103fe59+914993bf7c,21.0.0-2-g1367e85+e2614ded12,21.0.0-2-g45278ab+e70536a077,21.0.0-2-g4bc9b9f+7b2b5f8678,21.0.0-2-g5242d73+e2614ded12,21.0.0-2-g54e2caa+6403186824,21.0.0-2-g7f82c8f+3ac4acbffc,21.0.0-2-g8dde007+04a6aea1af,21.0.0-2-g8f08a60+9402881886,21.0.0-2-ga326454+3ac4acbffc,21.0.0-2-ga63a54e+81dd751046,21.0.0-2-gc738bc1+5f65c6e7a9,21.0.0-2-gde069b7+26c92b3210,21.0.0-2-gecfae73+0993ddc9bd,21.0.0-2-gfc62afb+e2614ded12,21.0.0-21-gba890a8+5a4f502a26,21.0.0-23-g9966ff26+03098d1af8,21.0.0-3-g357aad2+8ad216c477,21.0.0-3-g4be5c26+e2614ded12,21.0.0-3-g6d51c4a+4d2fe0280d,21.0.0-3-g7d9da8d+75b29a8a7f,21.0.0-3-gaa929c8+522e0f12c2,21.0.0-3-ge02ed75+4d2fe0280d,21.0.0-4-g3300ddd+e70536a077,21.0.0-4-gc004bbf+eac6615e82,21.0.0-4-gccdca77+f94adcd104,21.0.0-4-gd1c1571+18b81799f9,21.0.0-5-g7b47fff+4d2fe0280d,21.0.0-5-gb155db7+d2632f662b,21.0.0-5-gdf36809+637e4641ee,21.0.0-6-g722ad07+28c848f42a,21.0.0-7-g959bb79+522e0f12c2,21.0.0-7-gfd72ab2+cf01990774,21.0.0-9-g87fb7b8d+e2ab11cdd6,w.2021.04
LSSTDataManagementBasePackage
exposureInfo.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008-2017 AURA/LSST.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <https://www.lsstcorp.org/LegalNotices/>.
21  */
22 
23 #include "pybind11/pybind11.h"
24 
27 #include "lsst/afw/detection/Psf.h"
29 #include "lsst/afw/geom/SkyWcs.h"
33 #include "lsst/afw/image/Filter.h"
39 
40 namespace py = pybind11;
41 using namespace py::literals;
42 
43 namespace lsst {
44 namespace afw {
45 namespace image {
46 namespace {
47 
48 using PyExposureInfo = py::class_<ExposureInfo, std::shared_ptr<ExposureInfo>>;
49 
50 // Template methods where we can use pybind11's overload resolution (T is input)
51 template <class T>
52 void declareGenericMethods(PyExposureInfo &cls) {
53  using Class = PyExposureInfo::type;
54  cls.def("setComponent",
55  [](PyExposureInfo::type &self, std::string const &key, T const &object) {
56  self.setComponent(typehandling::makeKey<T>(key), object);
57  },
58  "key"_a, "object"_a);
59 }
60 // Template methods where we need to provide a unified interface (T is not input)
61 void declareGenericMethodsMerged(PyExposureInfo &cls) {
62  using typehandling::Storable;
63  using Class = PyExposureInfo::type;
64  cls.def("hasComponent",
65  [](Class const &self, std::string const &key) {
66  return self.hasComponent(typehandling::makeKey<std::shared_ptr<Storable const>>(key));
67  },
68  "key"_a);
69  cls.def("getComponent",
70  [](Class const &self, std::string const &key) -> py::object {
71  auto sharedKey = typehandling::makeKey<std::shared_ptr<Storable const>>(key);
72  // Cascading if-elses to support other types in the future
73  if (self.hasComponent(sharedKey)) {
74  return py::cast(self.getComponent(sharedKey));
75  } else {
76  return py::none();
77  }
78  },
79  "key"_a);
80  cls.def("removeComponent",
81  [](Class &self, std::string const &key) {
83  },
84  "key"_a);
85 }
86 
87 PYBIND11_MODULE(exposureInfo, mod) {
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"); // For Psf
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");
98 
99  /* Module level */
100  PyExposureInfo cls(mod, "ExposureInfo");
101 
102  /* Member types and enums */
103 
104  /* Constructors */
108  std::shared_ptr<geom::polygon::Polygon const> const &, Filter const &,
114  "photoCalib"_a = std::shared_ptr<PhotoCalib const>(),
116  "polygon"_a = std::shared_ptr<geom::polygon::Polygon const>(), "filter"_a = Filter(),
118  "coaddInputs"_a = std::shared_ptr<CoaddInputs>(), "apCorrMap"_a = std::shared_ptr<ApCorrMap>(),
119  "visitInfo"_a = std::shared_ptr<VisitInfo const>(), "transmissionCurve"_a = nullptr);
120  cls.def(py::init<>());
121  cls.def(py::init<ExposureInfo>(), "other"_a);
122  cls.def(py::init<ExposureInfo, bool>(), "other"_a, "copyMetadata"_a);
123 
124  /* Members */
125  cls.attr("KEY_WCS") = ExposureInfo::KEY_WCS.getId();
126  cls.def("hasWcs", &ExposureInfo::hasWcs);
127  cls.def("getWcs", (std::shared_ptr<geom::SkyWcs>(ExposureInfo::*)()) & ExposureInfo::getWcs);
128  cls.def("setWcs", &ExposureInfo::setWcs, "wcs"_a);
129 
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) {
135  if (detector.is(py::none())) {
136  self.setDetector(nullptr);
137  } else {
138  self.setDetector(py::cast<std::shared_ptr<afw::cameraGeom::Detector>>(detector));
139  }
140  },
141  "detector"_a);
142 
143  cls.def("getFilter", &ExposureInfo::getFilter);
144  cls.def("setFilter", &ExposureInfo::setFilter, "filter"_a);
145 
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);
150 
151  declareGenericMethods<std::shared_ptr<typehandling::Storable const>>(cls);
152  declareGenericMethodsMerged(cls);
153 
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);
158 
159  cls.def("getMetadata", &ExposureInfo::getMetadata);
160  cls.def("setMetadata", &ExposureInfo::setMetadata, "metadata"_a);
161 
162  cls.attr("KEY_PSF") = ExposureInfo::KEY_PSF.getId();
163  cls.def("hasPsf", &ExposureInfo::hasPsf);
164  cls.def("getPsf", &ExposureInfo::getPsf);
165  cls.def("setPsf",
166  [](ExposureInfo &self, py::object psf) {
167  if (psf.is(py::none())) {
168  self.setPsf(nullptr);
169  } else {
170  self.setPsf(py::cast<std::shared_ptr<afw::detection::Psf>>(psf));
171  }
172  },
173  "psf"_a);
174 
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);
182  } else {
183  self.setValidPolygon(py::cast<std::shared_ptr<afw::geom::polygon::Polygon>>(polygon));
184  }
185  },
186  "polygon"_a);
187 
188  cls.attr("KEY_AP_CORR_MAP") = ExposureInfo::KEY_AP_CORR_MAP.getId();
189  cls.def("hasApCorrMap", &ExposureInfo::hasApCorrMap);
190  cls.def("getApCorrMap", (std::shared_ptr<ApCorrMap>(ExposureInfo::*)()) & ExposureInfo::getApCorrMap);
191  cls.def("setApCorrMap", &ExposureInfo::setApCorrMap, "apCorrMap"_a);
192  cls.def("initApCorrMap", &ExposureInfo::initApCorrMap);
193 
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);
198 
199  cls.def("hasVisitInfo", &ExposureInfo::hasVisitInfo);
200  cls.def("getVisitInfo", &ExposureInfo::getVisitInfo);
201  cls.def("setVisitInfo", &ExposureInfo::setVisitInfo, "visitInfo"_a);
202 
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);
207 }
208 } // namespace
209 } // namespace image
210 } // namespace afw
211 } // namespace lsst
CoaddInputs.h
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
std::string
STL class.
std::shared_ptr
STL class.
lsst::afw::typehandling::makeKey
constexpr Key< K, V > makeKey(K const &id)
Factory function for Key, to enable type parameter inference.
Definition: Key.h:173
Psf.h
TransmissionCurve.h
psf
Key< int > psf
Definition: Exposure.cc:65
lsst::afw
Definition: imageAlgorithm.dox:1
SkyWcs.h
Filter.h
lsst::afw::geom.transform.transformContinued.cls
cls
Definition: transformContinued.py:33
PropertySet.h
Storable.h
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
Polygon.h
ExposureInfo.h
PhotoCalib.h
Implementation of the Photometric Calibration class.
type
table::Key< int > type
Definition: Detector.cc:163
detector
table::Key< int > detector
Definition: DetectorCollection.cc:172
key
Key< U > key
Definition: Schema.cc:281
ApCorrMap.h
pybind11
Definition: _GenericMap.cc:40
lsst::utils.tests.init
def init()
Definition: tests.py:59
lsst::afw::cameraGeom::PYBIND11_MODULE
PYBIND11_MODULE(camera, mod)
Definition: camera.cc:133
Detector.h
FilterLabel.h
VisitInfo.h