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(
"getCalcErrorMosaicMode", &StatisticsControl::getCalcErrorMosaicMode);
121 cls.def(
"setNumSigmaClip", &StatisticsControl::setNumSigmaClip);
122 cls.def(
"setNumIter", &StatisticsControl::setNumIter);
123 cls.def(
"setAndMask", &StatisticsControl::setAndMask);
124 cls.def(
"setNoGoodPixelsMask", &StatisticsControl::setNoGoodPixelsMask);
125 cls.def(
"setNanSafe", &StatisticsControl::setNanSafe);
126 cls.def(
"setWeighted", &StatisticsControl::setWeighted);
127 cls.def(
"setCalcErrorFromInputVariance", &StatisticsControl::setCalcErrorFromInputVariance);
128 cls.def(
"setCalcErrorMosaicMode", &StatisticsControl::setCalcErrorMosaicMode);
131 wrappers.wrapType(py::enum_<StatisticsControl::WeightsBoolean>(control,
"WeightsBoolean"),
132 [](
auto &mod,
auto &enm) {
139 wrappers.wrapType(py::class_<Statistics>(wrappers.module,
"Statistics"), [](
auto &mod,
auto &cls) {
140 cls.def(
"getResult", &Statistics::getResult,
"prop"_a = Property::NOTHING);
141 cls.def(
"getError", &Statistics::getError,
"prop"_a = Property::NOTHING);
142 cls.def(
"getValue", &Statistics::getValue,
"prop"_a = Property::NOTHING);
143 cls.def(
"getOrMask", &Statistics::getOrMask);
147 wrappers.addSignatureDependency(
"lsst.afw.image");
149 declareStatistics<unsigned short>(wrappers);
150 declareStatistics<double>(wrappers);
151 declareStatistics<float>(wrappers);
152 declareStatistics<int>(wrappers);
156 declareStatisticsVectorOverloads<unsigned short>(wrappers);
157 declareStatisticsVectorOverloads<double>(wrappers);
158 declareStatisticsVectorOverloads<float>(wrappers);
159 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.
A class to evaluate image statistics.
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