23 #include "pybind11/pybind11.h" 45 namespace py = pybind11;
54 using PyExposureRecord = py::class_<ExposureRecord, std::shared_ptr<ExposureRecord>, BaseRecord>;
55 using PyExposureTable = py::class_<ExposureTable, std::shared_ptr<ExposureTable>, BaseTable>;
56 using PyExposureCatalog =
57 py::class_<ExposureCatalogT<ExposureRecord>, std::shared_ptr<ExposureCatalogT<ExposureRecord>>,
58 SortedCatalogT<ExposureRecord>>;
60 PyExposureRecord declareExposureRecord(py::module &mod) {
61 PyExposureRecord
cls(mod,
"ExposureRecord");
62 cls.def(
"getId", &ExposureRecord::getId);
63 cls.def(
"setId", &ExposureRecord::setId,
"id"_a);
64 cls.def(
"getBBox", &ExposureRecord::getBBox);
65 cls.def(
"setBBox", &ExposureRecord::setBBox,
"bbox"_a);
66 cls.def(
"getTable", &ExposureRecord::getTable);
67 cls.def_property_readonly(
"table", &ExposureRecord::getTable);
69 (
bool (ExposureRecord::*)(
coord::Coord const &,
bool)
const) & ExposureRecord::contains,
70 "coord"_a,
"includeValidPolygon"_a =
false);
72 ExposureRecord::contains,
73 "point"_a,
"wcs"_a,
"includeValidPolygon"_a =
false);
74 cls.def(
"getWcs", &ExposureRecord::getWcs);
75 cls.def(
"setWcs", &ExposureRecord::setWcs,
"wcs"_a);
76 cls.def(
"getPsf", &ExposureRecord::getPsf);
77 cls.def(
"setPsf", &ExposureRecord::setPsf,
"psf"_a);
78 cls.def(
"getCalib", &ExposureRecord::getCalib);
79 cls.def(
"setCalib", &ExposureRecord::setCalib,
"calib"_a);
80 cls.def(
"getApCorrMap", &ExposureRecord::getApCorrMap);
81 cls.def(
"setApCorrMap", &ExposureRecord::setApCorrMap,
"appCorrMap"_a);
82 cls.def(
"getValidPolygon", &ExposureRecord::getValidPolygon);
85 cls.def(
"setValidPolygon",
86 [](ExposureRecord &
self, py::object polygon) {
87 if (polygon == py::none()) {
88 self.setValidPolygon(
nullptr);
90 self.setValidPolygon(py::cast<std::shared_ptr<afw::geom::polygon::Polygon>>(polygon));
95 cls.def(
"getVisitInfo", &ExposureRecord::getVisitInfo);
96 cls.def(
"setVisitInfo", &ExposureRecord::setVisitInfo,
"visitInfo"_a);
100 PyExposureTable declareExposureTable(py::module &mod) {
101 PyExposureTable
cls(mod,
"ExposureTable");
102 cls.def_static(
"make", &ExposureTable::make);
103 cls.def_static(
"makeMinimalSchema", &ExposureTable::makeMinimalSchema);
104 cls.def_static(
"checkSchema", &ExposureTable::checkSchema,
"schema"_a);
106 cls.def_static(
"getIdKey", &ExposureTable::getIdKey);
107 cls.def_static(
"getBBoxMinKey", &ExposureTable::getBBoxMinKey);
108 cls.def_static(
"getBBoxMaxKey", &ExposureTable::getBBoxMaxKey);
111 cls.def(
"makeRecord", &ExposureTable::makeRecord);
112 cls.def(
"copyRecord", (std::shared_ptr<ExposureRecord> (ExposureTable::*)(BaseRecord
const &)) &
113 ExposureTable::copyRecord);
114 cls.def(
"copyRecord",
115 (std::shared_ptr<ExposureRecord> (ExposureTable::*)(BaseRecord
const &, SchemaMapper
const &)) &
116 ExposureTable::copyRecord);
120 PyExposureCatalog declareExposureCatalog(py::module &mod) {
121 using Catalog = ExposureCatalogT<ExposureRecord>;
122 table::python::declareSortedCatalog<ExposureRecord>(mod,
"Exposure",
true);
125 PyExposureCatalog
cls(mod,
"ExposureCatalog", py::dynamic_attr());
127 cls.def(py::init<Schema const &>(),
"schema"_a);
128 cls.def(py::init<std::shared_ptr<ExposureTable>
const &>(),
"table"_a = std::shared_ptr<ExposureTable>());
129 cls.def(py::init<Catalog const &>(),
"other"_a);
131 cls.def_static(
"readFits", (Catalog(*)(std::string
const &,
int,
int)) & Catalog::readFits,
"filename"_a,
132 "hdu"_a = INT_MIN,
"flags"_a = 0);
133 cls.def_static(
"readFits", (Catalog(*)(fits::MemFileManager &,
int,
int)) & Catalog::readFits,
134 "manager"_a,
"hdu"_a = INT_MIN,
"flags"_a = 0);
137 cls.def(
"subset", (Catalog (Catalog::*)(ndarray::Array<bool const, 1>
const &)
const) & Catalog::subset,
140 (Catalog (Catalog::*)(std::ptrdiff_t, std::ptrdiff_t, std::ptrdiff_t)
const) & Catalog::subset,
141 "startd"_a,
"stopd"_a,
"step"_a);
142 cls.def(
"subsetContaining",
143 (Catalog (Catalog::*)(
coord::Coord const &,
bool)
const) & Catalog::subsetContaining,
"coord"_a,
144 "includeValidPolygon"_a =
false);
145 cls.def(
"subsetContaining",
147 Catalog::subsetContaining,
148 "point"_a,
"wcs"_a,
"includeValidPolygon"_a =
false);
155 py::module mod(
"exposure");
156 py::module::import(
"lsst.afw.table.simple");
157 py::module::import(
"lsst.afw.geom");
160 auto clsExposureRecord = declareExposureRecord(mod);
161 auto clsExposureTable = declareExposureTable(mod);
162 auto clsExposureColumnView = table::python::declareColumnView<ExposureRecord>(mod,
"Exposure");
163 auto clsExposureCatalog = declareExposureCatalog(mod);
165 clsExposureRecord.attr(
"Table") = clsExposureTable;
166 clsExposureRecord.attr(
"ColumnView") = clsExposureColumnView;
167 clsExposureRecord.attr(
"Catalog") = clsExposureCatalog;
168 clsExposureTable.attr(
"Record") = clsExposureRecord;
169 clsExposureTable.attr(
"ColumnView") = clsExposureColumnView;
170 clsExposureTable.attr(
"Catalog") = clsExposureCatalog;
171 clsExposureCatalog.attr(
"Record") = clsExposureRecord;
172 clsExposureCatalog.attr(
"Table") = clsExposureTable;
173 clsExposureCatalog.attr(
"ColumnView") = clsExposureColumnView;
lsst::afw::coord::Coord Coord
Implementation of the WCS standard for a any projection.
A base class for image defects.
Point< double, 2 > Point2D
PYBIND11_PLUGIN(exposure)