casacore
Loading...
Searching...
No Matches
LatticeUtilities.h
Go to the documentation of this file.
1// # LatticeUtilities.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_LATTICEUTILITIES_H
27#define LATTICES_LATTICEUTILITIES_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/casa/Arrays/ArrayFwd.h>
31
32namespace casacore { // # NAMESPACE CASACORE - BEGIN
33
34template <class T>
35class Lattice;
36template <class T>
37class MaskedLattice;
38class IPosition;
39class LogIO;
40class Slicer;
41
42// <summary>Static functions for Lattices</summary>
43// <use visibility=export>
44
45// <reviewed reviewer="" date="yyyy/mm/dd" tests="tLatticeUtilities.cc" demos="">
46// </reviewed>
47//
48// <prerequisite>
49// <li> <linkto class="Lattice">Lattice</linkto>
50// </prerequisite>
51//
52// <synopsis>
53// Some static helper functions for Lattices
54// </synopsis>
55//
56// <motivation>
57// Common functionality not appropriate for Lattice member functions
58// </motivation>
59//
60// <todo asof="2001/08/27">
61// <li> nothing I know of
62// </todo>
63//
64
66 public:
67 // Copy data and mask from input to output. If the input has no mask,
68 // that means all True (good), and these values will be transferred
69 // to the output. Mask transfer only occurs if the output has
70 // a writeable mask.
71 template <class T>
72 static void copyDataAndMask(LogIO& os, MaskedLattice<T>& out, const MaskedLattice<T>& in,
73 Bool zeroMasked = False);
74
75 // Replicate array through lattice in the specified region.
76 // The shape of <src>pixels</src> has to fit exactly into the shape of
77 // the selected region for each axis of <src>pixels</src>. Otherwise
78 // and exception will be thrown. For example,
79 // if the shape of the region is [10,20], the shape of pixels could
80 // be [10] and it will be replicated 20 times. Another example would
81 // be that the shape of pixels could be [5,10] and it would be
82 // replicated 4 times fitting into the Lattice
83 template <class T>
84 static void replicate(Lattice<T>& lat, const Slicer& region, const Array<T>& pixels);
85
86 // Bin up one axis of MaskedArray (uses Lattices in implementation)
87 template <class T>
88 static void bin(MaskedArray<T>& out, const MaskedArray<T>& in, uInt axis, uInt bin);
89
90 // Add degenerate axes to the lattice if needed (nDim is the desired number of dimensions
91 // for the output lattice). If the shapes are the same, the returned
92 // pointer holds a SubLattice. If a reshape was necessary, the pointer
93 // holds an ExtendLattice. The pointer is the callers responsibility to delete.
94 template <class T>
95 static void addDegenerateAxes(Lattice<T>*& pLatOut, const Lattice<T>& latIn, uInt nDim);
96};
97
98} // namespace casacore
99
100#ifndef CASACORE_NO_AUTO_TEMPLATES
101#include <casacore/lattices/Lattices/LatticeUtilities.tcc>
102#endif // # CASACORE_NO_AUTO_TEMPLATES
103#endif
static void copyDataAndMask(LogIO &os, MaskedLattice< T > &out, const MaskedLattice< T > &in, Bool zeroMasked=False)
Copy data and mask from input to output.
static void bin(MaskedArray< T > &out, const MaskedArray< T > &in, uInt axis, uInt bin)
Bin up one axis of MaskedArray (uses Lattices in implementation).
static void replicate(Lattice< T > &lat, const Slicer &region, const Array< T > &pixels)
Replicate array through lattice in the specified region.
static void addDegenerateAxes(Lattice< T > *&pLatOut, const Lattice< T > &latIn, uInt nDim)
Add degenerate axes to the lattice if needed (nDim is the desired number of dimensions for the output...
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40