LSSTApplications  19.0.0-14-gb0260a2+6327455aeb,20.0.0+44dbdb3492,20.0.0+8a208d85ec,20.0.0+914fcaec49,20.0.0+a571b09ef0,20.0.0+f15d39cacd,20.0.0-1-g253301a+8a208d85ec,20.0.0-1-g5b95a8c+351e15424a,20.0.0-16-g760a3dc6+7dead9ab29,20.0.0-18-gcabc0c9fd+54cb7ade16,20.0.0-2-g4dae9ad+8a636d8bd2,20.0.0-2-g61b8584+b4ab3064f8,20.0.0-2-ga51b5d4+1f4ba438e8,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+3033df31e9,20.0.0-2-gf072044+8a208d85ec,20.0.0-2-gf1f7952+8a636d8bd2,20.0.0-22-g54e2caa+8bd7be2b67,20.0.0-25-g5eafb0f+8a636d8bd2,20.0.0-28-g73474ed+df2822652a,20.0.0-29-g1235a2f+94e05d8818,20.0.0-3-g8f21e14+2bd63a3b42,20.0.0-3-gbd60e8c+ffb20d0b0d,20.0.0-3-gbecbe05+7f0063ada4,20.0.0-4-g4bc9b9f+5be46ab906,20.0.0-4-g97dc21a+df2822652a,20.0.0-4-gb4befbc+928dca1c48,20.0.0-4-gf910f65+b4ab3064f8,20.0.0-42-g74ec3ae9+afa8208526,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g4aa86cc+9b37c72498,20.0.0-6-g9a5b7a1+9aa0dcac42,20.0.0-6-gd222c45+7040a8a6f6,20.0.0-73-gf477d90+d0de1c7e9f,20.0.0-9-g4aef684+2aec92f563,20.0.0-9-g5051ac2+d529cf1a41,w.2020.47
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Related Functions | List of all members
lsst::afw::math::Statistics Class Referencefinal

#include <Statistics.h>

Public Types

typedef std::pair< double, double > Value
 The type used to report (value, error) for desired statistics. More...
 

Public Member Functions

