22 #include "pybind11/pybind11.h"
23 #include "pybind11/eigen.h"
25 #include "ndarray/pybind11.h"
31 using namespace pybind11::literals;
35 namespace extensions {
36 namespace simpleShape {
40 template <
typename T,
typename PyClass>
42 cls.def_static(
"computeMoments",
43 (SimpleShapeResult(*)(afw::geom::ellipses::Ellipse
const &,
44 afw::image::MaskedImage<T>
const &,
double)) &
45 SimpleShape::computeMoments,
46 "weight"_a,
"image"_a,
"nSigmaRegion"_a = 3.0);
52 py::module::import(
"lsst.afw.geom");
53 py::module::import(
"lsst.afw.image");
54 py::module::import(
"lsst.afw.table");
55 py::module::import(
"lsst.meas.base");
60 py::class_<SimpleShapeControl> clsSimpleShapeControl(mod,
"SimpleShapeControl");
61 py::class_<SimpleShapeResult> clsSimpleShapeResult(mod,
"SimpleShapeResult");
62 py::class_<SimpleShapeResultKey> clsSimpleShapeResultKey(mod,
"SimpleShapeResultKey");
65 clsSimpleShape.def(py::init<SimpleShape::Control const &, std::string const &, afw::table::Schema &>(),
66 "ctrl"_a,
"name"_a,
"schema"_a);
67 clsSimpleShapeControl.def(py::init<>());
69 clsSimpleShapeResultKey.def(py::init<afw::table::SubSchema const &>(),
"s"_a);
75 declareMoments<float>(clsSimpleShape);
76 declareMoments<double>(clsSimpleShape);
77 clsSimpleShape.def_static(
"correctWeightedMoments", &SimpleShape::correctWeightedMoments,
"weight"_a,
78 "ellipse"_a,
"center"_a);
80 clsSimpleShapeResult.def_readwrite(
"ellipse", &SimpleShapeResult::ellipse);
81 clsSimpleShapeResult.def_readwrite(
"center", &SimpleShapeResult::center);
83 clsSimpleShapeResult.def(
"getFlag", &SimpleShapeResult::getFlag);
85 clsSimpleShapeResultKey.def(
"get", &SimpleShapeResultKey::get,
"record"_a);