Loading [MathJax]/extensions/tex2jax.js
LSST Applications 28.0.0,g1653933729+a8ce1bb630,g1a997c3884+a8ce1bb630,g28da252d5a+5bd70b7e6d,g2bbee38e9b+638fca75ac,g2bc492864f+638fca75ac,g3156d2b45e+07302053f8,g347aa1857d+638fca75ac,g35bb328faa+a8ce1bb630,g3a166c0a6a+638fca75ac,g3e281a1b8c+7bbb0b2507,g4005a62e65+17cd334064,g414038480c+5b5cd4fff3,g41af890bb2+4ffae9de63,g4e1a3235cc+0f1912dca3,g6249c6f860+3c3976f90c,g80478fca09+46aba80bd6,g82479be7b0+77990446f6,g858d7b2824+78ba4d1ce1,g89c8672015+f667a5183b,g9125e01d80+a8ce1bb630,ga5288a1d22+2a6264e9ca,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc22bb204ba+78ba4d1ce1,gc28159a63d+638fca75ac,gcf0d15dbbd+32ddb6096f,gd6b7c0dfd1+3e339405e9,gda3e153d99+78ba4d1ce1,gda6a2b7d83+32ddb6096f,gdaeeff99f8+1711a396fd,gdd5a9049c5+b18c39e5e3,ge2409df99d+a5e4577cdc,ge33fd446bb+78ba4d1ce1,ge79ae78c31+638fca75ac,gf0baf85859+64e8883e75,gf5289d68f6+e1b046a8d7,gfa443fc69c+91d9ed1ecf,gfda6b12a05+8419469a56
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
_exposure.cc
Go to the documentation of this file.
1/*
2 * This file is part of afw.
3 *
4 * Developed for the LSST Data Management System.
5 * This product includes software developed by the LSST Project
6 * (https://www.lsst.org).
7 * See the COPYRIGHT file at the top-level directory of this distribution
8 * for details of code ownership.
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
24#include "pybind11/pybind11.h"
25#include "ndarray/pybind11.h"
26
27#include <memory>
28
30
31#include "lsst/afw/detection/Psf.h" // forward-declared by Exposure.h
32#include "lsst/afw/fits.h"
33#include "lsst/geom/Box.h"
34#include "lsst/geom/Point.h"
35#include "lsst/afw/geom/polygon/Polygon.h" // forward-declared by Exposure.h
36#include "lsst/afw/geom/SkyWcs.h" // forward-declared by Transform.h
37#include "lsst/afw/image/ApCorrMap.h" // forward-declared by Exposure.h
38#include "lsst/afw/image/PhotoCalib.h" // forward-declared by Exposure.h
39#include "lsst/afw/image/VisitInfo.h" // forward-declared by Exposure.h
40#include "lsst/afw/image/TransmissionCurve.h" // forward-declared by Exposure.h
41#include "lsst/afw/cameraGeom/Detector.h" // forward-declared by Exposure.h
49
50namespace py = pybind11;
51using namespace pybind11::literals;
52
53namespace lsst {
54namespace afw {
55namespace table {
56
57using cpputils::python::WrapperCollection;
58
59namespace {
60
61using PyExposureRecord = py::class_<ExposureRecord, std::shared_ptr<ExposureRecord>, BaseRecord>;
62using PyExposureTable = py::class_<ExposureTable, std::shared_ptr<ExposureTable>, BaseTable>;
63using PyExposureCatalog =
64 py::class_<ExposureCatalogT<ExposureRecord>, std::shared_ptr<ExposureCatalogT<ExposureRecord>>,
65 SortedCatalogT<ExposureRecord>>;
66
67PyExposureRecord declareExposureRecord(WrapperCollection &wrappers) {
68 return wrappers.wrapType(PyExposureRecord(wrappers.module, "ExposureRecord"), [](auto &mod, auto &cls) {
69 cls.def("getId", &ExposureRecord::getId);
70 cls.def("setId", &ExposureRecord::setId, "id"_a);
71 cls.def_property("id", &ExposureRecord::getId, &ExposureRecord::setId);
72 cls.def("getBBox", &ExposureRecord::getBBox);
73 cls.def("setBBox", &ExposureRecord::setBBox, "bbox"_a);
74 // No property for bbox, as it returns by value.
75 cls.def("getTable", &ExposureRecord::getTable);
76 // table has no setter
77 cls.def_property_readonly("table", &ExposureRecord::getTable);
78 cls.def("contains",
79 (bool(ExposureRecord::*)(lsst::geom::SpherePoint const &, bool) const) &
80 ExposureRecord::contains,
81 "coord"_a, "includeValidPolygon"_a = false);
82 cls.def("contains",
83 (bool(ExposureRecord::*)(lsst::geom::Point2D const &, geom::SkyWcs const &, bool) const) &
84 ExposureRecord::contains,
85 "point"_a, "wcs"_a, "includeValidPolygon"_a = false);
86 cls.def("getWcs", &ExposureRecord::getWcs);
87 cls.def("setWcs", &ExposureRecord::setWcs, "wcs"_a);
88 cls.def_property("wcs", &ExposureRecord::getWcs, &ExposureRecord::setWcs);
89 cls.def("getPsf", &ExposureRecord::getPsf);
90 cls.def("setPsf", &ExposureRecord::setPsf, "psf"_a);
91 cls.def_property("psf", &ExposureRecord::getPsf, &ExposureRecord::setPsf);
92
93 cls.def("getPhotoCalib", &ExposureRecord::getPhotoCalib);
94 cls.def("setPhotoCalib", &ExposureRecord::setPhotoCalib, "photoCalib"_a);
95 cls.def_property("photoCalib", &ExposureRecord::getPhotoCalib, &ExposureRecord::setPhotoCalib);
96 cls.def("getApCorrMap", &ExposureRecord::getApCorrMap);
97 cls.def("setApCorrMap", &ExposureRecord::setApCorrMap, "apCorrMap"_a);
98 cls.def_property("apCorrMap", &ExposureRecord::getApCorrMap, &ExposureRecord::setApCorrMap);
99 cls.def("getValidPolygon", &ExposureRecord::getValidPolygon);
100 cls.def("setValidPolygon", &ExposureRecord::setValidPolygon);
101 cls.def_property("validPolygon", &ExposureRecord::getValidPolygon, &ExposureRecord::setValidPolygon);
102 cls.def("getVisitInfo", &ExposureRecord::getVisitInfo);
103 cls.def("setVisitInfo", &ExposureRecord::setVisitInfo, "visitInfo"_a);
104 cls.def_property("visitInfo", &ExposureRecord::getVisitInfo, &ExposureRecord::setVisitInfo);
105 cls.def("getTransmissionCurve", &ExposureRecord::getTransmissionCurve);
106 cls.def("setTransmissionCurve", &ExposureRecord::setTransmissionCurve, "transmissionCurve"_a);
107 cls.def_property("transmissionCurve", &ExposureRecord::getTransmissionCurve,
108 &ExposureRecord::setTransmissionCurve);
109 cls.def("getDetector", &ExposureRecord::getDetector);
110 cls.def("setDetector", &ExposureRecord::setDetector, "detector"_a);
111 cls.def_property("detector", &ExposureRecord::getDetector, &ExposureRecord::setDetector);
112 });
113}
114
115PyExposureTable declareExposureTable(WrapperCollection &wrappers) {
116 return wrappers.wrapType(PyExposureTable(wrappers.module, "ExposureTable"), [](auto &mod, auto &cls) {
117 cls.def_static("make", &ExposureTable::make);
118 cls.def_static("makeMinimalSchema", &ExposureTable::makeMinimalSchema);
119 cls.def_static("checkSchema", &ExposureTable::checkSchema, "schema"_a);
120
121 cls.def_static("getIdKey", &ExposureTable::getIdKey);
122 cls.def_static("getBBoxMinKey", &ExposureTable::getBBoxMinKey);
123 cls.def_static("getBBoxMaxKey", &ExposureTable::getBBoxMaxKey);
124
125 cls.def("clone", &ExposureTable::clone);
126 cls.def("makeRecord", &ExposureTable::makeRecord);
127 cls.def("copyRecord", (std::shared_ptr<ExposureRecord>(ExposureTable::*)(BaseRecord const &)) &
128 ExposureTable::copyRecord);
129 cls.def("copyRecord", (std::shared_ptr<ExposureRecord>(ExposureTable::*)(BaseRecord const &,
130 SchemaMapper const &)) &
131 ExposureTable::copyRecord);
132 });
133}
134
135PyExposureCatalog declareExposureCatalog(WrapperCollection &wrappers) {
136 using Catalog = ExposureCatalogT<ExposureRecord>;
137 table::python::declareSortedCatalog<ExposureRecord>(wrappers, "Exposure", true);
138
139 // We need py::dynamic_attr() in class definition to support our Python-side caching
140 // of the associated ColumnView.
141 return wrappers.wrapType(
142 PyExposureCatalog(wrappers.module, "ExposureCatalog", py::dynamic_attr()),
143 [](auto &mod, auto &cls) {
144 cls.def(py::init<Schema const &>(), "schema"_a);
145 cls.def(py::init<std::shared_ptr<ExposureTable> const &>(),
146 "table"_a = std::shared_ptr<ExposureTable>());
147 cls.def(py::init<Catalog const &>(), "other"_a);
148 // Constructor taking C++ iterators not wrapped; we recommend .extend() (defined in pure
149 // Python) instead.
150 cls.def_static("readFits", (Catalog(*)(std::string const &, int, int)) & Catalog::readFits,
151 "filename"_a, "hdu"_a = fits::DEFAULT_HDU, "flags"_a = 0);
152 cls.def_static("readFits", (Catalog(*)(fits::MemFileManager &, int, int)) & Catalog::readFits,
153 "manager"_a, "hdu"_a = fits::DEFAULT_HDU, "flags"_a = 0);
154 // readFits taking Fits objects not wrapped, because Fits objects are not wrapped.
155
156 cls.def("subset",
157 (Catalog(Catalog::*)(ndarray::Array<bool const, 1> const &) const) & Catalog::subset,
158 "mask"_a);
159 cls.def("subset",
160 (Catalog(Catalog::*)(std::ptrdiff_t, std::ptrdiff_t, std::ptrdiff_t) const) &
161 Catalog::subset,
162 "startd"_a, "stopd"_a, "step"_a);
163 cls.def("subsetContaining",
164 (Catalog(Catalog::*)(lsst::geom::SpherePoint const &, bool) const) &
165 Catalog::subsetContaining,
166 "coord"_a, "includeValidPolygon"_a = false);
167 cls.def("subsetContaining",
168 (Catalog(Catalog::*)(lsst::geom::Point2D const &, geom::SkyWcs const &, bool) const) &
169 Catalog::subsetContaining,
170 "point"_a, "wcs"_a, "includeValidPolygon"_a = false);
171 });
172};
173
174} // anonymous namespace
175
177 // wrappers.addSignatureDependency("lsst.afw.geom");
178 // TODO: afw.geom, afw.image, and afw.detection cannot be imported due to
179 // circular dependencies until at least afw.image uses WrapperCollection
180 // in DM-20703
181
182 auto clsExposureRecord = declareExposureRecord(wrappers);
183 auto clsExposureTable = declareExposureTable(wrappers);
184 auto clsExposureColumnView = table::python::declareColumnView<ExposureRecord>(wrappers, "Exposure");
185 auto clsExposureCatalog = declareExposureCatalog(wrappers);
186
187 clsExposureRecord.attr("Table") = clsExposureTable;
188 clsExposureRecord.attr("ColumnView") = clsExposureColumnView;
189 clsExposureRecord.attr("Catalog") = clsExposureCatalog;
190 clsExposureTable.attr("Record") = clsExposureRecord;
191 clsExposureTable.attr("ColumnView") = clsExposureColumnView;
192 clsExposureTable.attr("Catalog") = clsExposureCatalog;
193 clsExposureCatalog.attr("Record") = clsExposureRecord;
194 clsExposureCatalog.attr("Table") = clsExposureTable;
195 clsExposureCatalog.attr("ColumnView") = clsExposureColumnView;
196}
197
198} // namespace table
199} // namespace afw
200} // namespace lsst
Implementation of the Photometric Calibration class.
A helper class for subdividing pybind11 module across multiple translation units (i....
Definition python.h:242
PySortedCatalog< Record > declareSortedCatalog(cpputils::python::WrapperCollection &wrappers, std::string const &name, bool isBase=false)
Wrap an instantiation of lsst::afw::table::SortedCatalogT<Record>.
PyColumnView< Record > declareColumnView(cpputils::python::WrapperCollection &wrappers, std::string const &name, bool isBase=false)
Declare member and static functions for a given instantiation of lsst::afw::table::ColumnViewT<Record...
Definition columnView.h:53
void wrapExposure(WrapperCollection &wrappers)
Definition _exposure.cc:176