23 #include <pybind11/pybind11.h>
24 #include <pybind11/stl.h>
29 using namespace pybind11::literals;
35 template <
typename Pixel>
37 mod.def(
"makeStatistics",
44 mod.def(
"makeStatistics",
48 mod.def(
"makeStatistics",
58 template <
typename Pixel>
70 py::enum_<Property>(mod,
"Property", py::arithmetic())
93 py::class_<StatisticsControl, std::shared_ptr<StatisticsControl>> clsStatisticsControl(
94 mod,
"StatisticsControl");
96 py::enum_<StatisticsControl::WeightsBoolean>(clsStatisticsControl,
"WeightsBoolean")
97 .value(
"WEIGHTS_FALSE", StatisticsControl::WeightsBoolean::WEIGHTS_FALSE)
98 .value(
"WEIGHTS_TRUE", StatisticsControl::WeightsBoolean::WEIGHTS_TRUE)
99 .value(
"WEIGHTS_NONE", StatisticsControl::WeightsBoolean::WEIGHTS_NONE)
104 "numSigmaClip"_a = 3.0,
"numIter"_a = 3,
"andMask"_a = 0x0,
"isNanSafe"_a =
true,
105 "useWeights"_a = StatisticsControl::WEIGHTS_NONE);
107 clsStatisticsControl.def(
"getMaskPropagationThreshold", &StatisticsControl::getMaskPropagationThreshold);
108 clsStatisticsControl.def(
"setMaskPropagationThreshold", &StatisticsControl::setMaskPropagationThreshold);
109 clsStatisticsControl.def(
"getNumSigmaClip", &StatisticsControl::getNumSigmaClip);
110 clsStatisticsControl.def(
"getNumIter", &StatisticsControl::getNumIter);
111 clsStatisticsControl.def(
"getAndMask", &StatisticsControl::getAndMask);
112 clsStatisticsControl.def(
"getNoGoodPixelsMask", &StatisticsControl::getNoGoodPixelsMask);
113 clsStatisticsControl.def(
"getNanSafe", &StatisticsControl::getNanSafe);
114 clsStatisticsControl.def(
"getWeighted", &StatisticsControl::getWeighted);
115 clsStatisticsControl.def(
"getWeightedIsSet", &StatisticsControl::getWeightedIsSet);
116 clsStatisticsControl.def(
"getCalcErrorFromInputVariance",
117 &StatisticsControl::getCalcErrorFromInputVariance);
118 clsStatisticsControl.def(
"setNumSigmaClip", &StatisticsControl::setNumSigmaClip);
119 clsStatisticsControl.def(
"setNumIter", &StatisticsControl::setNumIter);
120 clsStatisticsControl.def(
"setAndMask", &StatisticsControl::setAndMask);
121 clsStatisticsControl.def(
"setNoGoodPixelsMask", &StatisticsControl::setNoGoodPixelsMask);
122 clsStatisticsControl.def(
"setNanSafe", &StatisticsControl::setNanSafe);
123 clsStatisticsControl.def(
"setWeighted", &StatisticsControl::setWeighted);
124 clsStatisticsControl.def(
"setCalcErrorFromInputVariance",
125 &StatisticsControl::setCalcErrorFromInputVariance);
127 py::class_<Statistics> clsStatistics(mod,
"Statistics");
129 clsStatistics.def(
"getResult", &Statistics::getResult,
"prop"_a =
Property::NOTHING);
130 clsStatistics.def(
"getError", &Statistics::getError,
"prop"_a =
Property::NOTHING);
131 clsStatistics.def(
"getValue", &Statistics::getValue,
"prop"_a =
Property::NOTHING);
132 clsStatistics.def(
"getOrMask", &Statistics::getOrMask);
134 declareStatistics<unsigned short>(mod);
135 declareStatistics<double>(mod);
136 declareStatistics<float>(mod);
137 declareStatistics<int>(mod);
142 declareStatisticsVectorOverloads<unsigned short>(mod);
143 declareStatisticsVectorOverloads<double>(mod);
144 declareStatisticsVectorOverloads<float>(mod);
145 declareStatisticsVectorOverloads<int>(mod);
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 declareStatisticsVectorOverloads(py::module &mod)
PYBIND11_MODULE(statistics, mod)
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)
@ ORMASK
get the or-mask of all pixels used.
@ ERRORS
Include errors of requested quantities.
@ VARIANCECLIP
estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)
@ MEANSQUARE
find mean value of square of pixel values
@ MIN
estimate sample minimum
@ NCLIPPED
number of clipped points
@ NOTHING
We don't want anything.
@ STDEV
estimate sample standard deviation
@ NMASKED
number of masked points
@ STDEVCLIP
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
@ VARIANCE
estimate sample variance
@ MEDIAN
estimate sample median
@ MAX
estimate sample maximum
@ SUM
find sum of pixels in the image
@ IQRANGE
estimate sample inter-quartile range
@ MEAN
estimate sample mean
@ MEANCLIP
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
@ NPOINT
number of sample points
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
void declareStatistics(py::module &mod)
A base class for image defects.