casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: 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: LatticeUtilities.h 21538 2015-01-07 09:08:57Z gervandiepen $
27 
28 #ifndef LATTICES_LATTICEMATHUTIL_H
29 #define LATTICES_LATTICEMATHUTIL_H
30 
31 #include <casacore/casa/aips.h>
33 
34 namespace casacore { //# NAMESPACE CASACORE - BEGIN
35 
36 template <class T> class Array;
37 template <class T> class Lattice;
38 template <class T> class MaskedLattice;
39 template <class T> class MaskedArray;
40 class IPosition;
41 class LogIO;
42 class Slicer;
43 
44 // <summary>Static math functions for Lattices</summary>
45 // <use visibility=export>
46 
47 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tLatticeMathUtil.cc" demos="">
48 // </reviewed>
49 //
50 // <prerequisite>
51 // <li> <linkto class="Lattice">Lattice</linkto>
52 // </prerequisite>
53 //
54 // <synopsis>
55 // Some static helper math functions for Lattices
56 // </synopsis>
57 //
58 // <motivation>
59 // Common functionality not appropriate for Lattice member functions
60 // </motivation>
61 //
62 // <todo asof="2001/08/27">
63 // <li> nothing I know of
64 // </todo>
65 //
66 
67 
69 {
70  public:
71 
72 // Collapse the specified axes by averaging and recover the
73 // pixel values. If axes is empty, then the data just contains
74 // all of the lattice (i.e. no collapse),
75 // but dropDegenerateAxes is stil honoured
76  template <class T>
77  static void collapse (Array<T>& data, const IPosition& axes,
78  const MaskedLattice<T>& in,
79  Bool dropDegenerateAxes);
80 //
81 // Collapse the specified axes by averaging and recover either/and
82 // the pixel values and mask. If axes is empty, then the data and mask just contains
83 // all of the lattice (i.e. no collapse)
84 // but dropDegenerateAxes is stil honoured
85  template <class T>
86  static void collapse (
87  Array<T>& data, Array<Bool>& mask,
88  const IPosition& axes,
89  const MaskedLattice<T>& lat,
90  Bool dropDegenerateAxes,
91  Bool getPixels=True, Bool getMask=True,
93  );
94 
95 };
96 
97 // <summary>Global functions on Lattices</summary>
98 // <use visibility=export>
99 
100 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tLatticeMathUtil.cc" demos="">
101 // </reviewed>
102 //
103 // <prerequisite>
104 // <li> <linkto class="Lattice">Lattice</linkto>
105 // </prerequisite>
106 //
107 // <synopsis>
108 // Global functions using Lattices
109 // </synopsis>
110 //
111 // <example>
112 // <h4>Example 1:</h4>
113 // Copy the lattice-type data between two Images.// <srcblock>
114 //
115 // PagedImage<Float> myImg ("myimagefile");
116 // Float lmin;
117 // Float lmax;
118 // IPosition posMin = myImg.shape();
119 // IPosition posMax = myImg.shape();
120 // minMax( lmin, lmax, posMin, posMax, myImg );
121 //
122 // </srcblock>
123 // </example>
124 //
125 //
126 // <motivation>
127 // Algorithms like CLEAN need to know the position of the MIN and MAX
128 // of an image, but easy things like LEL's min and max don't tell you
129 // the location of the min and max. It seems there may be other global
130 // functions involving lattices.
131 // </motivation>
132 //
133 // <todo asof="1999/10/27">
134 // <li> nothing I know of
135 // </todo>
136 //
137 // <group name=LatticeMathUtil>
139 // This global function finds the max of a Lattice, and also
140 // the IPositions of the max. (LEL does not get you the IPositions of the
141 // min and max)
142 
143  template <class T>
144  void minMax(T & min, T & max,
145  IPosition & posMin, IPosition & posMax,
146  const Lattice<T>& lat);
147 
148 // </group>
149 
150 
151 } //# NAMESPACE CASACORE - END
152 
153 #ifndef CASACORE_NO_AUTO_TEMPLATES
154 #include <casacore/lattices/LatticeMath/LatticeMathUtil.tcc>
155 #endif //# CASACORE_NO_AUTO_TEMPLATES
156 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
A templated, abstract base class for array-like objects with masks.
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
A templated, abstract base class for array-like objects.
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
void getMask(size_t const num_mask, bool mask[], std::list< std::pair< size_t, size_t >> &ranges, bool invert=false, bool initialize=true)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void minMax(T &min, T &max, const TableVector< T > &tv)
Definition: TabVecMath.h:390
StatisticsTypes
This enum StatisticTypes is provided for use with the LatticeStatistics&lt;T&gt;::setPlotting function...
template &lt;class T, class U&gt; class vector;
Definition: MSFlagger.h:37
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.
const Bool True
Definition: aipstype.h:43
Static math functions for Lattices.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42