LSSTApplications
19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
25 #if !defined(LSST_AFW_MATH_STATISTICS_H)
26 #define LSST_AFW_MATH_STATISTICS_H
40 #include "boost/iterator/iterator_adaptor.hpp"
41 #include "boost/tuple/tuple.hpp"
51 template <
typename,
typename,
typename>
101 bool isNanSafe =
true,
105 : _numSigmaClip(numSigmaClip),
108 _noGoodPixelsMask(0x0),
109 _isNanSafe(isNanSafe),
110 _useWeights(useWeights),
111 _calcErrorFromInputVariance(false),
112 _maskPropagationThresholds() {
119 assert(_numSigmaClip > 0);
120 assert(_numIter > 0);
143 assert(numSigmaClip > 0);
144 _numSigmaClip = numSigmaClip;
152 void setNanSafe(
bool isNanSafe) noexcept { _isNanSafe = isNanSafe; }
155 _calcErrorFromInputVariance = calcErrorFromInputVariance;
161 double _numSigmaClip;
164 int _noGoodPixelsMask;
167 bool _calcErrorFromInputVariance;
232 template <
typename ImageT,
typename MaskT,
typename VarianceT>
233 explicit Statistics(ImageT
const &img, MaskT
const &msk, VarianceT
const &var,
int const flags,
244 template <
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
245 explicit Statistics(ImageT
const &img, MaskT
const &msk, VarianceT
const &var, WeightT
const &weights,
303 bool _weightsAreMultiplicative;
313 template <
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
314 void doStatistics(ImageT
const &img, MaskT
const &msk, VarianceT
const &var, WeightT
const &weights,
323 template <
typename ValueT>
324 class infinite_iterator :
public boost::iterator_adaptor<infinite_iterator<ValueT>, const ValueT *,
325 const ValueT, boost::forward_traversal_tag> {
332 void increment() noexcept { ; }
338 template <
typename ValueT>
353 template <
typename Pixel>
358 return Statistics(img, msk, var, flags, sctrl);
365 template <
typename ImageT,
typename MaskT,
typename VarianceT>
368 return Statistics(img, msk, var, flags, sctrl);
375 template <
typename Pixel>
378 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
390 template <
typename Pixel>
394 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance() ||
395 (!sctrl.getWeightedIsSet() && (weights.
getWidth() != 0 && weights.
getHeight() != 0))) {
413 StatisticsControl
const &sctrl = StatisticsControl());
419 template <
typename Pixel>
428 return Statistics(img, msk, var, flags, sctrl);
435 template <
typename ValueT>
468 template <
typename EntryT>
476 return Statistics(img, msk, var, flags, sctrl);
483 template <
typename EntryT>
495 return Statistics(img, msk, var, weights, flags, sctrl);
502 template <
typename EntryT>
507 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
519 template <
typename EntryT>
527 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
@ IQRANGE
estimate sample inter-quartile range
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
bool getCalcErrorFromInputVariance() const noexcept
lsst::afw::image::MaskedImage< EntryT >::MaskPtr getMask() const
ImageImposter(std::vector< ValueT > const &v)
Represent a 2-dimensional array of bitmask pixels.
infinite_iterator(const ValueT *p)
void setWeighted(bool useWeights) noexcept
void setNumIter(int numIter)
ImageImposter(ImageImposter< ValueT > const &img)
double getMaskPropagationThreshold(int bit) const
When pixels with the given bit are rejected, we count what fraction the rejected pixels would have co...
Statistics(Statistics const &)=default
lsst::afw::image::VariancePixel WeightPixel
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
x_iterator row_begin(int) const noexcept
bool getNanSafe() const noexcept
bool empty() const noexcept
int getHeight() const
Return the number of rows in the image.
bool getWeightedIsSet() const noexcept
int getAndMask() const noexcept
StatisticsControl(double numSigmaClip=3.0, int numIter=3, lsst::afw::image::MaskPixel andMask=0x0, bool isNanSafe=true, WeightsBoolean useWeights=WEIGHTS_NONE)
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)
void setMaskPropagationThreshold(int bit, double threshold)
double getNumSigmaClip() const noexcept
Statistics & operator=(Statistics const &)=default
x_iterator row_begin(int) const noexcept
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)
Value getResult(Property const prop=NOTHING) const
Return the value and error in the specified statistic (e.g.
@ MEANCLIP
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
@ VARIANCECLIP
estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)
This iterator will never increment.
A class to manipulate images, masks, and variance as a single object.
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
@ MEAN
estimate sample mean
lsst::afw::image::MaskPixel getOrMask() const noexcept
infinite_iterator< ValueT > x_iterator
int getWidth() const noexcept
MaskImposter(ValueT val=0) noexcept
@ STDEVCLIP
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
float VariancePixel
default type for MaskedImage variance images
~Statistics() noexcept=default
@ NCLIPPED
number of clipped points
Statistics & operator=(Statistics &&)=default
void setNumSigmaClip(double numSigmaClip)
@ ORMASK
get the or-mask of all pixels used.
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
@ ERRORS
Include errors of requested quantities.
A base class for image defects.
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
int getNumIter() const noexcept
Statistics(Statistics &&)=default
x_iterator row_end(int) const noexcept
A Mask wrapper to provide an infinite_iterator for Mask::row_begin().
Pass parameters to a Statistics object.
std::pair< double, double > Value
The type used to report (value, error) for desired statistics.
A vector wrapper to provide a vector with the necessary methods and typedefs to be processed by Stati...
@ MEANSQUARE
find mean value of square of pixel values
bool getWeighted() const noexcept
double getError(Property const prop=NOTHING) const
Return the error in the desired property (if specified in the constructor)
@ NPOINT
number of sample points
std::vector< ValueT >::const_iterator x_iterator
Reports invalid arguments.
@ STDEV
estimate sample standard deviation
lsst::afw::image::MaskedImage< EntryT >::ImagePtr getImage() const
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
@ MIN
estimate sample minimum
int getHeight() const noexcept
Extent< int, 2 > Extent2I
void setNanSafe(bool isNanSafe) noexcept
void setAndMask(int andMask)
std::vector< ValueT >::const_iterator fast_iterator
lsst::afw::image::MaskedImage< EntryT >::VariancePtr getVariance() const
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
@ MAX
estimate sample maximum
@ VARIANCE
estimate sample variance
Property
control what is calculated
@ NOTHING
We don't want anything.
friend class boost::iterator_core_access
lsst::geom::Extent2I getDimensions() const noexcept
void setNoGoodPixelsMask(int noGoodPixelsMask)
void setCalcErrorFromInputVariance(bool calcErrorFromInputVariance) noexcept
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
@ SUM
find sum of pixels in the image
@ NMASKED
number of masked points
int getNoGoodPixelsMask() const noexcept
int getWidth() const
Return the number of columns in the image.
@ MEDIAN
estimate sample median