23 #include "pybind11/pybind11.h"
36 namespace py = pybind11;
37 using namespace py::literals;
45 using PyPeakRecord = py::class_<PeakRecord, std::shared_ptr<PeakRecord>, table::BaseRecord>;
46 using PyPeakTable = py::class_<PeakTable, std::shared_ptr<PeakTable>, table::BaseTable>;
51 void declarePeakRecord(PyPeakRecord &
cls) {
52 cls.def(
"getTable", &PeakRecord::getTable);
53 cls.def_property_readonly(
"table", &PeakRecord::getTable);
54 cls.def(
"getId", &PeakRecord::getId);
55 cls.def(
"setId", &PeakRecord::setId);
56 cls.def(
"getIx", &PeakRecord::getIx);
57 cls.def(
"getIy", &PeakRecord::getIy);
58 cls.def(
"setIx", &PeakRecord::setIx);
59 cls.def(
"setIy", &PeakRecord::setIy);
60 cls.def(
"getI", &PeakRecord::getI);
61 cls.def(
"getCentroid", (
afw::geom::Point2I (PeakRecord::*)(
bool)
const) & PeakRecord::getCentroid);
62 cls.def(
"getCentroid", (
afw::geom::Point2D (PeakRecord::*)()
const) & PeakRecord::getCentroid);
63 cls.def(
"getFx", &PeakRecord::getFx);
64 cls.def(
"getFy", &PeakRecord::getFy);
65 cls.def(
"setFx", &PeakRecord::setFx);
66 cls.def(
"setFy", &PeakRecord::setFy);
67 cls.def(
"getF", &PeakRecord::getF);
68 cls.def(
"getPeakValue", &PeakRecord::getPeakValue);
69 cls.def(
"setPeakValue", &PeakRecord::setPeakValue);
70 auto streamStr = [](PeakRecord
const &
self) {
71 std::stringstream buffer;
75 cls.def(
"__str__", streamStr);
76 cls.def(
"__repr__", streamStr);
82 void declarePeakTable(PyPeakTable &cls) {
83 cls.def_static(
"make", &PeakTable::make,
"schema"_a,
"forceNew"_a =
false);
84 cls.def_static(
"makeMinimalSchema", &PeakTable::makeMinimalSchema);
85 cls.def_static(
"checkSchema", &PeakTable::checkSchema,
"schema"_a);
86 cls.def(
"getIdFactory", (std::shared_ptr<table::IdFactory> (PeakTable::*)()) & PeakTable::getIdFactory);
87 cls.def(
"setIdFactory", &PeakTable::setIdFactory,
"factory"_a);
88 cls.def_static(
"getIdKey", &PeakTable::getIdKey);
89 cls.def_static(
"getIxKey", &PeakTable::getIxKey);
90 cls.def_static(
"getIyKey", &PeakTable::getIyKey);
91 cls.def_static(
"getFxKey", &PeakTable::getFxKey);
92 cls.def_static(
"getFyKey", &PeakTable::getFyKey);
93 cls.def_static(
"getPeakValueKey", &PeakTable::getPeakValueKey);
95 cls.def(
"makeRecord", &PeakTable::makeRecord);
96 cls.def(
"copyRecord", (std::shared_ptr<PeakRecord> (PeakTable::*)(afw::table::BaseRecord
const &)) &
97 PeakTable::copyRecord);
98 cls.def(
"copyRecord", (std::shared_ptr<PeakRecord> (PeakTable::*)(afw::table::BaseRecord
const &,
99 afw::table::SchemaMapper
const &)) &
100 PeakTable::copyRecord);
106 py::module mod(
"_peak",
"Python wrapper for afw _peak library");
109 PyPeakRecord clsPeakRecord(mod,
"PeakRecord");
110 PyPeakTable clsPeakTable(mod,
"PeakTable");
113 declarePeakRecord(clsPeakRecord);
114 declarePeakTable(clsPeakTable);
115 auto clsPeakColumnView = table::python::declareColumnView<PeakRecord>(mod,
"Peak");
116 auto clsPeakCatalog = table::python::declareCatalog<PeakRecord>(mod,
"Peak");
118 clsPeakRecord.attr(
"Table") = clsPeakTable;
119 clsPeakRecord.attr(
"ColumnView") = clsPeakColumnView;
120 clsPeakRecord.attr(
"Catalog") = clsPeakCatalog;
121 clsPeakTable.attr(
"Record") = clsPeakRecord;
122 clsPeakTable.attr(
"ColumnView") = clsPeakColumnView;
123 clsPeakTable.attr(
"Catalog") = clsPeakCatalog;
124 clsPeakCatalog.attr(
"Record") = clsPeakRecord;
125 clsPeakCatalog.attr(
"Table") = clsPeakTable;
126 clsPeakCatalog.attr(
"ColumnView") = clsPeakColumnView;
PYBIND11_PLUGIN(_cameraPoint)
Point< double, 2 > Point2D