template<typename ImageT , typename MaskT , typename VarianceT >
 Statistics (ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Constructor for Statistics object. More...
 
template<typename ImageT , typename MaskT , typename VarianceT , typename WeightT >
 Statistics (ImageT const &img, MaskT const &msk, VarianceT const &var, WeightT const &weights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 
 Statistics (Statistics const &)=default
 
 Statistics (Statistics &&)=default
 
Statisticsoperator= (Statistics const &)=default
 
Statisticsoperator= (Statistics &&)=default
 
 ~Statistics () noexcept=default
 
Value getResult (Property const prop=NOTHING) const
 Return the value and error in the specified statistic (e.g. More...
 
double getError (Property const prop=NOTHING) const
 Return the error in the desired property (if specified in the constructor) More...
 
double getValue (Property const prop=NOTHING) const
 Return the value of the desired property (if specified in the constructor) More...
 
lsst::afw::image::MaskPixel getOrMask () const noexcept
 
template<>
 Statistics (image::Mask< image::MaskPixel > const &msk, image::Mask< image::MaskPixel > const &msk2, image::Mask< image::MaskPixel > const &var, int const flags, StatisticsControl const &sctrl)
 

Related Functions

(Note that these are not member functions.)

template<typename Pixel >
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) More...
 
template<typename ImageT , typename MaskT , typename VarianceT >
Statistics makeStatistics (ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Handle a straight front-end to the constructor. More...
 
template<typename Pixel >
Statistics makeStatistics (lsst::afw::image::MaskedImage< Pixel > const &mimg, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Handle MaskedImages, just pass the getImage() and getMask() values right on through. More...
 
template<typename Pixel >
Statistics makeStatistics (lsst::afw::image::MaskedImage< Pixel > const &mimg, lsst::afw::image::Image< WeightPixel > const &weights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Handle MaskedImages, just pass the getImage() and getMask() values right on through. More...
 
Statistics makeStatistics (lsst::afw::image::Mask< lsst::afw::image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Specialization to handle Masks. More...
 
template<typename Pixel >
Statistics makeStatistics (lsst::afw::image::Image< Pixel > const &img, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle regular (non-masked) Images. More...
 
template<typename EntryT >
Statistics makeStatistics (std::vector< EntryT > const &v, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle std::vector<> More...
 
template<typename EntryT >
Statistics makeStatistics (std::vector< EntryT > const &v, std::vector< WeightPixel > const &vweights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle std::vector<> More...
 
template<typename EntryT >
Statistics makeStatistics (lsst::afw::math::MaskedVector< EntryT > const &mv, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle lsst::afw::math::MaskedVector<> More...
 
template<typename EntryT >
Statistics makeStatistics (lsst::afw::math::MaskedVector< EntryT > const &mv, std::vector< WeightPixel > const &vweights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle lsst::afw::math::MaskedVector<> More...
 

Detailed Description

A class to evaluate image statistics

The basic strategy is to construct a Statistics object from an Image and a statement of what we want to know. The desired results can then be returned using Statistics methods. A StatisticsControl object is used to pass parameters. The statistics currently implemented are listed in the enum Properties in Statistics.h.

 // sets NumSigclip (3.0), and NumIter (3) for clipping
 lsst::afw::math::StatisticsControl sctrl(3.0, 3);

 sctrl.setNumSigmaClip(4.0);            // reset number of standard deviations for N-sigma clipping
 sctrl.setNumIter(5);                   // reset number of iterations for N-sigma clipping
 sctrl.setAndMask(0x1);                 // ignore pixels with these mask bits set
 sctrl.setNanSafe(true);                // check for NaNs & Infs, a bit slower (default=true)

 lsst::afw::math::Statistics statobj =
     lsst::afw::math::makeStatistics(*img, afwMath::NPOINT |
                                           afwMath::MEAN | afwMath::MEANCLIP, sctrl);
 double const n = statobj.getValue(lsst::afw::math::NPOINT);
 std::pair<double, double> const mean =
                                  statobj.getResult(lsst::afw::math::MEAN); // Returns (value, error)
 double const meanError = statobj.getError(lsst::afw::math::MEAN);                // just the error
Note
Factory function: We used a helper function, makeStatistics, rather that the constructor directly so that the compiler could deduce the types – cf. std::make_pair()
Inputs: The class Statistics is templated, and makeStatistics() can take either: (1) an image, (2) a maskedImage, or (3) a std::vector<> Overloaded makeStatistics() functions then wrap what they were passed in Image/Mask-like classes and call the Statistics constructor.
Clipping: The clipping is done iteratively with numSigmaClip and numIter specified in the StatisticsControl object. The first clip (ie. the first iteration) is performed at: median +/- numSigmaClip*IQ_TO_STDEV*IQR, where IQ_TO_STDEV=~0.74 is the conversion factor between the IQR and sigma for a Gaussian distribution. All subsequent iterations perform clips at mean +/- numSigmaClip*stdev.

Definition at line 215 of file Statistics.h.

Member Typedef Documentation

◆ Value

The type used to report (value, error) for desired statistics.

Definition at line 218 of file Statistics.h.

Constructor & Destructor Documentation

◆ Statistics() [1/5]

template<typename ImageT , typename MaskT , typename VarianceT >
lsst::afw::math::Statistics::Statistics ( ImageT const &  img,
MaskT const &  msk,
VarianceT const &  var,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
explicit

Constructor for Statistics object.

Parameters
imgImage whose properties we want
mskMask to control which pixels are included
varVariances corresponding to values in Image
flagsDescribe what we want to calculate
sctrlControl how things are calculated
Note
Most of the actual work is done in this constructor; the results are retrieved using getValue etc.

Definition at line 773 of file Statistics.cc.

775  : _flags(flags),
776  _mean(NaN, NaN),
777  _variance(NaN, NaN),
778  _min(NaN),
779  _max(NaN),
780  _sum(NaN),
781  _meanclip(NaN, NaN),
782  _varianceclip(NaN, NaN),
783  _median(NaN, NaN),
784  _nClipped(0),
785  _nMasked(0),
786  _iqrange(NaN),
787  _sctrl(sctrl),
788  _weightsAreMultiplicative(false) {
789  doStatistics(img, msk, var, var, _flags, _sctrl);
790 }

◆ Statistics() [2/5]

template<typename ImageT , typename MaskT , typename VarianceT , typename WeightT >
lsst::afw::math::Statistics::Statistics ( ImageT const &  img,
MaskT const &  msk,
VarianceT const &  var,
WeightT const &  weights,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
explicit
Parameters
imgImage whose properties we want
mskMask to control which pixels are included
varVariances corresponding to values in Image
weightsWeights to use corresponding to values in Image
flagsDescribe what we want to calculate
sctrlControl how things are calculated

Definition at line 822 of file Statistics.cc.

824  : _flags(flags),
825  _mean(NaN, NaN),
826  _variance(NaN, NaN),
827  _min(NaN),
828  _max(NaN),
829  _sum(NaN),
830  _meanclip(NaN, NaN),
831  _varianceclip(NaN, NaN),
832  _median(NaN, NaN),
833  _nClipped(0),
834  _nMasked(0),
835  _iqrange(NaN),
836  _sctrl(sctrl),
837  _weightsAreMultiplicative(true) {
838  if (!isEmpty(weights)) {
839  if (_sctrl.getWeightedIsSet() && !_sctrl.getWeighted()) {
840  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
841  "You must use the weights if you provide them");
842  }
843 
844  _sctrl.setWeighted(true);
845  }
846  doStatistics(img, msk, var, weights, _flags, _sctrl);
847 }

◆ Statistics() [3/5]

lsst::afw::math::Statistics::Statistics ( Statistics const &  )
default

◆ Statistics() [4/5]

lsst::afw::math::Statistics::Statistics ( Statistics &&  )
default

◆ ~Statistics()

lsst::afw::math::Statistics::~Statistics ( )
defaultnoexcept

◆ Statistics() [5/5]

template<>
lsst::afw::math::Statistics::Statistics ( image::Mask< image::MaskPixel > const &  msk,
image::Mask< image::MaskPixel > const &  msk2,
image::Mask< image::MaskPixel > const &  var,
int const  flags,
StatisticsControl const &  sctrl 
)

Definition at line 1070 of file Statistics.cc.

1073  : _flags(flags),
1074  _mean(NaN, NaN),
1075  _variance(NaN, NaN),
1076  _min(NaN),
1077  _max(NaN),
1078  _meanclip(NaN, NaN),
1079  _varianceclip(NaN, NaN),
1080  _median(NaN, NaN),
1081  _nClipped(0),
1082  _iqrange(NaN),
1083  _sctrl(sctrl) {
1084  if ((flags & ~(NPOINT | SUM)) != 0x0) {
1086  "Statistics<Mask> only supports NPOINT and SUM");
1087  }
1088 
1089  typedef image::Mask<image::MaskPixel> Mask;
1090 
1091  _n = msk.getWidth() * msk.getHeight();
1092  if (_n == 0) {
1093  throw LSST_EXCEPT(pexExceptions::InvalidParameterError, "Image contains no pixels");
1094  }
1095 
1096  // Check that an int's large enough to hold the number of pixels
1097  assert(msk.getWidth() * static_cast<double>(msk.getHeight()) < std::numeric_limits<int>::max());
1098 
1099  image::MaskPixel sum = 0x0;
1100  for (int y = 0; y != msk.getHeight(); ++y) {
1101  for (Mask::x_iterator ptr = msk.row_begin(y), end = msk.row_end(y); ptr != end; ++ptr) {
1102  sum |= (*ptr)[0];
1103  }
1104  }
1105  _sum = sum;
1106 }

Member Function Documentation

◆ getError()

double lsst::afw::math::Statistics::getError ( Property const  prop = NOTHING) const

Return the error in the desired property (if specified in the constructor)

Parameters
propthe afw::math::Property to retrieve. If NOTHING (default) and you only asked for one property in the constructor, that property's error is returned
Note
You may have needed to specify ERROR to the ctor

Definition at line 1058 of file Statistics.cc.

1058 { return getResult(prop).second; }

◆ getOrMask()

lsst::afw::image::MaskPixel lsst::afw::math::Statistics::getOrMask ( ) const
inlinenoexcept

Definition at line 283 of file Statistics.h.

283 { return _allPixelOrMask; }

◆ getResult()

std::pair< double, double > lsst::afw::math::Statistics::getResult ( Property const  prop = NOTHING) const

Return the value and error in the specified statistic (e.g.

MEAN)

Parameters
propthe afw::math::Property to retrieve. If NOTHING (default) and you only asked for one property (and maybe its error) in the constructor, that property is returned
Note
Only quantities requested in the constructor may be retrieved; in particular errors may not be available if you didn't specify ERROR in the constructor
See also
getValue and getError
Todo:
uncertainties on MEANCLIP,STDEVCLIP are sketchy. _n != _nClip

Definition at line 931 of file Statistics.cc.

931  {
932  // if iProp == NOTHING try to return their heart's delight, as specified in the constructor
933  Property const prop = static_cast<Property>(((iProp == NOTHING) ? _flags : iProp) & ~ERRORS);
934 
935  if (!(prop & _flags)) { // we didn't calculate it
937  (boost::format("You didn't ask me to calculate %d") % prop).str());
938  }
939 
940  Value ret(NaN, NaN);
941  switch (prop) {
942  case NPOINT:
943  ret.first = static_cast<double>(_n);
944  if (_flags & ERRORS) {
945  ret.second = 0;
946  }
947  break;
948 
949  case NCLIPPED:
950  ret.first = static_cast<double>(_nClipped);
951  if (_flags & ERRORS) {
952  ret.second = 0;
953  }
954  break;
955 
956  case NMASKED:
957  ret.first = static_cast<double>(_nMasked);
958  if (_flags & ERRORS) {
959  ret.second = 0;
960  }
961  break;
962 
963  case SUM:
964  ret.first = static_cast<double>(_sum);
965  if (_flags & ERRORS) {
966  ret.second = 0;
967  }
968  break;
969 
970  // == means ==
971  case MEAN:
972  ret.first = _mean.first;
973  if (_flags & ERRORS) {
974  ret.second = ::sqrt(_mean.second);
975  }
976  break;
977  case MEANCLIP:
978  ret.first = _meanclip.first;
979  if (_flags & ERRORS) {
980  ret.second = ::sqrt(_meanclip.second);
981  }
982  break;
983 
984  // == stdevs & variances ==
985  case VARIANCE:
986  ret.first = _variance.first;
987  if (_flags & ERRORS) {
988  ret.second = ::sqrt(_variance.second);
989  }
990  break;
991  case STDEV:
992  ret.first = sqrt(_variance.first);
993  if (_flags & ERRORS) {
994  ret.second = 0.5 * ::sqrt(_variance.second) / ret.first;
995  }
996  break;
997  case VARIANCECLIP:
998  ret.first = _varianceclip.first;
999  if (_flags & ERRORS) {
1000  ret.second = ret.second;
1001  }
1002  break;
1003  case STDEVCLIP:
1004  ret.first = sqrt(_varianceclip.first);
1005  if (_flags & ERRORS) {
1006  ret.second = 0.5 * ::sqrt(_varianceclip.second) / ret.first;
1007  }
1008  break;
1009 
1010  case MEANSQUARE:
1011  ret.first = (_n - 1) / static_cast<double>(_n) * _variance.first + ::pow(_mean.first, 2);
1012  if (_flags & ERRORS) {
1013  ret.second = ::sqrt(2 * ::pow(ret.first / _n, 2)); // assumes Gaussian
1014  }
1015  break;
1016 
1017  // == other stats ==
1018  case MIN:
1019  ret.first = _min;
1020  if (_flags & ERRORS) {
1021  ret.second = 0;
1022  }
1023  break;
1024  case MAX:
1025  ret.first = _max;
1026  if (_flags & ERRORS) {
1027  ret.second = 0;
1028  }
1029  break;
1030  case MEDIAN:
1031  ret.first = _median.first;
1032  if (_flags & ERRORS) {
1033  ret.second = sqrt(geom::HALFPI * _variance.first / _n); // assumes Gaussian
1034  }
1035  break;
1036  case IQRANGE:
1037  ret.first = _iqrange;
1038  if (_flags & ERRORS) {
1039  ret.second = NaN; // we're not estimating this properly
1040  }
1041  break;
1042 
1043  // no-op to satisfy the compiler
1044  case ERRORS:
1045  break;
1046  // default: redundant as 'ret' is initialized to NaN, NaN
1047  default: // we must have set prop to _flags
1048  assert(iProp == 0);
1049  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
1050  "getValue() may only be called without a parameter"
1051  " if you asked for only one statistic");
1052  }
1053  return ret;
1054 }

◆ getValue()

double lsst::afw::math::Statistics::getValue ( Property const  prop = NOTHING) const

Return the value of the desired property (if specified in the constructor)

Parameters
propthe afw::math::Property to retrieve. If NOTHING (default) and you only asked for one property in the constructor, that property is returned

Definition at line 1056 of file Statistics.cc.

1056 { return getResult(prop).first; }

◆ operator=() [1/2]

Statistics& lsst::afw::math::Statistics::operator= ( Statistics &&  )
default

◆ operator=() [2/2]

Statistics& lsst::afw::math::Statistics::operator= ( Statistics const &  )
default

Friends And Related Function Documentation

◆ makeStatistics() [1/10]

template<typename ImageT , typename MaskT , typename VarianceT >
Statistics makeStatistics ( ImageT const &  img,
MaskT const &  msk,
VarianceT const &  var,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

Handle a straight front-end to the constructor.

Definition at line 366 of file Statistics.h.

367  {
368  return Statistics(img, msk, var, flags, sctrl);
369 }

◆ makeStatistics() [2/10]

template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::Image< Pixel > const &  img,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

The makeStatistics() overload to handle regular (non-masked) Images.

Parameters
imgImage (or Image) whose properties we want
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 420 of file Statistics.h.

424  {
425  // make a phony mask that will be compiled out
426  MaskImposter<lsst::afw::image::MaskPixel> const msk;
427  MaskImposter<WeightPixel> const var;
428  return Statistics(img, msk, var, flags, sctrl);
429 }

◆ makeStatistics() [3/10]

template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::Image< Pixel > const &  img,
lsst::afw::image::Mask< image::MaskPixel > const &  msk,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

Handle a watered-down front-end to the constructor (no variance)

Examples
imageStatistics.cc.

Definition at line 354 of file Statistics.h.

356  {
357  MaskImposter<WeightPixel> var;
358  return Statistics(img, msk, var, flags, sctrl);
359 }

◆ makeStatistics() [4/10]

Statistics makeStatistics ( lsst::afw::image::Mask< lsst::afw::image::MaskPixel > const &  msk,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

Specialization to handle Masks.

Parameters
mskImage (or MaskedImage) whose properties we want
flagsDescribe what we want to calculate
sctrlControl how things are calculated

Definition at line 1113 of file Statistics.cc.

1114  {
1115  return Statistics(msk, msk, msk, flags, sctrl);
1116 }

◆ makeStatistics() [5/10]

template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::MaskedImage< Pixel > const &  mimg,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

Handle MaskedImages, just pass the getImage() and getMask() values right on through.

Definition at line 376 of file Statistics.h.

377  {
378  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
379  return Statistics(*mimg.getImage(), *mimg.getMask(), *mimg.getVariance(), flags, sctrl);
380  } else {
381  MaskImposter<WeightPixel> var;
382  return Statistics(*mimg.getImage(), *mimg.getMask(), var, flags, sctrl);
383  }
384 }

◆ makeStatistics() [6/10]

template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::MaskedImage< Pixel > const &  mimg,
lsst::afw::image::Image< WeightPixel > const &  weights,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

Handle MaskedImages, just pass the getImage() and getMask() values right on through.

Definition at line 391 of file Statistics.h.

393  {
394  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance() ||
395  (!sctrl.getWeightedIsSet() && (weights.getWidth() != 0 && weights.getHeight() != 0))) {
396  return Statistics(*mimg.getImage(), *mimg.getMask(), *mimg.getVariance(), weights, flags, sctrl);
397  } else {
398  MaskImposter<WeightPixel> var;
399  return Statistics(*mimg.getImage(), *mimg.getMask(), var, weights, flags, sctrl);
400  }
401 }

◆ makeStatistics() [7/10]

template<typename EntryT >
Statistics makeStatistics ( lsst::afw::math::MaskedVector< EntryT > const &  mv,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

The makeStatistics() overload to handle lsst::afw::math::MaskedVector<>

Parameters
mvMaskedVector
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 503 of file Statistics.h.

506  {
507  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
508  return Statistics(*mv.getImage(), *mv.getMask(), *mv.getVariance(), flags, sctrl);
509  } else {
510  MaskImposter<WeightPixel> var;
511  return Statistics(*mv.getImage(), *mv.getMask(), var, flags, sctrl);
512  }
513 }

◆ makeStatistics() [8/10]

template<typename EntryT >
Statistics makeStatistics ( lsst::afw::math::MaskedVector< EntryT > const &  mv,
std::vector< WeightPixel > const &  vweights,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

The makeStatistics() overload to handle lsst::afw::math::MaskedVector<>

Parameters
mvMaskedVector
vweightsweights
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 520 of file Statistics.h.

524  {
525  ImageImposter<WeightPixel> weights(vweights);
526 
527  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
528  return Statistics(*mv.getImage(), *mv.getMask(), *mv.getVariance(), weights, flags, sctrl);
529  } else {
530  MaskImposter<WeightPixel> var;
531  return Statistics(*mv.getImage(), *mv.getMask(), var, weights, flags, sctrl);
532  }
533 }

◆ makeStatistics() [9/10]

template<typename EntryT >
Statistics makeStatistics ( std::vector< EntryT > const &  v,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

The makeStatistics() overload to handle std::vector<>

Parameters
vImage (or MaskedImage) whose properties we want
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 469 of file Statistics.h.

472  {
473  ImageImposter<EntryT> img(v); // wrap the vector in a fake image
474  MaskImposter<lsst::afw::image::MaskPixel> msk; // instantiate a fake mask that will be compiled out.
475  MaskImposter<WeightPixel> var;
476  return Statistics(img, msk, var, flags, sctrl);
477 }

◆ makeStatistics() [10/10]

template<typename EntryT >
Statistics makeStatistics ( std::vector< EntryT > const &  v,
std::vector< WeightPixel > const &  vweights,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

The makeStatistics() overload to handle std::vector<>

Parameters
vImage (or MaskedImage) whose properties we want
vweightsWeights
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 484 of file Statistics.h.

488  {
489  ImageImposter<EntryT> img(v); // wrap the vector in a fake image
490  MaskImposter<lsst::afw::image::MaskPixel> msk; // instantiate a fake mask that will be compiled out.
491  MaskImposter<WeightPixel> var;
492 
493  ImageImposter<WeightPixel> weights(vweights);
494 
495  return Statistics(img, msk, var, weights, flags, sctrl);
496 }

The documentation for this class was generated from the following files:
y
int y
Definition: SpanSet.cc:49
lsst::afw::math::IQRANGE
@ IQRANGE
estimate sample inter-quartile range
Definition: Statistics.h:71
lsst::afw::math::MaskedVector::getMask
lsst::afw::image::MaskedImage< EntryT >::MaskPtr getMask() const
Definition: MaskedVector.h:91
lsst::afw::image::Mask
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:77
lsst::afw::math::StatisticsControl::setWeighted
void setWeighted(bool useWeights) noexcept
Definition: Statistics.h:153
lsst::afw::image::ImageBase< lsst::afw::image::MaskPixel >::row_begin
x_iterator row_begin(int y) const
Return an x_iterator to the start of the y'th row.
Definition: ImageBase.h:399
lsst.pex.config.history.format
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
lsst::afw::image::ImageBase< lsst::afw::image::MaskPixel >::getHeight
int getHeight() const
Return the number of rows in the image.
Definition: ImageBase.h:296
lsst::afw::math::StatisticsControl::getWeightedIsSet
bool getWeightedIsSet() const noexcept
Definition: Statistics.h:139
std::sqrt
T sqrt(T... args)
end
int end
Definition: BoundedField.cc:105
lsst::afw::math::Statistics::getResult
Value getResult(Property const prop=NOTHING) const
Return the value and error in the specified statistic (e.g.
Definition: Statistics.cc:931
lsst::afw::math::MEANCLIP
@ MEANCLIP
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
Definition: Statistics.h:72
lsst::afw::math::VARIANCECLIP
@ VARIANCECLIP
estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)
Definition: Statistics.h:74
lsst::afw::math::MEAN
@ MEAN
estimate sample mean
Definition: Statistics.h:67
lsst::afw::math::STDEVCLIP
@ STDEVCLIP
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
Definition: Statistics.h:73
lsst::afw::image::ImageBase< lsst::afw::image::MaskPixel >::row_end
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
Definition: ImageBase.h:402
lsst::afw::math::NCLIPPED
@ NCLIPPED
number of clipped points
Definition: Statistics.h:81
ptr
uint64_t * ptr
Definition: RangeSet.cc:88
std::int32_t
lsst::afw::math::ERRORS
@ ERRORS
Include errors of requested quantities.
Definition: Statistics.h:65
lsst::afw::image::MaskedImage::getVariance
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
Definition: MaskedImage.h:1079
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::afw::math::Statistics::Value
std::pair< double, double > Value
The type used to report (value, error) for desired statistics.
Definition: Statistics.h:218
lsst::afw::math::MEANSQUARE
@ MEANSQUARE
find mean value of square of pixel values
Definition: Statistics.h:79
lsst::afw::math::StatisticsControl::getWeighted
bool getWeighted() const noexcept
Definition: Statistics.h:138
lsst::afw::math::NPOINT
@ NPOINT
number of sample points
Definition: Statistics.h:66
lsst.pex::exceptions::InvalidParameterError
Reports invalid arguments.
Definition: Runtime.h:66
lsst::afw::math::STDEV
@ STDEV
estimate sample standard deviation
Definition: Statistics.h:68
lsst::afw::math::MaskedVector::getImage
lsst::afw::image::MaskedImage< EntryT >::ImagePtr getImage() const
Definition: MaskedVector.h:88
lsst::afw::math::Statistics::Statistics
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:773
lsst::afw::math::MIN
@ MIN
estimate sample minimum
Definition: Statistics.h:76
lsst::afw::math::MaskedVector::getVariance
lsst::afw::image::MaskedImage< EntryT >::VariancePtr getVariance() const
Definition: MaskedVector.h:94
lsst::afw::image::MaskedImage::getImage
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
Definition: MaskedImage.h:1046
lsst::afw::math::MAX
@ MAX
estimate sample maximum
Definition: Statistics.h:77
lsst::afw::math::VARIANCE
@ VARIANCE
estimate sample variance
Definition: Statistics.h:69
lsst::afw::math::Property
Property
control what is calculated
Definition: Statistics.h:63
lsst::afw::math::NOTHING
@ NOTHING
We don't want anything.
Definition: Statistics.h:64
lsst::afw::image::MaskedImage::getMask
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
Definition: MaskedImage.h:1058
lsst.obs.base.makeRawVisitInfo.NaN
NaN
Definition: makeRawVisitInfo.py:43
std::numeric_limits
lsst::afw::math::SUM
@ SUM
find sum of pixels in the image
Definition: Statistics.h:78
lsst::afw::math::NMASKED
@ NMASKED
number of masked points
Definition: Statistics.h:82
lsst::geom::HALFPI
constexpr double HALFPI
Definition: Angle.h:41
lsst::afw::image::ImageBase< lsst::afw::image::MaskPixel >::getWidth
int getWidth() const
Return the number of columns in the image.
Definition: ImageBase.h:294
lsst::afw::math::MEDIAN
@ MEDIAN
estimate sample median
Definition: Statistics.h:70
std::pow
T pow(T... args)