casacore
Loading...
Searching...
No Matches
LatticeMathUtil.h
Go to the documentation of this file.
1// # LatticeMathUtil.h: useful global functions for Lattices
2// # Copyright (C) 1995,1996,1997,1999,2000,2001,2002,2004
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_LATTICEMATHUTIL_H
27#define LATTICES_LATTICEMATHUTIL_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/lattices/LatticeMath/LatticeStatsBase.h>
31#include <casacore/casa/Arrays/ArrayFwd.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35template <class T>
36class Lattice;
37template <class T>
38class MaskedLattice;
39class IPosition;
40class LogIO;
41class Slicer;
42
43// <summary>Static math functions for Lattices</summary>
44// <use visibility=export>
45
46// <reviewed reviewer="" date="yyyy/mm/dd" tests="tLatticeMathUtil.cc" demos="">
47// </reviewed>
48//
49// <prerequisite>
50// <li> <linkto class="Lattice">Lattice</linkto>
51// </prerequisite>
52//
53// <synopsis>
54// Some static helper math functions for Lattices
55// </synopsis>
56//
57// <motivation>
58// Common functionality not appropriate for Lattice member functions
59// </motivation>
60//
61// <todo asof="2001/08/27">
62// <li> nothing I know of
63// </todo>
64//
65
67 public:
68 // Collapse the specified axes by averaging and recover the
69 // pixel values. If axes is empty, then the data just contains
70 // all of the lattice (i.e. no collapse),
71 // but dropDegenerateAxes is stil honoured
72 template <class T>
73 static void collapse(Array<T>& data, const IPosition& axes, const MaskedLattice<T>& in,
74 Bool dropDegenerateAxes);
75 //
76 // Collapse the specified axes by averaging and recover either/and
77 // the pixel values and mask. If axes is empty, then the data and mask just contains
78 // all of the lattice (i.e. no collapse)
79 // but dropDegenerateAxes is stil honoured
80 template <class T>
81 static void collapse(Array<T>& data, Array<Bool>& mask, const IPosition& axes,
82 const MaskedLattice<T>& lat, Bool dropDegenerateAxes, Bool getPixels = True,
83 Bool getMask = True,
85};
86
87// <summary>Global functions on Lattices</summary>
88// <use visibility=export>
89
90// <reviewed reviewer="" date="yyyy/mm/dd" tests="tLatticeMathUtil.cc" demos="">
91// </reviewed>
92//
93// <prerequisite>
94// <li> <linkto class="Lattice">Lattice</linkto>
95// </prerequisite>
96//
97// <synopsis>
98// Global functions using Lattices
99// </synopsis>
100//
101// <example>
102// <h4>Example 1:</h4>
103// Copy the lattice-type data between two Images.// <srcblock>
104//
105// PagedImage<Float> myImg ("myimagefile");
106// Float lmin;
107// Float lmax;
108// IPosition posMin = myImg.shape();
109// IPosition posMax = myImg.shape();
110// minMax( lmin, lmax, posMin, posMax, myImg );
111//
112// </srcblock>
113// </example>
114//
115//
116// <motivation>
117// Algorithms like CLEAN need to know the position of the MIN and MAX
118// of an image, but easy things like LEL's min and max don't tell you
119// the location of the min and max. It seems there may be other global
120// functions involving lattices.
121// </motivation>
122//
123// <todo asof="1999/10/27">
124// <li> nothing I know of
125// </todo>
126//
127// <group name=LatticeMathUtil>
129// This global function finds the max of a Lattice, and also
130// the IPositions of the max. (LEL does not get you the IPositions of the
131// min and max)
132
133template <class T>
134void minMax(T& min, T& max, IPosition& posMin, IPosition& posMax, const Lattice<T>& lat);
135
136// </group>
137
138} // namespace casacore
139
140#ifndef CASACORE_NO_AUTO_TEMPLATES
141#include <casacore/lattices/LatticeMath/LatticeMathUtil.tcc>
142#endif // # CASACORE_NO_AUTO_TEMPLATES
143#endif
static void collapse(Array< T > &data, Array< Bool > &mask, const IPosition &axes, const MaskedLattice< T > &lat, Bool dropDegenerateAxes, Bool getPixels=True, Bool getMask=True, const LatticeStatsBase::StatisticsTypes stat=LatticeStatsBase::MEAN)
Collapse the specified axes by averaging and recover either/and the pixel values and mask.
static void collapse(Array< T > &data, const IPosition &axes, const MaskedLattice< T > &in, Bool dropDegenerateAxes)
Collapse the specified axes by averaging and recover the pixel values.
StatisticsTypes
This enum StatisticTypes is provided for use with the LatticeStatistics<T>::setPlotting function.
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)
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41
void minMax(T &min, T &max, IPosition &posMin, IPosition &posMax, const Lattice< T > &lat)
This global function finds the max of a Lattice, and also the IPositions of the max.