Go to the documentation of this file.
28 #ifndef LATTICES_LATTICESTATISTICS_H
29 #define LATTICES_LATTICESTATISTICS_H
31 #include <casacore/casa/aips.h>
32 #include <casacore/casa/Arrays/Array.h>
33 #include <casacore/casa/Containers/Block.h>
34 #include <casacore/casa/Arrays/Vector.h>
35 #include <casacore/casa/Containers/Record.h>
36 #include <casacore/lattices/LatticeMath/LatticeStatsBase.h>
37 #include <casacore/lattices/LatticeMath/TiledCollapser.h>
38 #include <casacore/lattices/LatticeMath/TiledCollapser.h>
39 #include <casacore/lattices/LEL/LatticeExprNode.h>
40 #include <casacore/lattices/LatticeMath/LatticeStatsDataProvider.h>
41 #include <casacore/lattices/LatticeMath/MaskedLatticeStatsDataProvider.h>
42 #include <casacore/scimath/Mathematics/NumericTraits.h>
43 #include <casacore/casa/Utilities/DataType.h>
44 #include <casacore/casa/BasicSL/String.h>
45 #include <casacore/casa/Logging/LogIO.h>
46 #include <casacore/scimath/StatsFramework/FitToHalfStatisticsData.h>
47 #include <casacore/scimath/StatsFramework/StatisticsData.h>
48 #include <casacore/scimath/StatsFramework/StatisticsAlgorithm.h>
49 #include <casacore/scimath/StatsFramework/StatisticsAlgorithmFactory.h>
57 template <
class T>
class MaskedLattice;
58 template <
class T>
class SubLattice;
59 template <
class T>
class TempLattice;
62 #include <casacore/casa/iosstrfwd.h>
284 Int zAxis=-1,
Int zLayer=-1,
285 Int hAxis=-1,
Int hLayer=-1);
290 Int zAxis=-1,
Int zLayer=-1,
291 Int hAxis=-1,
Int hLayer=-1);
455 ThrowCc(
"Logic Error: This object cannot compute flux density");
459 ostringstream& osMax,
460 Int oWidth, DataType type);
479 ostringstream& rslt,
Int zLayer);
572 template <
class U,
class V>
579 template <
class U,
class V>
610 const Bool posInLattice);
649 >& sa, T& overallMin, T& overallMax,
IPosition& arrayShape,
651 std::vector<
Array<Bool> >& maskArray, std::vector<IPosition>& curPos,
657 T currentMin, T currentMax,
const IPosition& curPos,
663 return npts <= 0 ? 0 :
sum/npts;
667 return npts <= 0 ? 0 :
sqrt(sumsq/npts);
671 T& overallMin, T& overallMax, T currentMin, T currentMax,
684 #ifndef CASACORE_NO_AUTO_TEMPLATES
685 #include <casacore/lattices/LatticeMath/LatticeStatistics.tcc>
686 #endif //# CASACORE_NO_AUTO_TEMPLATES
const MaskedLattice< T > * pInLattice_p
void resetError()
Reset argument error condition.
IPosition locInLattice(const IPosition &storagePosition, Bool relativeToParent=True) const
Given a location in the storage lattice, convert those locations on the non-statistics axis (the la...
void forceUseOldTiledApplyMethod()
static AccumType _mean(const AccumType &sum, const AccumType &npts)
Specify which elements to extract from an n-dimensional array.
Vector< Int > displayAxes() const
Return the display axes.
void setComputeQuantiles(Bool b)
should quantile-like stats (median, quartiles, medabsdevmed) be computed? When the stats framework is...
A 2-D Specialization of the Array class.
LatticeStatistics(const MaskedLattice< T > &lattice, Bool showProgress=True, Bool forceDisk=False, Bool clone=True)
Constructor takes the lattice only.
A Vector of integers, for indexing into Array<T> objects.
void _doComputationUsingArrays(std::vector< CountedPtr< StatisticsAlgorithm< AccumType, typename Array< T >::const_iterator, Array< Bool >::const_iterator > > > &sa, T &overallMin, T &overallMax, IPosition &arrayShape, std::vector< Array< T > > &dataArray, std::vector< Array< Bool > > &maskArray, std::vector< IPosition > &curPos, uInt nthreads, const SubLattice< T > &subLat, Bool isChauv, Bool isMasked, Bool isReal, CountedPtr< const DataRanges > range)
Bool retrieveStorageStatistic(Array< AccumType > &slice, const LatticeStatsBase::StatisticsTypes type, const Bool dropDeg)
Retrieve a statistic from the storage lattice and return in an array.
Bool getMinMaxPos(IPosition &minPos, IPosition &maxPos)
Recover position of min and max.
LatticeStatistics(const LatticeStatistics< T > &other)
Copy constructor.
void forceUseStatsFrameworkUsingArrays()
A templated, abstract base class for array-like objects with masks.
Bool configureClassical()
configure object to use Classical Statistics The time, t_x, it takes to compute classical statistics ...
StatisticsTypes
This enum StatisticTypes is provided for use with the LatticeStatistics<T>::setPlotting function.
ALGORITHM
implemented algorithms
virtual Bool listLayerStats(const Matrix< AccumType > &ord, ostringstream &rslt, Int zLayer)
Vector< Int > displayAxes_p
A subset of a Lattice or MaskedLattice.
Referenced counted pointer for constant data.
std::map< String, uInt > _chauvIters
std::pair< String, String > stat_element
std::shared_ptr< const MaskedLattice< T > > _inLatPtrMgr
virtual ~LatticeStatistics()
Destructor.
Bool getFullMinMax(T &dataMin, T &dataMax)
Get full lattice min and max only.
Bool setNewLattice(const MaskedLattice< T > &lattice, Bool clone=True)
Set a new MaskedLattice object.
virtual Bool _canDoFlux() const
Virtual Functions.
IPosition statsSliceShape() const
Find the shape of slice from the statistics lattice at one spatial pixel.
void _doStatsLoop(uInt nsets, CountedPtr< LattStatsProgress > progressMeter)
LatticeExprNode sqrt(const LatticeExprNode &expr)
USE_DATA
which section of data to use, greater than or less than the center value
Bool hasLogger() const
Did we construct with a logger ?
virtual Bool _computeFlux(Quantum< AccumType > &flux, AccumType sum, const IPosition &pos, Bool posInLattice)
LatticeExprNode mean(const LatticeExprNode &expr)
Base class of statistics algorithm class hierarchy.
Bool getStatistic(Array< AccumType > &stat, LatticeStatsBase::StatisticsTypes type, Bool dropDeg=True)
Recover the desired Statistic into an array.
void minMax(Bool &none, AccumType &dMin, AccumType &dMax, const Vector< AccumType > &d, const Vector< AccumType > &n) const
Find min and max of good data in arrays specified by pointers.
Bool someGoodPoints()
See if there were some valid points found in the storage lattice.
std::list< stat_element > stat_list
Char PrecisionType
Higher precision type (Float->Double)
Data provider which allows stats framework to iterate through an unmasked lattice.
ostream-like interface to creating log messages.
Bool calculateStatistic(Array< AccumType > &slice, LatticeStatsBase::StatisticsTypes type, Bool dropDeg)
Calculate statistic from storage lattice and return in an array.
Bool doRobust_p
doRobust means that when the storage lattice is generated, the robust statistics are generated as wel...
Bool setList(const Bool &doList)
This function allows you to control whether the statistics are written to the output stream if you ar...
Bool doneSomeGoodPoints_p
Bool getLayerStats(stat_list &stats, Double area, Int zAxis=-1, Int zLayer=-1, Int hAxis=-1, Int hLayer=-1)
LatticeStatistics< T > & operator=(const LatticeStatistics< T > &other)
Assignment operator.
Bool display()
Display the statistics by listing and/or plotting them.
void _latticePosToStoragePos(IPosition &storagePos, const IPosition &latticePos)
convert a position in the input lattice to the corresponding position in the stats storage lattice.
void setStream(ostream &os, Int oPrec)
Non-virtual functions.
Bool configureHingesFences(Double f)
configure to use hinges-fences algorithm
void _fillStorageLattice(T currentMin, T currentMax, const IPosition &curPos, const StatsData< AccumType > &stats, Bool doQuantiles, AccumType q1=0, AccumType q3=0)
void _updateMinMaxPos(T &overallMin, T &overallMax, T currentMin, T currentMax, const IPosition &minPos, const IPosition &maxPos, Bool atStart, const SubLattice< T > &subLat)
Data provider which allows stats framework to iterate through a masked lattice.
std::map< String, uInt > getChauvenetNiter() const
get number of iterations associated with Chauvenet criterion algorithm
void _computeStatsUsingArrays(SubLattice< T > subLat, CountedPtr< LattStatsProgress > progressMeter, const IPosition &cursorShape)
void _computeStatsUsingLattDataProviders(LatticeStepper &stepper, SubLattice< T > subLat, Slicer &slicer, CountedPtr< LattStatsProgress > progressMeter, uInt nsets)
IPosition _storageLatticeShape() const
get the storage lattice shape
LatticeStatistics(const MaskedLattice< T > &lattice, LogIO &os, Bool showProgress=True, Bool forceDisk=False, Bool clone=True)
Constructor takes the lattice and a LogIO object for logging.
void _computeQuantiles(AccumType &median, AccumType &medAbsDevMed, AccumType &q1, AccumType &q3, CountedPtr< StatisticsAlgorithm< AccumType, U, V > > statsAlg, uInt64 knownNpts, AccumType knownMin, AccumType knownMax) const
@ STATS_FRAMEWORK_DATA_PROVIDERS
Bool needStorageLattice_p
CENTER
choice of center point based on the corresponding statistics from the entire distribution of data,...
Bool retrieveStorageStatistic(Vector< AccumType > &slice, const IPosition &pos, const Bool posInLattice)
Retrieve a statistic from the storage lattice at the specified location and return in an array.
void generateRobust()
Find the median per cursorAxes chunk.
virtual void summStats()
Summarize the statistics found over the entire lattice.
void _computeQuantilesForStatsFramework(StatsData< AccumType > &stats, AccumType &q1, AccumType &q3, CountedPtr< StatisticsAlgorithm< AccumType, U, V > > statsAlg) const
Bool getLayerStats(String &stats, Double area, Int zAxis=-1, Int zLayer=-1, Int hAxis=-1, Int hLayer=-1)
Bool setAxes(const Vector< Int > &cursorAxes)
Set the cursor axes (0 relative).
this file contains all the compiler specific defines
Bool configureClassical(Double aOld, Double bOld, Double aNew, Double bNew)
Vector< Int > cursorAxes_p
LatticeExprNode median(const LatticeExprNode &expr)
const Double c
Fundamental physical constants (SI units):
virtual Quantum< AccumType > _flux(Bool &, AccumType, Double) const
Compute and display various statistics from a lattice.
Bool getStats(Vector< AccumType > &, const IPosition &pos, const Bool posInLattice=False)
This function gets a vector containing all the statistics for a given location.
void stretchMinMax(AccumType &dMin, AccumType &dMax) const
Stretch min and max by 5%.
Bool setInExCludeRange(const Vector< T > &include, const Vector< T > &exclude, Bool setMinMaxToInclude=False)
You may specify a pixel intensity range as either one for which all pixels in that range are included...
IPosition locInStorageLattice(const IPosition &latticePosition, LatticeStatsBase::StatisticsTypes type) const
Given a location in the lattice and a statistic type, work out where to put it in the storage lattice...
Bool someGoodPointsValue_p
IPosition _cursorShapeForArrayMethod(uInt64 setSize) const
String errorMessage() const
Recover last error message.
virtual void displayStats(AccumType nPts, AccumType sum, AccumType median, AccumType medAbsDevMed, AccumType quartile, AccumType sumSq, AccumType mean, AccumType var, AccumType rms, AccumType sigma, AccumType dMin, AccumType dMax, AccumType q1, AccumType q3)
virtual Bool _computeFlux(Array< AccumType > &flux, const Array< AccumType > &npts, const Array< AccumType > &sum)
Bool getConvertedStatistic(Array< T > &stat, LatticeStatsBase::StatisticsTypes type, Bool dropDeg=True)
StatisticsData::ALGORITHM _getAlgorithm() const
Traverse a Lattice by cursor shape.
template <class T, class U> class vector;
static AccumType _rms(const AccumType &sumsq, const AccumType &npts)
LatticeExprNode sum(const LatticeExprNode &expr)
NumericTraits< T >::PrecisionType AccumType
Bool configureBiweight(Int maxIter, Double c)
The configure methods return True if reconfiguration is actually necessary (ie if the underlying stor...
virtual void listMinMax(ostringstream &osMin, ostringstream &osMax, Int oWidth, DataType type)
String: the storage and methods of handling collections of characters.
bool Bool
Define the standard types used by Casacore.
void forceAllowCodeDecideWhichAlgortihmToUse()
TableExprNode rms(const TableExprNode &array)
Vector< Int > statsToPlot_p
void _configureDataProviders(LatticeStatsDataProvider< T > &lattDP, MaskedLatticeStatsDataProvider< T > &maskedLattDP) const
PtrHolder< LatticeStatsAlgorithm > _latticeStatsAlgortihm
unset means let the code decide
Bool generateStorageLattice()
Create a new storage lattice.
Bool goodParameterStatus_p
StatisticsAlgorithmFactory< AccumType, const T *, const Bool * > _saf
void forceUseStatsFrameworkUsingDataProviders()
The force* methods are really only for testing.
CountedPtr< TempLattice< AccumType > > pStoreLattice_p
Quantities (i.e. dimensioned values)
Bool configureFitToHalf(FitToHalfStatisticsData::CENTER centerType=FitToHalfStatisticsData::CMEAN, FitToHalfStatisticsData::USE_DATA useData=FitToHalfStatisticsData::LE_CENTER, AccumType centerValue=0)
configure to use fit to half algorithm.
Bool configureChauvenet(Double zscore=-1, Int maxIterations=-1)
configure to use Chauvenet's criterion
virtual Bool listStats(Bool hasBeam, const IPosition &dPos, const Matrix< AccumType > &ord)
List the statistics to the logger.
unsigned long long uInt64
Base class for LatticeStatistics class.