23#include "pybind11/pybind11.h"
24#include "pybind11/stl.h"
36using namespace pybind11::literals;
43using PyFluxAlgorithm =
44 py::class_<ApertureFluxAlgorithm, std::shared_ptr<ApertureFluxAlgorithm>, SimpleAlgorithm>;
45using PyFluxControl = py::class_<ApertureFluxControl>;
46using PyFluxResult = py::class_<ApertureFluxResult, std::shared_ptr<ApertureFluxResult>, FluxResult>;
47using PyFluxTransform =
48 py::class_<ApertureFluxTransform, std::shared_ptr<ApertureFluxTransform>, BaseTransform>;
51 return wrappers.
wrapType(PyFluxControl(wrappers.module,
"ApertureFluxControl"), [](
auto &mod,
auto &cls) {
52 LSST_DECLARE_CONTROL_FIELD(cls, ApertureFluxControl, radii);
53 LSST_DECLARE_CONTROL_FIELD(cls, ApertureFluxControl, maxSincRadius);
54 LSST_DECLARE_CONTROL_FIELD(cls, ApertureFluxControl, shiftKernel);
56 cls.def(py::init<>());
60template <
typename Image,
class PyClass>
61void declareComputeFluxes(PyClass &cls) {
64 cls.def_static(
"computeSincFlux",
65 (Result(*)(
Image const &, afw::geom::ellipses::Ellipse
const &,
Control const &)) &
67 "image"_a,
"ellipse"_a,
"ctrl"_a =
Control());
68 cls.def_static(
"computeNaiveFlux",
69 (Result(*)(
Image const &, afw::geom::ellipses::Ellipse
const &,
Control const &)) &
71 "image"_a,
"ellipse"_a,
"ctrl"_a =
Control());
72 cls.def_static(
"computeFlux",
73 (Result(*)(
Image const &, afw::geom::ellipses::Ellipse
const &,
Control const &)) &
75 "image"_a,
"ellipse"_a,
"ctrl"_a =
Control());
79 return wrappers.
wrapType(PyFluxAlgorithm(wrappers.module,
"ApertureFluxAlgorithm"), [](
auto &mod,
auto &cls) {
80 cls.attr(
"FAILURE") = py::cast(ApertureFluxAlgorithm::FAILURE);
81 cls.attr(
"APERTURE_TRUNCATED") = py::cast(ApertureFluxAlgorithm::APERTURE_TRUNCATED);
82 cls.attr(
"SINC_COEFFS_TRUNCATED") = py::cast(ApertureFluxAlgorithm::SINC_COEFFS_TRUNCATED);
86 declareComputeFluxes<afw::image::Image<double>>(cls);
87 declareComputeFluxes<afw::image::MaskedImage<double>>(cls);
88 declareComputeFluxes<afw::image::Image<float>>(cls);
89 declareComputeFluxes<afw::image::MaskedImage<float>>(cls);
91 cls.def(
"measure", &ApertureFluxAlgorithm::measure,
"measRecord"_a,
"exposure"_a);
92 cls.def(
"fail", &ApertureFluxAlgorithm::fail,
"measRecord"_a,
"error"_a = nullptr);
93 cls.def_static(
"makeFieldPrefix", &ApertureFluxAlgorithm::makeFieldPrefix,
"name"_a,
"radius"_a);
98 wrappers.
wrapType(PyFluxResult(wrappers.module,
"ApertureFluxResult"), [](
auto &mod,
auto &cls) {
99 cls.def(
"getFlag", (bool (ApertureFluxResult::*)(unsigned int) const) &ApertureFluxResult::getFlag,
102 (bool (ApertureFluxResult::*)(std::string const &name) const) &ApertureFluxResult::getFlag,
104 cls.def(
"setFlag", &ApertureFluxResult::setFlag,
"index"_a,
"value"_a);
105 cls.def(
"unsetFlag", &ApertureFluxResult::unsetFlag,
"index"_a);
110 return wrappers.
wrapType(PyFluxTransform(wrappers.module,
"ApertureFluxTransform"), [](
auto &mod,
auto &cls) {
111 cls.def(py::init<ApertureFluxTransform::Control const &, std::string const &,
112 afw::table::SchemaMapper &>(),
113 "ctrl"_a,
"name"_a,
"mapper"_a);
115 cls.def(
"__call__", &ApertureFluxTransform::operator(),
"inputCatalog"_a,
"outputCatalog"_a,
"wcs"_a,
123 auto clsFluxControl = declareFluxControl(wrappers);
124 auto clsFluxAlgorithm = declareFluxAlgorithm(wrappers);
125 declareFluxResult(wrappers);
126 auto clsFluxTransform = declareFluxTransform(wrappers);
128 clsFluxAlgorithm.attr(
"Control") = clsFluxControl;
130 clsFluxTransform.attr(
"Control") = clsFluxControl;
132 python::declareAlgorithm<ApertureFluxAlgorithm, ApertureFluxControl, ApertureFluxTransform>(
133 clsFluxAlgorithm, clsFluxControl, clsFluxTransform);
A helper class for subdividing pybind11 module across multiple translation units (i....
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...
ApertureFluxControl Control
static Result computeSincFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
Compute the instFlux (and optionally, uncertanties) within an aperture using Sinc photometry.
static Result computeFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
Compute the instFlux (and optionally, uncertanties) within an aperture using the algorithm determined...
ApertureFluxResult Result
Result object returned by static methods.
static Result computeNaiveFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
Compute the instFlux (and optionally, uncertanties) within an aperture using naive photometry.
void wrapApertureFlow(WrapperCollection &)
g2d::python::Image< double > Image