LatticeStatistics.h

Go to the documentation of this file.
00001 //# LatticeStatistics.h: generate statistics from a Lattice
00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 
00028 #ifndef LATTICES_LATTICESTATISTICS_H
00029 #define LATTICES_LATTICESTATISTICS_H
00030 
00031 #include <casacore/casa/aips.h>
00032 #include <casacore/casa/Arrays/Array.h>
00033 #include <casacore/casa/Containers/Block.h>
00034 #include <casacore/casa/Arrays/Vector.h>
00035 #include <casacore/casa/Containers/Record.h>
00036 #include <casacore/lattices/LatticeMath/LatticeStatsBase.h>
00037 #include <casacore/lattices/LatticeMath/TiledCollapser.h>
00038 #include <casacore/lattices/LatticeMath/TiledCollapser.h>
00039 #include <casacore/lattices/LEL/LatticeExprNode.h>
00040 #include <casacore/lattices/LatticeMath/LatticeStatsDataProvider.h>
00041 #include <casacore/lattices/LatticeMath/MaskedLatticeStatsDataProvider.h>
00042 #include <casacore/scimath/Mathematics/NumericTraits.h>
00043 #include <casacore/casa/Utilities/DataType.h>
00044 #include <casacore/casa/BasicSL/String.h>
00045 #include <casacore/casa/Logging/LogIO.h>
00046 #include <casacore/scimath/Mathematics/FitToHalfStatisticsData.h>
00047 #include <casacore/scimath/Mathematics/StatisticsData.h>
00048 #include <casacore/scimath/Mathematics/StatisticsAlgorithm.h>
00049 #include <vector>
00050 #include <list>
00051 
00052 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00053 
00054 //# Forward Declarations
00055 template <class T> class MaskedLattice;
00056 template <class T> class TempLattice;
00057 class IPosition;
00058 
00059 #include <casacore/casa/iosstrfwd.h>
00060 
00061 
00062 // <summary>
00063 // Compute and display various statistics from a lattice
00064 // </summary>
00065 // <use visibility=export>
00066 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00067 // </reviewed>
00068 // <prerequisite>
00069 //   <li> <linkto class=LatticeStatsBase>LatticeStatsBase</linkto>
00070 //   <li> <linkto class=MaskedLattice>MaskedLattice</linkto>
00071 // </prerequisite>
00072 
00073 // <etymology>
00074 // This is a class designed to display and retrieve statistics from lattices
00075 // </etymology>
00076 
00077 // <synopsis>
00078 // This class enable you to display and/or retrieve statistics evaluated over 
00079 // specified regions of a lattice.  The dimension of the region is arbitrary, but 
00080 // the size of each dimension is always the shape of the corresponding lattice axis.
00081 // The statistics are displayed as a function of location of the axes not
00082 // used to evaluate the statistics over.  The axes which you evaluate the statistics
00083 // over are called the cursor axes, the others are called the display axes.
00084 //
00085 // For example, consider a lattice cube (call the axes xyz or [0,1,2]).  You could 
00086 // display statistics from xy planes (cursor axes [0,1]) as a function of z (display
00087 // axes [2]).   Or  you could retrieve statistics from the z axis (cursor axes [2])
00088 // for each [x,y] location (display axes [0,1]).
00089 //
00090 // This class inherits from  <linkto class="LatticeStatsBase">LatticeStatsBase</linkto> 
00091 // This base class provides an <src>enum</src> defining allowed statistics types and a 
00092 // helper function to convert between a <src>String</src> and a 
00093 // <src>Vector<Int></src> describing  the desired statistics to plot.  
00094 // An example is shown below.
00095 //
00096 // This class can list, plot and retrieve statistics.  When it lists statistics,
00097 // it always lists all the available statistics.  When you plot statistics,
00098 // you must specify which ones you would like to see.
00099 //
00100 // This class generates a "storage lattice" into which it writes the accumulated
00101 // statistical sums.  It is from this storage lattice that the plotting and retrieval
00102 // arrays are drawn.  The storage lattice is either in core or on disk 
00103 // depending upon its size (if > 10% of memory given by .aipsrc system.resources.memory
00104 // then it goes into a disk-based PagedArray).  If on disk,  the
00105 // storage lattice is deleted when the <src>LatticeStatistics</src> class 
00106 // object destructs.    However, currently, if the process is terminated ungracefully,
00107 // the storage lattice will be left over.  
00108 // </synopsis>
00109 //
00110 // <note role=tip>
00111 // This class has a few virtual functions; they are not part of a nice general
00112 // polymorphic interface; rather they have specialized functionality.  The idea 
00113 // of these is that you can derive a class from LatticeStatistics, such as 
00114 // <linkto class="ImageStatistics">ImageStatistics</linkto> which provides
00115 // you with a little more information when displaying/logging the 
00116 // statistics (such as world coordinates)
00117 // The virtual functions are
00118 // <ul>
00119 // <li> <src>getBeamArea</src> can be used to return the synthesized beam
00120 //    area so that the FLUX statistic can be computed
00121 // <li> <src>listStats</src> is used to list the statistics to the logger
00122 // <li> <src>getLabelsM</src> find the X-axis label and the title label
00123 //     for the plotting.   
00124 // </ul>
00125 // </note>
00126 //
00127 // <note role=tip>
00128 // If you ignore return error statuses from the functions that set the
00129 // state of the class, the internal status of the class is set to bad.
00130 // This means it will just  keep on returning error conditions until you
00131 // explicitly recover the situation.  A message describing the last
00132 // error condition can be recovered with function errorMessage.
00133 // </note>
00134 
00135 
00136 // <example>
00137 // <srcBlock>
00139 //
00140 //      PagedImage<Float> inImage(inName);
00141 //   
00143 //      
00144 //      LogOrigin or("myClass", "myFunction(...)", WHERE);
00145 //      LogIO os(or);
00146 //      LatticeStatistics<Float> stats(SubImage<FLoat>(inImage), os);
00147 //      
00149 //
00150 //      Vector<Int> cursorAxes(2)
00151 //      cursorAxes(0) = 1;
00152 //      cursorAxes(1) = 2;
00153 //      if (!stats.setAxes(cursorAxes)) return 1;
00154 //
00156 //
00157 //      if (!stats.setList(True)) return 1;
00158 //      String device = "/xs";
00159 //      Vector<Int> nxy(2);
00160 //      nxy(0) = 1;
00161 //      nxy(1) = 1;
00162 //      Vector<Int> statsToPlot = LatticeStatsBase::toStatisticTypes("mean,rms,sigma");
00163 //      if (!stats.setPlotting(statsToPlot, device, nxy)) return 1;
00164 // 
00166 // 
00167 //      if (!stats.display ()) return 1;
00168 //
00170 //
00171 //      Array<Double> sum;
00172 //      if (!stats.getStatistic(sum, LatticeStatsBase::SUM)) return 1;
00173 //
00174 // </srcBlock>
00175 // In this example, a <src>PagedImage</src> is constructed (which isA
00176 // MaskedLattice) with .  We set the cursor axes 
00177 // to be the y and z axes, we specify to list the statistics if we plot them,
00178 // and we ask to plot the mean, standard deviation, and root mean square of each 
00179 // yz plane as a function of x location on the PGPLOT device "/xs" with
00180 // 1 subplot per page (there will be only one in this case).  After the
00181 // plotting and listing, we also retrieve the sum of the selected pixels
00182 // as a function of x location into an array.
00183 // </example>
00184 
00185 // <motivation>
00186 // The generation of statistical information from a lattice is a basic 
00187 // and necessary capability.
00188 // </motivation>
00189 
00190 // <todo asof="1996/11/26">
00191 //   <li> Implement plotting for complex lattices
00192 //   <li> Retrieve statistics at specified location of display axes
00193 // </todo>
00194 
00195 
00196 template <class T> class LatticeStatistics : public LatticeStatsBase
00197 {
00198 
00199 public:
00200 
00201 
00202     typedef typename NumericTraits<T>::PrecisionType AccumType;
00203 
00204     struct AlgConf {
00205         StatisticsData::ALGORITHM algorithm;
00206         // hinges-fences f factor
00207         Double hf;
00208         // fit to have center type
00209         FitToHalfStatisticsData::CENTER ct;
00210         // fit to half data portion to use
00211         FitToHalfStatisticsData::USE_DATA ud;
00212         // fit to half center value
00213         AccumType cv;
00214         // Chauvenet zscore
00215         Double zs;
00216         // Chauvenet max iterations
00217         Int mi;
00218     };
00219 
00220 // Constructor takes the lattice and a <src>LogIO</src> object for logging.
00221 // You can specify whether you want to see progress meters or not.
00222 // You can force the storage lattice to be disk based, otherwise
00223 // the decision for core or disk is taken for you.
00224    LatticeStatistics (const MaskedLattice<T>& lattice, 
00225                       LogIO& os,
00226                       Bool showProgress=True,
00227                       Bool forceDisk=False);
00228 
00229 // Constructor takes the lattice only. In the absence of a logger you get no messages.
00230 // This includes error messages and potential listing of the statistics.
00231 // You can specify whether you want to see progress meters or not.
00232 // You can force the storage lattice to be disk based, otherwise
00233 // the decision for core or disk is taken for you.
00234    LatticeStatistics (const MaskedLattice<T>& lattice,
00235                       Bool showProgress=True,
00236                       Bool forceDisk=False);
00237 
00238 // Copy constructor.  Copy semantics are followed.  Therefore any storage lattice 
00239 // that has already been created for <src>other</src> is copied to <src>*this</src>
00240    LatticeStatistics(const LatticeStatistics<T> &other);
00241 
00242 // Destructor
00243    virtual ~LatticeStatistics ();
00244 
00245 // Assignment operator.  Deletes any storage lattice associated with
00246 // the object being assigned to and copies any storage lattice that has
00247 // already been created for "other".
00248    LatticeStatistics<T> &operator=(const LatticeStatistics<T> &other);
00249 
00250 // Set the cursor axes (0 relative).  A return value of <src>False</src>
00251 // indicates you have asked for an invalid axis.  The default state of the class
00252 // is to set the cursor axes to all axes in the lattice.
00253    Bool setAxes (const Vector<Int>& cursorAxes);
00254 
00255 // You may specify a pixel intensity range as either one for which 
00256 // all pixels in that range are included or one for which all pixels 
00257 // in that range are excluded.   One or the other of <src>include</src> 
00258 // and <src>exclude</src> must therefore be a zero length vector if you 
00259 // call this function.    If you are setting an <src>include</src>
00260 // range, then if you set <src>setMinMaxToInclude=True</src>, the
00261 // minimum and maximum values that this class returns will always be 
00262 // the minimum and maximum of the <src>include</src> range, respectively.
00263 // A return value of <src>False</src> indicates that 
00264 // you have given both an <src>include</src> and an <src>exclude</src> 
00265 // range.  A vector of length 1 for <src>include</src> and/or <src>exclude</src>
00266 // means that the range will be set to (say for <src>include</src>)
00267 // <src>-abs(include(0))</src> to <src>abs(include(0))</src>.  A return value
00268 // of <src>False</src> indicates that both an inclusion and exclusion 
00269 // range were given or that the internal state of the class is bad.   If you don't
00270 // call this function, the default state of the class  is to include all pixels.
00271    Bool setInExCludeRange(const Vector<T>& include,
00272                           const Vector<T>& exclude,
00273                           Bool setMinMaxToInclude=False);
00274 
00275 // This function allows you to control whether the statistics are written to
00276 // the output stream if you are also making a plot.  A return value of 
00277 // <src>False</src> indicates that the internal state of the class is bad.
00278 // If you have created the <src>LatticeStatistics</src> object without
00279 // a <src>LogIO</src> object, you won't see any listings, but no error
00280 // conditions will be generated.  The default state of the class is to 
00281 // not list the output when making a plot. 
00282    Bool setList(const Bool& doList);
00283 
00284 // Display the statistics by listing and/or plotting them.  If you don't call
00285 // this function then you won't see anything !  A return value of <src>False</src>
00286 // indicates an invalid plotting device, or that the internal state of the class is bad.
00287 
00288    Bool display();
00289 
00290    Bool getLayerStats(String& stats, Double area, 
00291                       Int zAxis=-1, Int zLayer=-1, 
00292                       Int hAxis=-1, Int hLayer=-1); 
00293 
00294    typedef std::pair<String,String> stat_element;
00295    typedef std::list<stat_element> stat_list;
00296    Bool getLayerStats( stat_list &stats, Double area, 
00297                       Int zAxis=-1, Int zLayer=-1, 
00298                       Int hAxis=-1, Int hLayer=-1); 
00299 
00300 // Return the display axes.  The returned vector will be valid only if <src>setAxes</src>
00301 // has been called, or if one of the active "display" or "get*" methods has been called. 
00302    Vector<Int> displayAxes() const {return displayAxes_p;} 
00303 
00304 // Recover the desired Statistic into an array.  If you choose to use
00305 // the T version, be aware that the values in the AccumType version of the
00306 // Array may not be representable in the T version (e.g. large values for
00307 // SumSq).  The shape of the
00308 // array is the shape of the display axes (e.g. if the shape of the lattice is
00309 // [nx,ny,nz] and you ask for the mean of the y axis the shape of the returned
00310 // array would be [nx,nz].    A returned array of zero shape indicates that there 
00311 // were no good values.   A return   value of <src>False</src> 
00312 // indicates that the internal state of  the class is bad.
00313 // <group>
00314    Bool getStatistic (Array<AccumType>& stat, LatticeStatsBase::StatisticsTypes type, Bool dropDeg=True);
00315    Bool getConvertedStatistic (Array<T>& stat, LatticeStatsBase::StatisticsTypes type, Bool dropDeg=True);
00316 // </group>
00317 
00318 // Recover position of min and max. Only works if there are no
00319 // display axes (i.e. statistics found over entire image), otherwise,
00320 // the returned values are resized to 0 shape.  A return  
00321 // value of <src>False</src> indicates that the internal state of 
00322 // the class is bad.
00323    Bool getMinMaxPos(IPosition& minPos, IPosition& maxPos);
00324 
00325 // This function gets a vector containing all the statistics
00326 // for a given location.  If <src>posInLattice=True</src> then
00327 // the location is a location in the input lattice.  Any
00328 // positions on the display axes are ignored.  Otherwise, you
00329 // should just give locations for the display axes only.
00330 // Use can use the enum in class LatticeStatsBase to find out
00331 // which locations in the vector contain which statistics.
00332 // A returned vector of zero shape indicates that there 
00333 // were no good values. A return  value of <src>False</src> 
00334 // indicates that the  internal state of the class is bad.
00335    Bool getStats (Vector<AccumType>&,
00336                   const IPosition& pos,
00337                   const Bool posInLattice=False);
00338 
00339 // Reset argument error condition.  If you specify invalid arguments to
00340 // one of the above <src>set</src> functions, an internal flag will be set which will
00341 // prevent the work functions from doing anything (should you have chosen 
00342 // to ignore the Boolean return values of the <src>set</src> functions).
00343 // This function allows you to reset that internal state to good.
00344    void resetError () {goodParameterStatus_p = True;};
00345 
00346 // Get full lattice min and max only.  Returns False if no unmasked data, else returns True.
00347 // Honours any include or exclude range if set.
00348    Bool getFullMinMax (T& dataMin, T& dataMax);
00349 
00350 // Recover last error message
00351    String errorMessage() const {return error_p;};
00352 
00353 // Set a new MaskedLattice object.  A return value of <src>False</src> indicates the 
00354 // lattice had an invalid type or that the internal state of the class is bad.
00355    Bool setNewLattice(const MaskedLattice<T>& lattice);
00356 
00357 // Did we construct with a logger ?
00358    Bool hasLogger () const {return haveLogger_p;};
00359 
00360    // configure object to use Classical Statistics
00361    // The time, t_x, it takes to compute classical statistics using algorithm x, can
00362    // be modeled by
00363    // t_x = n_sets*(a_x + b_x*n_el)
00364    // where n_sets is the number of independent sets of data to compute stats on,
00365    // each containing n_el number of elements. a_x is the time it takes to compute
00366    // stats a a single set of data, and b_x is the time it takes to accumulate
00367    // a single point.
00368    // The old algorithm was developed in the early history of the project, I'm guessing
00369    // by Neil Kileen, while the new algorithm was developed in 2015 by Dave Mehringer
00370    // as part of the stats framework project. The old algorithm is faster in the regime
00371    // of large n_sets and small n_el, while the new algorithm is faster in the
00372    // regime of small n_sets and large n_el.
00373    // If one always wants to use one of these algorithms, that algorithm's coefficients
00374    // should be set to 0, while setting the other algorithm's coefficients to positive
00375    // values. Note that it's the relative, not the absolute, values of these
00376    // coeffecients that is important
00377    // The version that takes no parameters uses the default values of the coefficients;
00378    // <group>
00379    void configureClassical();
00380 
00381    void configureClassical(Double aOld, Double bOld, Double aNew, Double bNew);
00382    // </group>
00383 
00384    // configure to use fit to half algorithm.
00385    void configureFitToHalf(
00386            FitToHalfStatisticsData::CENTER centerType=FitToHalfStatisticsData::CMEAN,
00387            FitToHalfStatisticsData::USE_DATA useData=FitToHalfStatisticsData::LE_CENTER,
00388            AccumType centerValue=0
00389    );
00390 
00391    // configure to use hinges-fences algorithm
00392    void configureHingesFences(Double f);
00393 
00394    // configure to use Chauvenet's criterion
00395    void configureChauvenet(
00396            Double zscore=-1, Int maxIterations=-1
00397    );
00398 
00399    // get number of iterations associated with Chauvenet criterion algorithm
00400    std::map<String, uInt> getChauvenetNiter() const { return _chauvIters; }
00401 
00402 protected:
00403 
00404    LogIO os_p;
00405    Vector<Int> cursorAxes_p, displayAxes_p;
00406    Bool goodParameterStatus_p;
00407    Bool haveLogger_p, fixedMinMax_p;
00408 
00409 // doRobust means that when the storage lattice is generated, the
00410 // robust statistics are generated as well
00411 
00412    Bool doRobust_p;
00413    Bool doList_p;
00414    IPosition minPos_p, maxPos_p, blcParent_p;
00415    String error_p;
00416 //
00417 // Virtual Functions.  See implementation to figure it all out !
00418 
00419    // FIXME The indirect dependence of this class on ImageInterface related
00420    // issues (eg flux density) breaks encapsulation. All the ImageInterface related code should be
00421    // encapsulated in ImageStatistics. Unfortunately, that requires significantly
00422    // more time than I have atm. A return value of False means that the object in
00423    // question cannot compute flux density values. The default implementation returns False.
00424    virtual Bool _canDoFlux() const { return False; }
00425 
00426    virtual Quantum<AccumType> _flux(Bool&, AccumType, Double) const {
00427        ThrowCc("Logic Error: This object cannot compute flux density");
00428    }
00429 
00430    virtual void listMinMax (ostringstream& osMin,
00431                             ostringstream& osMax,
00432                             Int oWidth, DataType type);
00433 
00434    //
00435 
00436 // List the statistics to the logger.   The implementation here
00437 // is adequate for all lattices.  See ImageStatistics for an
00438 // example of where extra information is provided. hasBeam is
00439 // the return value of getBeamArea. If it is true, that means
00440 // that the FLUX statistics will be available in the storage
00441 // lattice.  dPos is the location of the start of the cursor in the
00442 // storage image for this row.  stats(j,i) is the statistics matrix.
00443 // for the jth point and the ith statistic.
00444 // The return value is False if something goes wrong !
00445 // Have a look at the implementation to see what you really
00446 // have to do.
00447    virtual Bool listStats (Bool hasBeam, const IPosition& dPos,
00448                           const Matrix<AccumType>& ord);
00449    virtual Bool listLayerStats (
00450              const Matrix<AccumType>& ord,
00451              ostringstream& rslt, Int zLayer); 
00452 /*
00453 // Gets labels for higher order axes and x axis.
00454 // dPos is the location of the start of the cursor in the
00455 // storage image for this row. 
00456    virtual void getLabels(String& higherOrderLabel, String& xAxisLabel,
00457                           const IPosition& dPos) const;
00458 */
00459 // Given a location in the storage lattice, convert those locations on the   
00460 // non-statistics axis (the last one) and optionally account for the 
00461 // lattice subsectioning
00462    IPosition locInLattice (const IPosition& storagePosition,
00463                            Bool relativeToParent=True) const;
00464  
00465 // Non-virtual functions
00466 //
00467 // set stream manipulators
00468    void setStream (ostream& os, Int oPrec);
00469 
00470    // get the storage lattice shape
00471    inline IPosition _storageLatticeShape() const { return pStoreLattice_p->shape(); }
00472 
00473    virtual Bool _computeFlux(
00474         Array<AccumType>& flux, const Array<AccumType>& npts, const Array<AccumType>& sum
00475    );
00476 
00477    virtual Bool _computeFlux(
00478            Quantum<AccumType>& flux, AccumType sum, const IPosition& pos,
00479            Bool posInLattice
00480    );
00481 
00482    // convert a position in the input lattice to the corresponding
00483    // position in the stats storage lattice. The number of elements
00484    // in storagePos will not be changed and only the first N elements
00485    // will be modified where N = the number of elements in latticePos.
00486    // <src>storagePos</src> must therefore have at least as many elements
00487    // as <src>latticePos</src>. Returns False if
00488    //<src>latticePos</src> is inconsistent with the input lattice.
00489    void _latticePosToStoragePos(
00490            IPosition& storagePos, const IPosition& latticePos
00491    );
00492 
00493 private:
00494 
00495    const MaskedLattice<T>* pInLattice_p;
00496    CountedPtr<TempLattice<AccumType> > pStoreLattice_p;
00497    Vector<Int> nxy_p, statsToPlot_p;
00498    Vector<T> range_p;
00499    Bool noInclude_p, noExclude_p;
00500        
00501    Bool needStorageLattice_p, doneSomeGoodPoints_p, someGoodPointsValue_p;
00502    Bool showProgress_p, forceDisk_p;
00503 
00504    T minFull_p, maxFull_p;
00505    Bool doneFullMinMax_p;
00506 
00507    AlgConf _algConf;
00508    std::map<String, uInt> _chauvIters;
00509 
00510    Double _aOld, _bOld, _aNew, _bNew;
00511 
00512    void _setDefaultCoeffs() {
00513        // coefficients from timings run on PagedImages on
00514        // etacarinae.cv.nrao.edu (dmehring's development
00515        // machine)
00516        _aOld = 4.7e-7;
00517        _bOld = 2.3e-8;
00518        _aNew = 1.6e-5;
00519        _bNew = 1.5e-8;
00520    }
00521 
00522 // Summarize the statistics found over the entire lattice
00523    virtual void summStats();
00524 
00525        virtual void displayStats(
00526            AccumType nPts, AccumType sum, AccumType median,
00527            AccumType medAbsDevMed, AccumType quartile, AccumType sumSq, AccumType mean,
00528            AccumType var, AccumType rms, AccumType sigma, AccumType dMin, AccumType dMax,
00529            AccumType q1, AccumType q3
00530        );
00531 
00532 // Calculate statistic from storage lattice and return in an array
00533    Bool calculateStatistic (Array<AccumType>& slice, 
00534                             LatticeStatsBase::StatisticsTypes type,
00535                             Bool dropDeg);
00536 
00537 // Find the median per cursorAxes chunk
00538    void generateRobust (); 
00539 
00540 // Create a new storage lattice
00541    Bool generateStorageLattice (); 
00542 
00543 // Given a location in the lattice and a statistic type, work
00544 // out where to put it in the storage lattice
00545    IPosition locInStorageLattice(const IPosition& latticePosition,
00546                                  LatticeStatsBase::StatisticsTypes type) const;
00547 
00548 // Find min and max of good data in arrays specified by pointers
00549    void minMax            (Bool& none, AccumType& dMin, AccumType& dMax,
00550                            const Vector<AccumType>& d,
00551                            const Vector<AccumType>& n) const;
00552 
00553 // Retrieve a statistic from the storage lattice and return in an array
00554    Bool retrieveStorageStatistic (Array<AccumType>& slice,
00555                                   const LatticeStatsBase::StatisticsTypes type,
00556                                   const Bool dropDeg);
00557 
00558 // Retrieve a statistic from the storage lattice at the specified
00559 // location and return in an array
00560    Bool retrieveStorageStatistic (Vector<AccumType>& slice, 
00561                                   const IPosition& pos,
00562                                   const Bool posInLattice);
00563 
00564 // Find the shape of slice from the statistics lattice at one
00565 // spatial pixel
00566    IPosition statsSliceShape () const; 
00567 
00568 // See if there were some valid points found in the storage lattice
00569    Bool someGoodPoints ();  
00570 
00571 // Stretch min and max by 5%
00572    void stretchMinMax (AccumType& dMin, AccumType& dMax) const;
00573 
00574    CountedPtr<StatisticsAlgorithm<AccumType, const T*, const Bool*> > _createStatsAlgorithm() const;
00575 
00576    void _configureDataProviders(
00577            LatticeStatsDataProvider<T>& lattDP,
00578            MaskedLatticeStatsDataProvider<T>& maskedLattDP
00579     ) const;
00580 
00581    void _doStatsLoop(uInt nsets, CountedPtr<LattStatsProgress> progressMeter);
00582 };
00583 
00584 //# Declare extern templates for often used types.
00585 #ifdef AIPS_CXX11
00586   extern template class LatticeStatistics<Float>;
00587 #endif
00588 
00589 
00590 } //# NAMESPACE CASA - END
00591 
00592 #ifndef CASACORE_NO_AUTO_TEMPLATES
00593 #include <casacore/lattices/LatticeMath/LatticeStatistics.tcc>
00594 #endif //# CASACORE_NO_AUTO_TEMPLATES
00595 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1