casacore
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>
32 #include <casacore/casa/Arrays/Vector.h>
33 #include <casacore/casa/BasicSL/String.h>
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 class IPosition;
38 class Regex;
39 
40 // <summary> Base class for LatticeStatistics class</summary>
41 // <use visibility=export>
42 //
43 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
44 // </reviewed>
45 //
46 // <prerequisite>
47 // <li> Vector
48 // <li> String
49 // </prerequisite>
50 //
51 // <etymology>
52 // A simple base class for the <linkto class="LatticeStatistics">LatticeStatistics</linkto> class
53 // </etymology>
54 //
55 // <synopsis>
56 // This base class provides an <src>enum</src> defining allowed statistics types
57 // and a helper function to convert between a <src>String</src> and a
58 // <src>Vector<Int></src> describing the desired statistics to plot. The reason for
59 // having it as a base class rather than just part of LatticeStatistics is that
60 // the latter is templated, and it doesn't make much sense to invoke the static function
61 // <src>setStatisticTypes</src> function with a templated type.
62 // </synopsis>
63 //
64 // <example>
65 // <srcblock>
66 // Vector<Int> statsToPlot = LatticeStatsBase::toStatisticTypes("mean,rms,sigma");
67 // </srcblock>
68 // </example>
69 //
70 // <todo asof="yyyy/mm/dd">
71 // </todo>
72 
73 
75 {
76 public:
77 
78 // This <src>enum StatisticTypes</src> is provided for use with the
79 // <src>LatticeStatistics<T>\::setPlotting</src> function. It gives the allowed
80 // statistics types that you can ask for.
81 
83 
84 // The number of points
86 
87 // The sum
88  SUM,
89 
90 // The sum squared
92 
93 // The median - the robust stats does not fit well into storage lattice approach
95 
96 // median of absolute deviation from median
98 
99 // inter-quartile range
101 
102  // The first and third quartiles
103  Q1,
104  Q3,
105 
106 // The minimum
108 
109 // The maximum
111 
112 // The mean
114 
115 // The variance about the mean
117 
118 // The standard deviation about the mean
120 
121 // The rms
123 
124 // The flux density (can't always compute this - needs the beam)
126 
127 // The total number of available statistics to plot
129 
130 // The total number of accumulation image items (not for general use:
131 // note that the accumulation items MUST come first in this enum)
133 };
134 
135 // Helper function to convert a String containing a list of desired statistics to
136 // the correct Vector<Int> required for the LatticeStatistics<T>::setPlotting
137 // function. This may be usful if your user interface involves strings rather than integers.
138 // A new value is added to the output vector (which is resized appropriately) if any of the
139 // substrings "npts", "min", "max", "sum", "sumsq", "mean", "sigma", "rms",
140 // and "flux" is present. An empty vector results if there are no matches
141 // <group>
142  static Vector<Int> toStatisticTypes (const String& statistics,
143  const Regex& delimiter);
144  static Vector<Int> toStatisticTypes (const Vector<String>& statistics);
145 // </group>
146 
147 // Convert type to string.
148 // <group>
149  static String toStatisticName (StatisticsTypes type);
150  static String toStatisticName (Int type);
151 // </group>
152 
153 // Returns -1 if the statistic string is not valid
154  static Int toStatisticType (const String& statistic);
155 
156 // Check and fill in defaults for a <src>Vector<Int></src> containing the
157 // number of subplots in x and y to be put on a plot. The <src>Vector<Int></src>
158 // is resized to 2 before assignment. A return value of <src>False</src> indicates
159 // invalid arguments.
160  static Bool setNxy (Vector<Int>& nxy,
161  ostream& os);
162 
163 // A storage image is used to accumulate information as a function of the display
164 // axes as an image is iterated through. This function sets the storage image shape
165 // to that appropriate to the shape of the display axes and the desired size of the first
166 // or last dimension.
167  static void setStorageImageShape (IPosition& storeImageShape,
168  const Bool& last,
169  const Int& axisSize,
170  const Vector<Int>& displayAxes,
171  const IPosition& shape);
172 
173 // Stretch a range by 10%
174  static void stretchMinMax (Float& min, Float& max);
175 };
176 
177 
178 } //# NAMESPACE CASACORE - END
179 
180 #endif
181 
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
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
Regular expression class.
Definition: Regex.h:198
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<T>::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:2151
static void stretchMinMax(Float &min, Float &max)
Stretch a range by 10%.
The variance about the mean.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
static Vector< Int > toStatisticTypes(const String &statistics, const Regex &delimiter)
Helper function to convert a String containing a list of desired statistics to the correct Vector<Int...
this file contains all the compiler specific defines
Definition: mainpage.dox:28
The standard deviation about the mean.
static Bool setNxy(Vector< Int > &nxy, ostream &os)
Check and fill in defaults for a Vector<Int> containing the number of subplots in x and y to be put o...
static String toStatisticName(StatisticsTypes type)
Convert type to string.