23 #include "pybind11/pybind11.h"
33 using namespace pybind11::literals;
41 using PyCentroidAlgorithm =
42 py::class_<SdssCentroidAlgorithm, std::shared_ptr<SdssCentroidAlgorithm>, SimpleAlgorithm>;
43 using PyCentroidControl = py::class_<SdssCentroidControl>;
44 using PyCentroidTransform =
45 py::class_<SdssCentroidTransform, std::shared_ptr<SdssCentroidTransform>,
BaseTransform>;
47 PyCentroidControl declareCentroidControl(
py::module &mod) {
48 PyCentroidControl
cls(mod,
"SdssCentroidControl");
56 cls.def(py::init<>());
61 PyCentroidAlgorithm declareCentroidAlgorithm(
py::module &mod) {
62 PyCentroidAlgorithm
cls(mod,
"SdssCentroidAlgorithm");
64 cls.attr(
"FAILURE") = py::cast(SdssCentroidAlgorithm::FAILURE);
65 cls.attr(
"EDGE") = py::cast(SdssCentroidAlgorithm::EDGE);
66 cls.attr(
"NO_SECOND_DERIVATIVE") = py::cast(SdssCentroidAlgorithm::NO_SECOND_DERIVATIVE);
67 cls.attr(
"ALMOST_NO_SECOND_DERIVATIVE") = py::cast(SdssCentroidAlgorithm::ALMOST_NO_SECOND_DERIVATIVE);
68 cls.attr(
"NOT_AT_MAXIMUM") = py::cast(SdssCentroidAlgorithm::NOT_AT_MAXIMUM);
70 cls.def(py::init<SdssCentroidAlgorithm::Control const &, std::string const &, afw::table::Schema &>(),
71 "ctrl"_a,
"name"_a,
"schema"_a);
74 cls.def(
"fail", &SdssCentroidAlgorithm::fail,
"measRecord"_a,
"error"_a =
nullptr);
79 PyCentroidTransform declareCentroidTransform(
py::module &mod) {
80 PyCentroidTransform
cls(mod,
"SdssCentroidTransform");
83 afw::table::SchemaMapper &>(),
84 "ctrl"_a,
"name"_a,
"mapper"_a);
92 py::module::import(
"lsst.afw.table");
93 py::module::import(
"lsst.meas.base.algorithm");
94 py::module::import(
"lsst.meas.base.flagHandler");
95 py::module::import(
"lsst.meas.base.transform");
97 auto clsCentroidControl = declareCentroidControl(mod);
98 auto clsCentroidAlgorithm = declareCentroidAlgorithm(mod);
99 auto clsCentroidTransform = declareCentroidTransform(mod);
101 clsCentroidAlgorithm.attr(
"Control") = clsCentroidControl;
102 clsCentroidTransform.attr(
"Control") = clsCentroidControl;
104 python::declareAlgorithm<SdssCentroidAlgorithm, SdssCentroidControl, SdssCentroidTransform>(
105 clsCentroidAlgorithm, clsCentroidControl, clsCentroidTransform);