23 #include "pybind11/pybind11.h"
24 #include "pybind11/eigen.h"
28 #include "ndarray/pybind11.h"
33 using namespace pybind11::literals;
41 using PyCentroidChecker = py::class_<CentroidChecker>;
42 using PyCentroidResult = py::class_<CentroidResult, std::shared_ptr<CentroidResult>>;
43 using PyCentroidResultKey = py::class_<CentroidResultKey>;
44 using PyCentroidTransform = py::class_<CentroidTransform, std::shared_ptr<CentroidTransform>,
BaseTransform>;
47 PyCentroidResult
cls(mod,
"CentroidResult");
51 cls.def_readwrite(
"xErr", &CentroidResult::xErr);
52 cls.def_readwrite(
"yErr", &CentroidResult::yErr);
53 cls.def_readwrite(
"x_y_Cov", &CentroidResult::x_y_Cov);
55 cls.def(py::init<>());
56 cls.def(py::init<CentroidElement, CentroidElement, CentroidCov const &>(),
"x"_a,
"y"_a,
"matrix"_a);
57 cls.def(py::init<CentroidElement, CentroidElement, ErrElement, ErrElement>(),
"x"_a,
"y"_a,
"xErr"_a,
60 cls.def(
"getCentroid", &CentroidResult::getCentroid);
61 cls.def(
"setCentroid", &CentroidResult::setCentroid,
"centroid"_a);
62 cls.def(
"getPoint", &CentroidResult::getPoint);
63 cls.def(
"getCentroidErr", &CentroidResult::getCentroidErr);
64 cls.def(
"setCentroidErr",
65 (
void (CentroidResult::*)(
CentroidCov const &)) & CentroidResult::setCentroidErr,
"matrix"_a);
66 cls.def(
"setCentroidErr",
71 void declareCentroidResultKey(
py::module &mod) {
72 PyCentroidResultKey
cls(mod,
"CentroidResultKey");
74 cls.def(py::init<>());
75 cls.def(
py::init<afw::table::PointKey<CentroidElement>
const &,
76 afw::table::CovarianceMatrixKey<ErrElement, 2>
const &>(),
77 "centroid"_a,
"uncertainty"_a);
78 cls.def(py::init<afw::table::SubSchema const &>(),
"subSchema"_a);
80 cls.def_static(
"addFields", &CentroidResultKey::addFields,
"schema"_a,
"name"_a,
"doc"_a,
"uncertainty"_a);
82 cls.def(
"__eq__", &CentroidResultKey::operator==, py::is_operator());
83 cls.def(
"__nq__", &CentroidResultKey::operator!=, py::is_operator());
85 cls.def(
"get", &CentroidResultKey::get,
"record"_a);
88 cls.def(
"getCentroid", &CentroidResultKey::getCentroid);
89 cls.def(
"getCentroidErr", &CentroidResultKey::getCentroidErr);
90 cls.def(
"getX", &CentroidResultKey::getX);
91 cls.def(
"getY", &CentroidResultKey::getY);
94 void declareCentroidTransform(
py::module &mod) {
95 PyCentroidTransform
cls(mod,
"CentroidTransform");
97 cls.def(py::init<std::string const &, afw::table::SchemaMapper &>(),
"name"_a,
"mapper"_a);
99 cls.def(
"__call__", &CentroidTransform::operator(),
"inputCatalog"_a,
"outputCatalog"_a,
"wcs"_a,
103 void declareCentroidChecker(
py::module &mod) {
104 PyCentroidChecker
cls(mod,
"CentroidChecker");
106 cls.def(py::init<afw::table::Schema &, std::string const &, bool, double>(),
"schema"_a,
"name"_a,
107 "inside"_a =
true,
"maxDistFromPeak"_a = -1.0);
109 cls.def(
"__call__", &CentroidChecker::operator(),
"record"_a);
112 void declareUncertaintyEnum(
py::module &mod) {
113 py::enum_<UncertaintyEnum> enm(mod,
"UncertaintyEnum");
123 py::module::import(
"lsst.afw.table");
124 py::module::import(
"lsst.meas.base.transform");
126 declareCentroidResult(mod);
127 declareCentroidResultKey(mod);
128 declareCentroidTransform(mod);
129 declareCentroidChecker(mod);
130 declareUncertaintyEnum(mod);