23#include <pybind11/pybind11.h>
25#include <pybind11/stl.h>
30using namespace pybind11::literals;
36template <
typename Pixel>
38 wrappers.wrap([](
auto &mod) {
39 mod.def(
"makeStatistics",
43 mod.def(
"makeStatistics",
47 mod.def(
"makeStatistics",
51 mod.def(
"makeStatistics",
55 mod.def(
"makeStatistics",
62template <
typename Pixel>
64 wrappers.wrap([](
auto &mod) {
65 mod.def(
"makeStatistics",
69 mod.def(
"makeStatistics",
78 wrappers.wrapType(py::enum_<Property>(wrappers.module,
"Property", py::arithmetic()),
79 [](
auto &mod,
auto &enm) {
80 enm.value(
"NOTHING", Property::NOTHING);
81 enm.value(
"ERRORS", Property::ERRORS);
82 enm.value(
"NPOINT", Property::NPOINT);
83 enm.value(
"MEAN", Property::MEAN);
84 enm.value(
"STDEV", Property::STDEV);
85 enm.value(
"VARIANCE", Property::VARIANCE);
86 enm.value(
"MEDIAN", Property::MEDIAN);
87 enm.value(
"IQRANGE", Property::IQRANGE);
88 enm.value(
"MEANCLIP", Property::MEANCLIP);
89 enm.value(
"STDEVCLIP", Property::STDEVCLIP);
90 enm.value(
"VARIANCECLIP", Property::VARIANCECLIP);
91 enm.value(
"MIN", Property::MIN);
92 enm.value(
"MAX", Property::MAX);
93 enm.value(
"SUM", Property::SUM);
94 enm.value(
"MEANSQUARE", Property::MEANSQUARE);
95 enm.value(
"ORMASK", Property::ORMASK);
96 enm.value(
"NCLIPPED", Property::NCLIPPED);
97 enm.value(
"NMASKED", Property::NMASKED);
103 using PyClass = py::class_<StatisticsControl, std::shared_ptr<StatisticsControl>>;
104 auto control = wrappers.wrapType(
PyClass(wrappers.module,
"StatisticsControl"), [](
auto &mod,
auto &cls) {
105 cls.def(py::init<double, int, lsst::afw::image::MaskPixel, bool,
106 typename StatisticsControl::WeightsBoolean>(),
107 "numSigmaClip"_a = 3.0,
"numIter"_a = 3,
"andMask"_a = 0x0,
"isNanSafe"_a = true,
108 "useWeights"_a = StatisticsControl::WEIGHTS_NONE);
110 cls.def(
"getMaskPropagationThreshold", &StatisticsControl::getMaskPropagationThreshold);
111 cls.def(
"setMaskPropagationThreshold", &StatisticsControl::setMaskPropagationThreshold);
112 cls.def(
"getNumSigmaClip", &StatisticsControl::getNumSigmaClip);
113 cls.def(
"getNumIter", &StatisticsControl::getNumIter);
114 cls.def(
"getAndMask", &StatisticsControl::getAndMask);
115 cls.def(
"getNoGoodPixelsMask", &StatisticsControl::getNoGoodPixelsMask);
116 cls.def(
"getNanSafe", &StatisticsControl::getNanSafe);
117 cls.def(
"getWeighted", &StatisticsControl::getWeighted);
118 cls.def(
"getWeightedIsSet", &StatisticsControl::getWeightedIsSet);
119 cls.def(
"getCalcErrorFromInputVariance", &StatisticsControl::getCalcErrorFromInputVariance);
120 cls.def(
"setNumSigmaClip", &StatisticsControl::setNumSigmaClip);
121 cls.def(
"setNumIter", &StatisticsControl::setNumIter);
122 cls.def(
"setAndMask", &StatisticsControl::setAndMask);
123 cls.def(
"setNoGoodPixelsMask", &StatisticsControl::setNoGoodPixelsMask);
124 cls.def(
"setNanSafe", &StatisticsControl::setNanSafe);
125 cls.def(
"setWeighted", &StatisticsControl::setWeighted);
126 cls.def(
"setCalcErrorFromInputVariance", &StatisticsControl::setCalcErrorFromInputVariance);
129 wrappers.wrapType(py::enum_<StatisticsControl::WeightsBoolean>(control,
"WeightsBoolean"),
130 [](
auto &mod,
auto &enm) {
131 enm.value(
"WEIGHTS_FALSE", StatisticsControl::WeightsBoolean::WEIGHTS_FALSE);
132 enm.value(
"WEIGHTS_TRUE", StatisticsControl::WeightsBoolean::WEIGHTS_TRUE);
133 enm.value(
"WEIGHTS_NONE", StatisticsControl::WeightsBoolean::WEIGHTS_NONE);
137 wrappers.wrapType(py::class_<Statistics>(wrappers.module,
"Statistics"), [](
auto &mod,
auto &cls) {
138 cls.def(
"getResult", &Statistics::getResult,
"prop"_a = Property::NOTHING);
139 cls.def(
"getError", &Statistics::getError,
"prop"_a = Property::NOTHING);
140 cls.def(
"getValue", &Statistics::getValue,
"prop"_a = Property::NOTHING);
141 cls.def(
"getOrMask", &Statistics::getOrMask);
145 wrappers.addSignatureDependency(
"lsst.afw.image");
147 declareStatistics<unsigned short>(wrappers);
148 declareStatistics<double>(wrappers);
149 declareStatistics<float>(wrappers);
150 declareStatistics<int>(wrappers);
154 declareStatisticsVectorOverloads<unsigned short>(wrappers);
155 declareStatisticsVectorOverloads<double>(wrappers);
156 declareStatisticsVectorOverloads<float>(wrappers);
157 declareStatisticsVectorOverloads<int>(wrappers);
A class to represent a 2-dimensional array of pixels.
Represent a 2-dimensional array of bitmask pixels.
A class to manipulate images, masks, and variance as a single object.
Pass parameters to a Statistics object.
void declareStatistics(lsst::utils::python::WrapperCollection &wrappers)
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
void wrapStatistics(lsst::utils::python::WrapperCollection &)
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
void declareStatisticsVectorOverloads(lsst::utils::python::WrapperCollection &wrappers)
py::class_< PixelAreaBoundedField, std::shared_ptr< PixelAreaBoundedField >, BoundedField > PyClass
A base class for image defects.