casacore
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: 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$
27
28#ifndef LATTICES_LATTICEUTILITIES_H
29#define LATTICES_LATTICEUTILITIES_H
30
31#include <casacore/casa/aips.h>
32#include <casacore/casa/Arrays/ArrayFwd.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36template <class T> class Lattice;
37template <class T> class 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
65
67{
68 public:
69
70// Copy data and mask from input to output. If the input has no mask,
71// that means all True (good), and these values will be transferred
72// to the output. Mask transfer only occurs if the output has
73// a writeable mask.
74 template <class T>
75 static void copyDataAndMask (LogIO& os, MaskedLattice<T>& out,
76 const MaskedLattice<T>& in, Bool zeroMasked=False);
77
78// Replicate array through lattice in the specified region.
79// The shape of <src>pixels</src> has to fit exactly into the shape of
80// the selected region for each axis of <src>pixels</src>. Otherwise
81// and exception will be thrown. For example,
82// if the shape of the region is [10,20], the shape of pixels could
83// be [10] and it will be replicated 20 times. Another example would
84// be that the shape of pixels could be [5,10] and it would be
85// replicated 4 times fitting into the Lattice
86 template <class T>
87 static void replicate (Lattice<T>& lat,
88 const Slicer& region,
89 const Array<T>& pixels);
90
91// Bin up one axis of MaskedArray (uses Lattices in implementation)
92 template <class T>
93 static void bin (MaskedArray<T>& out, const MaskedArray<T>& in, uInt axis, uInt bin);
94
95// Add degenerate axes to the lattice if needed (nDim is the desired number of dimensions
96// for the output lattice). If the shapes are the same, the returned
97// pointer holds a SubLattice. If a reshape was necessary, the pointer
98// holds an ExtendLattice. The pointer is the callers responsibility to delete.
99 template <class T>
100 static void addDegenerateAxes (Lattice<T>*& pLatOut, const Lattice<T>& latIn, uInt nDim);
101};
102
103
104} //# NAMESPACE CASACORE - END
105
106#ifndef CASACORE_NO_AUTO_TEMPLATES
107#include <casacore/lattices/Lattices/LatticeUtilities.tcc>
108#endif //# CASACORE_NO_AUTO_TEMPLATES
109#endif
110
111
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...
this file contains all the compiler specific defines
Definition: mainpage.dox:28
const Bool False
Definition: aipstype.h:44
unsigned int uInt
Definition: aipstype.h:51
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42