casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
LatticeStatsBase.h
Go to the documentation of this file.
00001 //# LatticeStatsBase.h: base class for LatticeStatistics class
00002 //# Copyright (C) 1996,1999,2000,2001
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: LatticeStatsBase.h 19909 2007-02-23 02:08:02Z Malte.Marquarding $
00027 
00028 #ifndef LATTICES_LATTICESTATSBASE_H
00029 #define LATTICES_LATTICESTATSBASE_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/Arrays/Vector.h>
00033 #include <casa/BasicSL/String.h>
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 class IPosition;
00038 class Regex;
00039 
00040 // <summary> Base class for LatticeStatistics class</summary>
00041 // <use visibility=export>
00042 // 
00043 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00044 // </reviewed>
00045 // 
00046 // <prerequisite>
00047 //   <li> Vector
00048 //   <li> String
00049 // </prerequisite>
00050 //
00051 // <etymology>
00052 // A simple base class for the <linkto class="LatticeStatistics">LatticeStatistics</linkto> class
00053 // </etymology>
00054 //
00055 // <synopsis>
00056 // This base class provides an <src>enum</src> defining allowed statistics types 
00057 // and a helper function to convert between a <src>String</src> and a
00058 // <src>Vector<Int></src> describing the desired statistics to plot.  The reason for
00059 // having it as a base class rather than just part of LatticeStatistics is that
00060 // the latter is templated, and it doesn't make much sense to invoke the static function
00061 // <src>setStatisticTypes</src> function with a templated type.
00062 // </synopsis>
00063 //
00064 // <example>
00065 // <srcBlock>
00066 //    Vector<Int> statsToPlot = LatticeStatsBase::toStatisticTypes("mean,rms,sigma");
00067 // </srcBlock>
00068 // </example>
00069 //
00070 // <motivation>
00071 // My sensibilities were offended at having to say
00072 //
00073 //    <src>Vector<Int> statsToPlot = LatticeStatistics<Float>::toStatisticTypes("mean,rms,sigma");</src>
00074 //
00075 // when the <src><Float></src> was meaningless.
00076 // </motivation>
00077 //
00078 // <todo asof="yyyy/mm/dd">
00079 // </todo>
00080 
00081 
00082 class LatticeStatsBase
00083 {
00084 public:
00085 
00086 // This <src>enum StatisticTypes</src> is provided for use with the
00087 // <src>LatticeStatistics<T>::setPlotting</src> function.  It gives the allowed 
00088 // statistics types that you can ask for.
00089    
00090 enum StatisticsTypes {
00091  
00092 // The number of points
00093    NPTS,
00094 
00095 // The sum
00096    SUM,
00097 
00098 // The sum squared
00099    SUMSQ,
00100 
00101 // The median - the robust stats does not fit well into storage lattice approach
00102    MEDIAN,
00103 
00104 // median of absolute deviation from median
00105    MEDABSDEVMED,
00106 
00107 // inter-quartile range
00108    QUARTILE, 
00109 
00110 // The minimum
00111    MIN,
00112 
00113 // The maximum
00114    MAX,
00115 
00116 // The mean
00117    MEAN,
00118 
00119 // The variance about the mean
00120    VARIANCE,
00121 
00122 // The standard deviation about the mean
00123    SIGMA,
00124 
00125 // The rms
00126    RMS,
00127 
00128 // The flux density (can't always compute this - needs the beam)
00129    FLUX,
00130 
00131 // The total number of available statistics to plot
00132    NSTATS,
00133 
00134 // The total number of accumulation image items (not for general use:
00135 // note that the accumulation items MUST come first in this enum)
00136    NACCUM = VARIANCE+1
00137 };
00138 
00139 // Helper function to convert a String containing a list of desired statistics to
00140 // the correct Vector<Int> required for the LatticeStatistics<T>::setPlotting
00141 // function.  This may be usful if your user interface involves strings rather than integers.
00142 // A new value is added to the output vector (which is resized appropriately) if any of the
00143 // substrings "npts", "min", "max", "sum", "sumsq", "mean", "sigma", "rms", 
00144 // and "flux" is present.  An empty vector results if there are no matches
00145 // <group>
00146    static Vector<Int> toStatisticTypes (const String& statistics, 
00147                                         const Regex& delimiter);
00148    static Vector<Int> toStatisticTypes (const Vector<String>& statistics);
00149 // </group>
00150 
00151 // Convert type to string.
00152 // <group>
00153    static String toStatisticName (StatisticsTypes type);
00154    static String toStatisticName (Int type);
00155 // </group>
00156 
00157 // Returns -1 if the statistic string is not valid
00158    static Int toStatisticType (const String& statistic);
00159 
00160 // Check and fill in defaults for a <src>Vector<Int></src> containing the 
00161 // number of subplots in x and y to be put on a plot.  The <src>Vector<Int></src> 
00162 // is resized to 2 before assignment.  A return value of <src>False</src> indicates 
00163 // invalid arguments.
00164    static Bool setNxy (Vector<Int>& nxy,
00165                        ostream& os);
00166 
00167 // A storage image is used to accumulate information as a function of the display
00168 // axes as an image is iterated through.  This function sets the storage image shape 
00169 // to that appropriate to the shape of the display axes and the desired size of the first
00170 // or last dimension.  
00171    static void setStorageImageShape (IPosition& storeImageShape,
00172                                      const Bool& last,
00173                                      const Int& axisSize,
00174                                      const Vector<Int>& displayAxes,
00175                                      const IPosition& shape);
00176 
00177 // Stretch a range by 10%
00178    static void stretchMinMax (Float& min, Float& max);
00179 };
00180 
00181 
00182 } //# NAMESPACE CASA - END
00183 
00184 #endif
00185