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 <ostream>
34#include <set>
35
36namespace casacore { // # NAMESPACE CASACORE - BEGIN
37
38class IPosition;
39class Regex;
40
41// <summary> Base class for LatticeStatistics class</summary>
42// <use visibility=export>
43//
44// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
45// </reviewed>
46//
47// <prerequisite>
48// <li> Vector
49// <li> String
50// </prerequisite>
51//
52// <etymology>
53// A simple base class for the <linkto class="LatticeStatistics">LatticeStatistics</linkto> class
54// </etymology>
55//
56// <synopsis>
57// This base class provides an <src>enum</src> defining allowed statistics types
58// and a helper function to convert between a <src>String</src> and a
59// <src>Vector<Int></src> describing the desired statistics to plot. The reason for
60// having it as a base class rather than just part of LatticeStatistics is that
61// the latter is templated, and it doesn't make much sense to invoke the static function
62// <src>setStatisticTypes</src> function with a templated type.
63// </synopsis>
64//
65// <example>
66// <srcblock>
67// Vector<Int> statsToPlot = LatticeStatsBase::toStatisticTypes("mean,rms,sigma");
68// </srcblock>
69// </example>
70//
71// <todo asof="yyyy/mm/dd">
72// </todo>
73
75 public:
76 // This <src>enum StatisticTypes</src> is provided for use with the
77 // <src>LatticeStatistics<T>\::setPlotting</src> function. It gives the allowed
78 // statistics types that you can ask for.
79
81
82 // The number of points
84
85 // The sum
87
88 // The sum squared
90
91 // The median - the robust stats does not fit well into storage lattice approach
93
94 // median of absolute deviation from median
96
97 // inter-quartile range
99
100 // The first and third quartiles
103
104 // The minimum
106
107 // The maximum
109
110 // The mean
112
113 // The variance about the mean
115
116 // The standard deviation about the mean
118
119 // The rms
121
122 // The flux density (can't always compute this - needs the beam)
124
125 // The total number of available statistics to plot
127
128 // The total number of accumulation image items (not for general use:
129 // note that the accumulation items MUST come first in this enum)
130 // dmehring changed from VARIANCE+1 to SIGMA+1 because the standard
131 // deviation should be stored rather than taking the square root of
132 // the same value multiple times. Not to mention the biweight
133 // algorithm does not compute the variance, so that the standard
134 // deviation must be explicitly stored for it.
136 };
137
138 // Helper function to convert a String containing a list of desired statistics to
139 // the correct Vector<Int> required for the LatticeStatistics<T>::setPlotting
140 // function. This may be usful if your user interface involves strings rather than integers.
141 // A new value is added to the output vector (which is resized appropriately) if any of the
142 // substrings "npts", "min", "max", "sum", "sumsq", "mean", "sigma", "rms",
143 // and "flux" is present. An empty vector results if there are no matches
144 // <group>
145 static Vector<Int> toStatisticTypes(const String& statistics, const std::regex& delimiter);
146 static Vector<Int> toStatisticTypes(const Vector<String>& statistics);
147 // </group>
148
149 // Convert type to string.
150 // <group>
153 // </group>
154
155 // Returns -1 if the statistic string is not valid
156 static Int toStatisticType(const String& statistic);
157
158 // Check and fill in defaults for a <src>Vector<Int></src> containing the
159 // number of subplots in x and y to be put on a plot. The <src>Vector<Int></src>
160 // is resized to 2 before assignment. A return value of <src>False</src> indicates
161 // invalid arguments.
162 static Bool setNxy(Vector<Int>& nxy, std::ostream& os);
163
164 // A storage image is used to accumulate information as a function of the display
165 // axes as an image is iterated through. This function sets the storage image shape
166 // to that appropriate to the shape of the display axes and the desired size of the first
167 // or last dimension.
168 static void setStorageImageShape(IPosition& storeImageShape, const Bool& last,
169 const Int& axisSize, const Vector<Int>& displayAxes,
170 const IPosition& shape);
171
172 // Stretch a range by 10%
173 static void stretchMinMax(Float& min, Float& max);
174
175 static std::set<Double> quartileFracs();
176};
177
178} // namespace casacore
179
180#endif
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 Bool setNxy(Vector< Int > &nxy, std::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 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 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:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
IPosition shape(const RecordFieldId &) const
Get the actual shape of this field.
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