casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LatticeStatsBase.h
Go to the documentation of this file.
1 //# LatticeStatsBase.h: base class for LatticeStatistics class
2 //# Copyright (C) 1996,1999,2000,2001
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef LATTICES_LATTICESTATSBASE_H
29 #define LATTICES_LATTICESTATSBASE_H
30 
31 #include <casacore/casa/aips.h>
34 
35 #include <set>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 class IPosition;
40 class Regex;
41 
42 // <summary> Base class for LatticeStatistics class</summary>
43 // <use visibility=export>
44 //
45 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
46 // </reviewed>
47 //
48 // <prerequisite>
49 // <li> Vector
50 // <li> String
51 // </prerequisite>
52 //
53 // <etymology>
54 // A simple base class for the <linkto class="LatticeStatistics">LatticeStatistics</linkto> class
55 // </etymology>
56 //
57 // <synopsis>
58 // This base class provides an <src>enum</src> defining allowed statistics types
59 // and a helper function to convert between a <src>String</src> and a
60 // <src>Vector<Int></src> describing the desired statistics to plot. The reason for
61 // having it as a base class rather than just part of LatticeStatistics is that
62 // the latter is templated, and it doesn't make much sense to invoke the static function
63 // <src>setStatisticTypes</src> function with a templated type.
64 // </synopsis>
65 //
66 // <example>
67 // <srcblock>
68 // Vector<Int> statsToPlot = LatticeStatsBase::toStatisticTypes("mean,rms,sigma");
69 // </srcblock>
70 // </example>
71 //
72 // <todo asof="yyyy/mm/dd">
73 // </todo>
74 
75 
77 {
78 public:
79 
80 // This <src>enum StatisticTypes</src> is provided for use with the
81 // <src>LatticeStatistics<T>\::setPlotting</src> function. It gives the allowed
82 // statistics types that you can ask for.
83 
85 
86 // The number of points
88 
89 // The sum
90  SUM,
91 
92 // The sum squared
94 
95 // The median - the robust stats does not fit well into storage lattice approach
97 
98 // median of absolute deviation from median
100 
101 // inter-quartile range
103 
104  // The first and third quartiles
105  Q1,
106  Q3,
107 
108 // The minimum
110 
111 // The maximum
113 
114 // The mean
116 
117 // The variance about the mean
119 
120 // The standard deviation about the mean
122 
123 // The rms
125 
126 // The flux density (can't always compute this - needs the beam)
128 
129 // The total number of available statistics to plot
131 
132 // The total number of accumulation image items (not for general use:
133 // note that the accumulation items MUST come first in this enum)
134 // dmehring changed from VARIANCE+1 to SIGMA+1 because the standard
135 // deviation should be stored rather than taking the square root of
136 // the same value multiple times. Not to mention the biweight
137 // algorithm does not compute the variance, so that the standard
138 // deviation must be explicitly stored for it.
139  NACCUM = SIGMA + 1
140 };
141 
142 // Helper function to convert a String containing a list of desired statistics to
143 // the correct Vector<Int> required for the LatticeStatistics<T>::setPlotting
144 // function. This may be usful if your user interface involves strings rather than integers.
145 // A new value is added to the output vector (which is resized appropriately) if any of the
146 // substrings "npts", "min", "max", "sum", "sumsq", "mean", "sigma", "rms",
147 // and "flux" is present. An empty vector results if there are no matches
148 // <group>
149  static Vector<Int> toStatisticTypes (const String& statistics,
150  const std::regex& delimiter);
151  static Vector<Int> toStatisticTypes (const Vector<String>& statistics);
152 // </group>
153 
154 // Convert type to string.
155 // <group>
156  static String toStatisticName (StatisticsTypes type);
157  static String toStatisticName (Int type);
158 // </group>
159 
160 // Returns -1 if the statistic string is not valid
161  static Int toStatisticType (const String& statistic);
162 
163 // Check and fill in defaults for a <src>Vector<Int></src> containing the
164 // number of subplots in x and y to be put on a plot. The <src>Vector<Int></src>
165 // is resized to 2 before assignment. A return value of <src>False</src> indicates
166 // invalid arguments.
167  static Bool setNxy (Vector<Int>& nxy,
168  ostream& os);
169 
170 // A storage image is used to accumulate information as a function of the display
171 // axes as an image is iterated through. This function sets the storage image shape
172 // to that appropriate to the shape of the display axes and the desired size of the first
173 // or last dimension.
174  static void setStorageImageShape (IPosition& storeImageShape,
175  const Bool& last,
176  const Int& axisSize,
177  const Vector<Int>& displayAxes,
178  const IPosition& shape);
179 
180 // Stretch a range by 10%
181  static void stretchMinMax (Float& min, Float& max);
182 
183  static std::set<Double> quartileFracs();
184 };
185 
186 
187 } //# NAMESPACE CASACORE - END
188 
189 #endif
190 
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
int Int
Definition: aipstype.h:50
static Int toStatisticType(const String &statistic)
Returns -1 if the statistic string is not valid.
The total number of available statistics to plot.
The median - the robust stats does not fit well into storage lattice approach.
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
Base class for LatticeStatistics class.
static void setStorageImageShape(IPosition &storeImageShape, const Bool &last, const Int &axisSize, const Vector< Int > &displayAxes, const IPosition &shape)
A storage image is used to accumulate information as a function of the display axes as an image is it...
The first and third quartiles.
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
The total number of accumulation image items (not for general use: note that the accumulation items M...
median of absolute deviation from median
The flux density (can&#39;t always compute this - needs the beam)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
StatisticsTypes
This enum StatisticTypes is provided for use with the LatticeStatistics&lt;T&gt;::setPlotting function...
float Float
Definition: aipstype.h:54
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1987
static void stretchMinMax(Float &min, Float &max)
Stretch a range by 10%.
TableExprNode regex(const TableExprNode &node)
Functions for regular expression matching and pattern matching.
Definition: ExprNode.h:1483
The variance about the mean.
static std::set< Double > quartileFracs()
String: the storage and methods of handling collections of characters.
Definition: String.h:225
static Vector< Int > toStatisticTypes(const String &statistics, const std::regex &delimiter)
Helper function to convert a String containing a list of desired statistics to the correct Vector&lt;Int...
The standard deviation about the mean.
static Bool setNxy(Vector< Int > &nxy, ostream &os)
Check and fill in defaults for a Vector&lt;Int&gt; containing the number of subplots in x and y to be put o...
static String toStatisticName(StatisticsTypes type)
Convert type to string.