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>
Referenced counted pointer for constant data.
USE_DATA
which section of data to use, greater than or less than the center value
CENTER
choice of center point based on the corresponding statistics from the entire distribution of data,...
Bool goodParameterStatus_p
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.
Bool someGoodPoints()
See if there were some valid points found in the storage lattice.
Vector< Int > displayAxes_p
virtual Quantum< AccumType > _flux(Bool &, AccumType, Double) const
void _fillStorageLattice(T currentMin, T currentMax, const IPosition &curPos, const StatsData< AccumType > &stats, Bool doQuantiles, AccumType q1=0, AccumType q3=0)
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 getLayerStats(String &stats, Double area, Int zAxis=-1, Int zLayer=-1, Int hAxis=-1, Int hLayer=-1)
std::map< String, uInt > _chauvIters
Bool doRobust_p
doRobust means that when the storage lattice is generated, the robust statistics are generated as wel...
Bool configureHingesFences(Double f)
configure to use hinges-fences algorithm
static AccumType _mean(const AccumType &sum, const AccumType &npts)
virtual Bool listLayerStats(const Matrix< AccumType > &ord, ostringstream &rslt, Int zLayer)
Vector< Int > cursorAxes_p
void forceAllowCodeDecideWhichAlgortihmToUse()
virtual ~LatticeStatistics()
Destructor.
virtual Bool _computeFlux(Array< AccumType > &flux, const Array< AccumType > &npts, const Array< AccumType > &sum)
Bool configureClassical(Double aOld, Double bOld, Double aNew, Double bNew)
std::map< String, uInt > getChauvenetNiter() const
get number of iterations associated with Chauvenet criterion algorithm
void setComputeQuantiles(Bool b)
should quantile-like stats (median, quartiles, medabsdevmed) be computed? When the stats framework is...
Bool display()
Display the statistics by listing and/or plotting them.
std::list< stat_element > stat_list
void _doStatsLoop(uInt nsets, CountedPtr< LattStatsProgress > progressMeter)
virtual void summStats()
Summarize the statistics found over the entire lattice.
void _computeStatsUsingArrays(SubLattice< T > subLat, CountedPtr< LattStatsProgress > progressMeter, const IPosition &cursorShape)
StatisticsAlgorithmFactory< AccumType, const T *, const Bool * > _saf
Bool setAxes(const Vector< Int > &cursorAxes)
Set the cursor axes (0 relative).
void _updateMinMaxPos(T &overallMin, T &overallMax, T currentMin, T currentMax, const IPosition &minPos, const IPosition &maxPos, Bool atStart, const SubLattice< T > &subLat)
Bool retrieveStorageStatistic(Array< AccumType > &slice, const LatticeStatsBase::StatisticsTypes type, const Bool dropDeg)
Retrieve a statistic from the storage lattice and return in an array.
CountedPtr< TempLattice< AccumType > > pStoreLattice_p
NumericTraits< T >::PrecisionType AccumType
StatisticsData::ALGORITHM _getAlgorithm() const
const MaskedLattice< T > * pInLattice_p
Vector< Int > displayAxes() const
Return the display axes.
Bool someGoodPointsValue_p
void _computeQuantilesForStatsFramework(StatsData< AccumType > &stats, AccumType &q1, AccumType &q3, CountedPtr< StatisticsAlgorithm< AccumType, U, V > > statsAlg) const
Bool configureFitToHalf(FitToHalfStatisticsData::CENTER centerType=FitToHalfStatisticsData::CMEAN, FitToHalfStatisticsData::USE_DATA useData=FitToHalfStatisticsData::LE_CENTER, AccumType centerValue=0)
configure to use fit to half algorithm.
void resetError()
Reset argument error condition.
Bool getFullMinMax(T &dataMin, T &dataMax)
Get full lattice min and max only.
@ STATS_FRAMEWORK_DATA_PROVIDERS
Bool configureBiweight(Int maxIter, Double c)
The configure methods return True if reconfiguration is actually necessary (ie if the underlying stor...
virtual Bool _computeFlux(Quantum< AccumType > &flux, AccumType sum, const IPosition &pos, Bool posInLattice)
static AccumType _rms(const AccumType &sumsq, const AccumType &npts)
Bool setList(const Bool &doList)
This function allows you to control whether the statistics are written to the output stream if you ar...
Bool getMinMaxPos(IPosition &minPos, IPosition &maxPos)
Recover position of min and max.
void _computeStatsUsingLattDataProviders(LatticeStepper &stepper, SubLattice< T > subLat, Slicer &slicer, CountedPtr< LattStatsProgress > progressMeter, uInt nsets)
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 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...
Vector< Int > statsToPlot_p
String errorMessage() const
Recover last error message.
Bool setNewLattice(const MaskedLattice< T > &lattice, Bool clone=True)
Set a new MaskedLattice object.
void _configureDataProviders(LatticeStatsDataProvider< T > &lattDP, MaskedLatticeStatsDataProvider< T > &maskedLattDP) const
PtrHolder< LatticeStatsAlgorithm > _latticeStatsAlgortihm
unset means let the code decide
Bool configureChauvenet(Double zscore=-1, Int maxIterations=-1)
configure to use Chauvenet's criterion
void stretchMinMax(AccumType &dMin, AccumType &dMax) const
Stretch min and max by 5%.
void forceUseStatsFrameworkUsingDataProviders()
The force* methods are really only for testing.
IPosition statsSliceShape() const
Find the shape of slice from the statistics lattice at one spatial pixel.
std::pair< String, String > stat_element
LatticeStatistics(const MaskedLattice< T > &lattice, Bool showProgress=True, Bool forceDisk=False, Bool clone=True)
Constructor takes the lattice only.
Bool hasLogger() const
Did we construct with a logger ?
virtual Bool listStats(Bool hasBeam, const IPosition &dPos, const Matrix< AccumType > &ord)
List the statistics to the logger.
Bool calculateStatistic(Array< AccumType > &slice, LatticeStatsBase::StatisticsTypes type, Bool dropDeg)
Calculate statistic from storage lattice and return in an array.
std::shared_ptr< const MaskedLattice< T > > _inLatPtrMgr
Bool needStorageLattice_p
Bool getStats(Vector< AccumType > &, const IPosition &pos, const Bool posInLattice=False)
This function gets a vector containing all the statistics for a given location.
LatticeStatistics(const LatticeStatistics< T > &other)
Copy constructor.
void _latticePosToStoragePos(IPosition &storagePos, const IPosition &latticePos)
convert a position in the input lattice to the corresponding position in the stats storage lattice.
LatticeStatistics< T > & operator=(const LatticeStatistics< T > &other)
Assignment operator.
virtual Bool _canDoFlux() const
Virtual Functions.
virtual void listMinMax(ostringstream &osMin, ostringstream &osMax, Int oWidth, DataType type)
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.
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)
Bool getStatistic(Array< AccumType > &stat, LatticeStatsBase::StatisticsTypes type, Bool dropDeg=True)
Recover the desired Statistic into an array.
IPosition _cursorShapeForArrayMethod(uInt64 setSize) const
void forceUseOldTiledApplyMethod()
IPosition _storageLatticeShape() const
get the storage lattice shape
Bool configureClassical()
configure object to use Classical Statistics The time, t_x, it takes to compute classical statistics ...
void _computeQuantiles(AccumType &median, AccumType &medAbsDevMed, AccumType &q1, AccumType &q3, CountedPtr< StatisticsAlgorithm< AccumType, U, V > > statsAlg, uInt64 knownNpts, AccumType knownMin, AccumType knownMax) const
Bool getLayerStats(stat_list &stats, Double area, Int zAxis=-1, Int zLayer=-1, Int hAxis=-1, Int hLayer=-1)
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)
void generateRobust()
Find the median per cursorAxes chunk.
Bool getConvertedStatistic(Array< T > &stat, LatticeStatsBase::StatisticsTypes type, Bool dropDeg=True)
Bool doneSomeGoodPoints_p
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.
void forceUseStatsFrameworkUsingArrays()
Bool generateStorageLattice()
Create a new storage lattice.
void setStream(ostream &os, Int oPrec)
Non-virtual functions.
StatisticsTypes
This enum StatisticTypes is provided for use with the LatticeStatistics<T>::setPlotting function.
Data provider which allows stats framework to iterate through an unmasked lattice.
Data provider which allows stats framework to iterate through a masked lattice.
Char PrecisionType
Higher precision type (Float->Double)
Base class of statistics algorithm class hierarchy.
ALGORITHM
implemented algorithms
String: the storage and methods of handling collections of characters.
const Double c
Fundamental physical constants (SI units):
this file contains all the compiler specific defines
LatticeExprNode mean(const LatticeExprNode &expr)
LatticeExprNode sum(const LatticeExprNode &expr)
LatticeExprNode sqrt(const LatticeExprNode &expr)
bool Bool
Define the standard types used by Casacore.
LatticeExprNode median(const LatticeExprNode &expr)
unsigned long long uInt64
TableExprNode rms(const TableExprNode &array)