23 #include "pybind11/pybind11.h" 27 #include "numpy/arrayobject.h" 28 #include "ndarray/pybind11.h" 29 #include "ndarray/converter.h" 41 namespace py = pybind11;
49 using PySourceRecord = py::class_<SourceRecord, std::shared_ptr<SourceRecord>, SimpleRecord>;
50 using PySourceTable = py::class_<SourceTable, std::shared_ptr<SourceTable>, SimpleTable>;
51 using PySourceColumnView =
52 py::class_<SourceColumnViewT<SourceRecord>, std::shared_ptr<SourceColumnViewT<SourceRecord>>,
53 ColumnViewT<SourceRecord>>;
58 PySourceRecord declareSourceRecord(py::module &mod) {
59 PySourceRecord
cls(mod,
"SourceRecord");
60 cls.def(
"getFootprint", &SourceRecord::getFootprint);
61 cls.def(
"setFootprint", &SourceRecord::setFootprint);
62 cls.def(
"getTable", &SourceRecord::getTable);
63 cls.def_property_readonly(
"table", &SourceRecord::getTable);
65 cls.def(
"getParent", &SourceRecord::getParent);
66 cls.def(
"setParent", &SourceRecord::setParent,
"id"_a);
68 cls.def(
"getPsfFlux", &SourceRecord::getPsfFlux);
69 cls.def(
"getPsfFluxErr", &SourceRecord::getPsfFluxErr);
70 cls.def(
"getPsfFluxFlag", &SourceRecord::getPsfFluxFlag);
72 cls.def(
"getModelFlux", &SourceRecord::getModelFlux);
73 cls.def(
"getModelFluxErr", &SourceRecord::getModelFluxErr);
74 cls.def(
"getModelFluxFlag", &SourceRecord::getModelFluxFlag);
76 cls.def(
"getApFlux", &SourceRecord::getApFlux);
77 cls.def(
"getApFluxErr", &SourceRecord::getApFluxErr);
78 cls.def(
"getApFluxFlag", &SourceRecord::getApFluxFlag);
80 cls.def(
"getInstFlux", &SourceRecord::getInstFlux);
81 cls.def(
"getInstFluxErr", &SourceRecord::getInstFluxErr);
82 cls.def(
"getInstFluxFlag", &SourceRecord::getInstFluxFlag);
84 cls.def(
"getCalibFlux", &SourceRecord::getCalibFlux);
85 cls.def(
"getCalibFluxErr", &SourceRecord::getCalibFluxErr);
86 cls.def(
"getCalibFluxFlag", &SourceRecord::getCalibFluxFlag);
88 cls.def(
"getCentroid", &SourceRecord::getCentroid);
89 cls.def(
"getCentroidErr", &SourceRecord::getCentroidErr);
90 cls.def(
"getCentroidFlag", &SourceRecord::getCentroidFlag);
92 cls.def(
"getShape", &SourceRecord::getShape);
93 cls.def(
"getShapeErr", &SourceRecord::getShapeErr);
94 cls.def(
"getShapeFlag", &SourceRecord::getShapeFlag);
96 cls.def(
"getX", &SourceRecord::getX);
97 cls.def(
"getY", &SourceRecord::getY);
98 cls.def(
"getIxx", &SourceRecord::getIxx);
99 cls.def(
"getIyy", &SourceRecord::getIyy);
100 cls.def(
"getIxy", &SourceRecord::getIxy);
101 cls.def(
"updateCoord", (
void (SourceRecord::*)(
image::Wcs const &)) & SourceRecord::updateCoord,
"wcs"_a);
102 cls.def(
"updateCoord", (
void (SourceRecord::*)(
image::Wcs const &, PointKey<double>
const &)) &
103 SourceRecord::updateCoord,
111 PySourceTable declareSourceTable(py::module &mod) {
112 PySourceTable
cls(mod,
"SourceTable");
114 cls.def_static(
"make",
115 (std::shared_ptr<SourceTable>(*)(Schema
const &, std::shared_ptr<IdFactory>
const &)) &
117 cls.def_static(
"make", (std::shared_ptr<SourceTable>(*)(Schema
const &)) & SourceTable::make);
118 cls.def_static(
"makeMinimalSchema", &SourceTable::makeMinimalSchema);
119 cls.def_static(
"getParentKey", &SourceTable::getParentKey);
120 cls.def(
"copyRecord",
121 (std::shared_ptr<SourceRecord> (SourceTable::*)(BaseRecord
const &)) & SourceTable::copyRecord);
122 cls.def(
"copyRecord",
123 (std::shared_ptr<SourceRecord> (SourceTable::*)(BaseRecord
const &, SchemaMapper
const &)) &
124 SourceTable::copyRecord);
125 cls.def(
"makeRecord", &SourceTable::makeRecord);
127 cls.def(
"getPsfFluxSlot", &SourceTable::getPsfFluxSlot);
128 cls.def(
"definePsfFlux", &SourceTable::definePsfFlux,
"name"_a);
129 cls.def(
"getPsfFluxDefinition", &SourceTable::getPsfFluxDefinition);
130 cls.def(
"hasPsfFluxSlot", &SourceTable::hasPsfFluxSlot);
131 cls.def(
"getPsfFluxKey", &SourceTable::getPsfFluxKey);
132 cls.def(
"getPsfFluxErrKey", &SourceTable::getPsfFluxErrKey);
133 cls.def(
"getPsfFluxFlagKey", &SourceTable::getPsfFluxFlagKey);
135 cls.def(
"getModelFluxSlot", &SourceTable::getModelFluxSlot);
136 cls.def(
"defineModelFlux", &SourceTable::defineModelFlux,
"name"_a);
137 cls.def(
"getModelFluxDefinition", &SourceTable::getModelFluxDefinition);
138 cls.def(
"hasModelFluxSlot", &SourceTable::hasModelFluxSlot);
139 cls.def(
"getModelFluxKey", &SourceTable::getModelFluxKey);
140 cls.def(
"getModelFluxErrKey", &SourceTable::getModelFluxErrKey);
141 cls.def(
"getModelFluxFlagKey", &SourceTable::getModelFluxFlagKey);
143 cls.def(
"getApFluxSlot", &SourceTable::getApFluxSlot);
144 cls.def(
"defineApFlux", &SourceTable::defineApFlux,
"name"_a);
145 cls.def(
"getApFluxDefinition", &SourceTable::getApFluxDefinition);
146 cls.def(
"hasApFluxSlot", &SourceTable::hasApFluxSlot);
147 cls.def(
"getApFluxKey", &SourceTable::getApFluxKey);
148 cls.def(
"getApFluxErrKey", &SourceTable::getApFluxErrKey);
149 cls.def(
"getApFluxFlagKey", &SourceTable::getApFluxFlagKey);
151 cls.def(
"getInstFluxSlot", &SourceTable::getInstFluxSlot);
152 cls.def(
"defineInstFlux", &SourceTable::defineInstFlux,
"name"_a);
153 cls.def(
"getInstFluxDefinition", &SourceTable::getInstFluxDefinition);
154 cls.def(
"hasInstFluxSlot", &SourceTable::hasInstFluxSlot);
155 cls.def(
"getInstFluxKey", &SourceTable::getInstFluxKey);
156 cls.def(
"getInstFluxErrKey", &SourceTable::getInstFluxErrKey);
157 cls.def(
"getInstFluxFlagKey", &SourceTable::getInstFluxFlagKey);
159 cls.def(
"getCalibFluxSlot", &SourceTable::getCalibFluxSlot);
160 cls.def(
"defineCalibFlux", &SourceTable::defineCalibFlux,
"name"_a);
161 cls.def(
"getCalibFluxDefinition", &SourceTable::getCalibFluxDefinition);
162 cls.def(
"hasCalibFluxSlot", &SourceTable::hasCalibFluxSlot);
163 cls.def(
"getCalibFluxKey", &SourceTable::getCalibFluxKey);
164 cls.def(
"getCalibFluxErrKey", &SourceTable::getCalibFluxErrKey);
165 cls.def(
"getCalibFluxFlagKey", &SourceTable::getCalibFluxFlagKey);
167 cls.def(
"getCentroidSlot", &SourceTable::getCentroidSlot);
168 cls.def(
"defineCentroid", &SourceTable::defineCentroid,
"name"_a);
169 cls.def(
"getCentroidDefinition", &SourceTable::getCentroidDefinition);
170 cls.def(
"hasCentroidSlot", &SourceTable::hasCentroidSlot);
171 cls.def(
"getCentroidKey", &SourceTable::getCentroidKey);
172 cls.def(
"getCentroidErrKey", &SourceTable::getCentroidErrKey);
173 cls.def(
"getCentroidFlagKey", &SourceTable::getCentroidFlagKey);
175 cls.def(
"getShapeSlot", &SourceTable::getShapeSlot);
176 cls.def(
"defineShape", &SourceTable::defineShape,
"name"_a);
177 cls.def(
"getShapeDefinition", &SourceTable::getShapeDefinition);
178 cls.def(
"hasShapeSlot", &SourceTable::hasShapeSlot);
179 cls.def(
"getShapeKey", &SourceTable::getShapeKey);
180 cls.def(
"getShapeErrKey", &SourceTable::getShapeErrKey);
181 cls.def(
"getShapeFlagKey", &SourceTable::getShapeFlagKey);
186 PySourceColumnView declareSourceColumnView(py::module &mod) {
187 table::python::declareColumnView<SourceRecord>(mod,
"Source",
true);
188 PySourceColumnView
cls(mod,
"SourceColumnView");
190 cls.def(
"getPsfFlux", &SourceColumnView::getPsfFlux);
191 cls.def(
"getPsfFluxErr", &SourceColumnView::getPsfFluxErr);
192 cls.def(
"getApFlux", &SourceColumnView::getApFlux);
193 cls.def(
"getApFluxErr", &SourceColumnView::getApFluxErr);
194 cls.def(
"getModelFlux", &SourceColumnView::getModelFlux);
195 cls.def(
"getModelFluxErr", &SourceColumnView::getModelFluxErr);
196 cls.def(
"getInstFlux", &SourceColumnView::getInstFlux);
197 cls.def(
"getInstFluxErr", &SourceColumnView::getInstFluxErr);
198 cls.def(
"getCalibFlux", &SourceColumnView::getCalibFlux);
199 cls.def(
"getCalibFluxErr", &SourceColumnView::getCalibFluxErr);
200 cls.def(
"getX", &SourceColumnView::getX);
201 cls.def(
"getY", &SourceColumnView::getY);
202 cls.def(
"getIxx", &SourceColumnView::getIxx);
203 cls.def(
"getIyy", &SourceColumnView::getIyy);
204 cls.def(
"getIxy", &SourceColumnView::getIxy);
209 py::module::import(
"lsst.afw.geom.ellipses");
210 py::module::import(
"lsst.afw.table.simple");
211 py::module::import(
"lsst.afw.table.aggregates");
212 py::module::import(
"lsst.afw.table.slots");
214 py::module mod(
"source");
216 if (_import_array() < 0) {
217 PyErr_SetString(PyExc_ImportError,
"numpy.core.multiarray failed to import");
225 mod.attr(
"SOURCE_IO_NO_HEAVY_FOOTPRINTS") =
228 auto clsSourceRecord = declareSourceRecord(mod);
229 auto clsSourceTable = declareSourceTable(mod);
230 auto clsSourceColumnView = declareSourceColumnView(mod);
231 auto clsSourceCatalog = table::python::declareSortedCatalog<SourceRecord>(mod,
"Source");
233 clsSourceRecord.attr(
"Table") = clsSourceTable;
234 clsSourceRecord.attr(
"ColumnView") = clsSourceColumnView;
235 clsSourceRecord.attr(
"Catalog") = clsSourceCatalog;
236 clsSourceTable.attr(
"Record") = clsSourceRecord;
237 clsSourceTable.attr(
"ColumnView") = clsSourceColumnView;
238 clsSourceTable.attr(
"Catalog") = clsSourceCatalog;
239 clsSourceCatalog.attr(
"Record") = clsSourceRecord;
240 clsSourceCatalog.attr(
"Table") = clsSourceTable;
241 clsSourceCatalog.attr(
"ColumnView") = clsSourceColumnView;
Implementation of the WCS standard for a any projection.
PYBIND11_PLUGIN(_cameraPoint)
A base class for image defects.
SourceColumnViewT< SourceRecord > SourceColumnView
Read/write heavy footprints as non-heavy footprints.
Do not read/write footprints at all.