23 #include "pybind11/pybind11.h"
24 #include "pybind11/stl.h"
38 using namespace pybind11::literals;
42 namespace extensions {
43 namespace photometryKron {
48 py::class_<KronFluxControl>
cls(mod,
"KronFluxControl");
50 cls.def(py::init<>());
64 void declareKronFluxAlgorithm(
py::module &mod) {
65 py::class_<KronFluxAlgorithm, std::shared_ptr<KronFluxAlgorithm>, base::SimpleAlgorithm>
cls(
66 mod,
"KronFluxAlgorithm");
68 cls.def_static(
"getFlagDefinitions", &KronFluxAlgorithm::getFlagDefinitions,
69 py::return_value_policy::copy);
70 cls.attr(
"FAILURE") = py::cast(KronFluxAlgorithm::FAILURE);
71 cls.attr(
"EDGE") = py::cast(KronFluxAlgorithm::EDGE);
72 cls.attr(
"BAD_SHAPE_NO_PSF") = py::cast(KronFluxAlgorithm::BAD_SHAPE_NO_PSF);
73 cls.attr(
"NO_MINIMUM_RADIUS") = py::cast(KronFluxAlgorithm::NO_MINIMUM_RADIUS);
74 cls.attr(
"NO_FALLBACK_RADIUS") = py::cast(KronFluxAlgorithm::NO_FALLBACK_RADIUS);
75 cls.attr(
"BAD_RADIUS") = py::cast(KronFluxAlgorithm::BAD_RADIUS);
76 cls.attr(
"USED_MINIMUM_RADIUS") = py::cast(KronFluxAlgorithm::USED_MINIMUM_RADIUS);
77 cls.attr(
"USED_PSF_RADIUS") = py::cast(KronFluxAlgorithm::USED_PSF_RADIUS);
78 cls.attr(
"SMALL_RADIUS") = py::cast(KronFluxAlgorithm::SMALL_RADIUS);
79 cls.attr(
"BAD_SHAPE") = py::cast(KronFluxAlgorithm::BAD_SHAPE);
82 daf::base::PropertySet &>(),
83 "ctrl"_a,
"name"_a,
"schema"_a,
"metadata"_a);
86 cls.def(
"measureForced", &KronFluxAlgorithm::measureForced,
"measRecord"_a,
"exposure"_a,
"refRecord"_a,
88 cls.def(
"fail", &KronFluxAlgorithm::fail,
"measRecord"_a,
"error"_a = NULL);
91 using PyKronAperture = py::class_<KronAperture>;
99 template <
typename ImageT>
100 void declareKronApertureTemplatedMethods(PyKronAperture &
cls) {
101 cls.def_static(
"determineRadius", &KronAperture::determineRadius<ImageT>,
"image"_a,
"axes"_a,
"center"_a,
103 cls.def(
"measureFlux", &KronAperture::measureFlux<ImageT>,
"image"_a,
"nRadiusForFlux"_a,
108 PyKronAperture
cls(mod,
"KronAperture");
110 cls.def(py::init<geom::Point2D const &, afw::geom::ellipses::BaseCore const &, float>(),
"center"_a,
111 "core"_a,
"radiusForRadius"_a =
std::nanf(
""));
112 cls.def(py::init<afw::table::SourceRecord const &, float>(),
"source"_a,
114 cls.def(py::init<afw::table::SourceRecord const &, geom::AffineTransform const &, double, float>(),
115 "reference"_a,
"refToMeas"_a,
"radius"_a,
"radiusForRadius"_a =
std::nanf(
""));
117 cls.def_static(
"getKronAxes", &KronAperture::getKronAxes,
"shape"_a,
"transformation"_a,
"radius"_a);
119 cls.def(
"getX", &KronAperture::getX);
120 cls.def(
"getY", &KronAperture::getY);
121 cls.def(
"getRadiusForRadius", &KronAperture::getRadiusForRadius);
122 cls.def(
"getCenter", &KronAperture::getCenter);
123 cls.def(
"getAxes", (afw::geom::ellipses::Axes & (KronAperture::*)()) & KronAperture::getAxes,
124 py::return_value_policy::reference_internal);
127 declareKronApertureTemplatedMethods<afw::image::MaskedImage<float>>(
cls);
133 py::module::import(
"lsst.afw.geom");
134 py::module::import(
"lsst.afw.image");
135 py::module::import(
"lsst.afw.table");
136 py::module::import(
"lsst.daf.base");
138 declareKronFluxControl(mod);
139 declareKronFluxAlgorithm(mod);
140 declareKronAperture(mod);