casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef LATTICES_LATTICESTATSBASE_H
27#define LATTICES_LATTICESTATSBASE_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/casa/Arrays/Vector.h>
31#include <casacore/casa/BasicSL/String.h>
32
33#include <set>
34
35namespace casacore { //# NAMESPACE CASACORE - BEGIN
36
37class IPosition;
38class 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{
76public:
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
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
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)
132// dmehring changed from VARIANCE+1 to SIGMA+1 because the standard
133// deviation should be stored rather than taking the square root of
134// the same value multiple times. Not to mention the biweight
135// algorithm does not compute the variance, so that the standard
136// deviation must be explicitly stored for it.
137 NACCUM = SIGMA + 1
139
140// Helper function to convert a String containing a list of desired statistics to
141// the correct Vector<Int> required for the LatticeStatistics<T>::setPlotting
142// function. This may be usful if your user interface involves strings rather than integers.
143// A new value is added to the output vector (which is resized appropriately) if any of the
144// substrings "npts", "min", "max", "sum", "sumsq", "mean", "sigma", "rms",
145// and "flux" is present. An empty vector results if there are no matches
146// <group>
147 static Vector<Int> toStatisticTypes (const String& statistics,
148 const std::regex& delimiter);
149 static Vector<Int> toStatisticTypes (const Vector<String>& statistics);
150// </group>
151
152// Convert type to string.
153// <group>
156// </group>
157
158// Returns -1 if the statistic string is not valid
159 static Int toStatisticType (const String& statistic);
160
161// Check and fill in defaults for a <src>Vector<Int></src> containing the
162// number of subplots in x and y to be put on a plot. The <src>Vector<Int></src>
163// is resized to 2 before assignment. A return value of <src>False</src> indicates
164// invalid arguments.
165 static Bool setNxy (Vector<Int>& nxy,
166 ostream& os);
167
168// A storage image is used to accumulate information as a function of the display
169// axes as an image is iterated through. This function sets the storage image shape
170// to that appropriate to the shape of the display axes and the desired size of the first
171// or last dimension.
172 static void setStorageImageShape (IPosition& storeImageShape,
173 const Bool& last,
174 const Int& axisSize,
175 const Vector<Int>& displayAxes,
176 const IPosition& shape);
177
178// Stretch a range by 10%
179 static void stretchMinMax (Float& min, Float& max);
180
181 static std::set<Double> quartileFracs();
182};
183
184
185} //# NAMESPACE CASACORE - END
186
187#endif
188
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<Int...
static std::set< Double > quartileFracs()
static String toStatisticName(Int type)
static String toStatisticName(StatisticsTypes type)
Convert type to string.
static Vector< Int > toStatisticTypes(const Vector< String > &statistics)
static void stretchMinMax(Float &min, Float &max)
Stretch a range by 10%.
static Int toStatisticType(const String &statistic)
Returns -1 if the statistic string is not valid.
StatisticsTypes
This enum StatisticTypes is provided for use with the LatticeStatistics<T>::setPlotting function.
@ QUARTILE
inter-quartile range
@ NPTS
The number of points.
@ NSTATS
The total number of available statistics to plot.
@ NACCUM
The total number of accumulation image items (not for general use: note that the accumulation items M...
@ VARIANCE
The variance about the mean.
@ Q1
The first and third quartiles.
@ MEDIAN
The median - the robust stats does not fit well into storage lattice approach.
@ SIGMA
The standard deviation about the mean.
@ FLUX
The flux density (can't always compute this - needs the beam)
@ MEDABSDEVMED
median of absolute deviation from median
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 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...
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
Definition ExprNode.h:1991
float Float
Definition aipstype.h:52
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40