casacore
Loading...
Searching...
No Matches
RebinLattice.h
Go to the documentation of this file.
1//# RebinLattice.h: rebin a masked lattices
2//# Copyright (C) 2003
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 receied 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_REBINLATTICE_H
27#define LATTICES_REBINLATTICE_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/casa/Arrays/Array.h>
33#include <casacore/casa/Arrays/Slicer.h>
34#include <casacore/lattices/Lattices/MaskedLattice.h>
35
36namespace casacore { //# NAMESPACE CASACORE - BEGIN
37
38//# Forward Declarations
39
40class IPosition;
41
42
43// <summary>
44// Rebin a masked lattice.
45// </summary>
46
47// <use visibility=local>
48
49// <reviewed reviewer="" date="" tests="tRebinLattice.cc">
50// </reviewed>
51
52// <prerequisite>
53// <li> <linkto class="MaskedLattice">MaskedLattice</linkto>
54// </prerequisite>
55
56// <synopsis>
57// This class enables you to rebin (data are averaged over bin) a MaskedLattice by
58// a given factor per axis
59// </synopsis>
60
61// <example>
62// <srcblock>
63// IPosition shape(2, 10, 20);
64// TiledShape tShape(shape);
65// TempLattice<Float> latIn(tShape);
66// IPosition factors(2, 2, 5);
67// RebinLattice<Float> rl(latIn, factors);
68// cerr << "Binned data = " << rl.get() << endl;
69// </srcblock>
70// </example>
71
72// <motivation>
73// </motivation>
74
75
76template<class T>
77class RebinLattice : public MaskedLattice<T>
78{
79public:
80
81 // Default constructor (Object is unuseable)
83
84 // Constructor. The bins don't have to fit integrally. Whatever
85 // is left over at the end is treated as a full bin.
86 RebinLattice(const MaskedLattice<T>& lattice, const IPosition& bin);
87
88 // Copy constructor (reference semantics)
90
91 // Destructor.
92 virtual ~RebinLattice();
93
94 // Assignment (reference semantics)
96
97 // Make a copy of the object (reference semantics).
98 virtual MaskedLattice<T>* cloneML() const;
99
100 // Is the lattice masked?
101 // It is if its parent lattice is masked.
102 virtual Bool isMasked() const;
103
104 // Is the lattice paged to disk?
105 virtual Bool isPaged() const;
106
107 // The lattice is not writable.
108 virtual Bool isWritable() const;
109
110 // Handle locking of the lattice which is delegated to its parent.
111 // <br>It is strongly recommended to use class
112 // <linkto class=LatticeLocker>LatticeLocker</linkto> to
113 // handle lattice locking. It also contains a more detailed
114 // explanation of the locking process.
115 // <group>
116 virtual Bool lock (FileLocker::LockType, uInt nattempts);
117 virtual void unlock();
119 // </group>
120
121 // Resynchronize the Lattice object with the lattice file.
122 // This function is only useful if no read-locking is used, ie.
123 // if the table lock option is UserNoReadLocking or AutoNoReadLocking.
124 // In that cases the table system does not acquire a read-lock, thus
125 // does not synchronize itself automatically.
126 virtual void resync();
127
128 // Flush the data.
129 virtual void flush();
130
131 // Close the Lattice temporarily (if it is paged to disk).
132 // It'll be reopened automatically when needed or when
133 // <src>reopen</src> is called explicitly.
134 virtual void tempClose();
135
136 // If needed, reopen a temporarily closed Lattice.
137 virtual void reopen();
138
139 // Get a pointer the region/mask object.
140 // It returns 0.
141 virtual const LatticeRegion* getRegionPtr() const;
142
143 // Returns the shape of the lattice.
144 virtual IPosition shape() const;
145
146 // Return the name of the parent lattice.
147 virtual String name (Bool stripPath=False) const;
148
149 // This function returns the recommended maximum number of pixels to
150 // include in the cursor of an iterator.
151 virtual uInt advisedMaxPixels() const;
152
153 // Check class internals - used for debugging. Should always return True
154 virtual Bool ok() const;
155
156 // Do the actual getting of an array of values.
157 // Slicers with non-unit stride are not yet supported
158 virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section);
159
160 // Do the actual putting of an array of values.
161 // The lattice is not writable.
162 virtual void doPutSlice (const Array<T>& sourceBuffer,
163 const IPosition& where,
164 const IPosition& stride);
165
166 // Get a section of the mask.
167 // Slicers with non-unit stride are not yet supported
168 virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section);
169
170 // Static function needed by LEL. Applies binning factors
171 // to shape to give the shape of the output lattice. Will
172 // give the same result as function 'shape'
173 static IPosition rebinShape (const IPosition& shapeLatticeIn,
174 const IPosition& bin);
175
176private:
177 Slicer findOriginalSlicer (const Slicer& section) const;
178 void getDataAndMask (const Slicer& section);
179 void bin(const Array<T>& dataIn);
180 void bin(const Array<T>& dataIn, const Array<Bool>& maskIn);
181//
185// Cache
189};
190
191
192
193} //# NAMESPACE CASACORE - END
194
195#ifndef CASACORE_NO_AUTO_TEMPLATES
196#include <casacore/lattices/Lattices/RebinLattice.tcc>
197#endif //# CASACORE_NO_AUTO_TEMPLATES
198#endif
LockType
Define the possible lock types.
Definition FileLocker.h:93
virtual ~RebinLattice()
Destructor.
virtual Bool isWritable() const
The lattice is not writable.
virtual void resync()
Resynchronize the Lattice object with the lattice file.
virtual void reopen()
If needed, reopen a temporarily closed Lattice.
virtual Bool isMasked() const
Is the lattice masked? It is if its parent lattice is masked.
RebinLattice(const RebinLattice< T > &other)
Copy constructor (reference semantics)
virtual Bool hasLock(FileLocker::LockType) const
virtual MaskedLattice< T > * cloneML() const
Make a copy of the object (reference semantics).
virtual void tempClose()
Close the Lattice temporarily (if it is paged to disk).
virtual Bool isPaged() const
Is the lattice paged to disk?
virtual String name(Bool stripPath=False) const
Return the name of the parent lattice.
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking of the lattice which is delegated to its parent.
virtual void unlock()
virtual void flush()
Flush the data.
void bin(const Array< T > &dataIn, const Array< Bool > &maskIn)
void bin(const Array< T > &dataIn)
virtual const LatticeRegion * getRegionPtr() const
Get a pointer the region/mask object.
virtual void doPutSlice(const Array< T > &sourceBuffer, const IPosition &where, const IPosition &stride)
Do the actual putting of an array of values.
void getDataAndMask(const Slicer &section)
RebinLattice()
Default constructor (Object is unuseable)
Slicer findOriginalSlicer(const Slicer &section) const
static IPosition rebinShape(const IPosition &shapeLatticeIn, const IPosition &bin)
Static function needed by LEL.
virtual IPosition shape() const
Returns the shape of the lattice.
virtual Bool doGetMaskSlice(Array< Bool > &buffer, const Slicer &section)
Get a section of the mask.
Array< T > itsData
Cache.
virtual Bool doGetSlice(Array< T > &buffer, const Slicer &section)
Do the actual getting of an array of values.
virtual uInt advisedMaxPixels() const
This function returns the recommended maximum number of pixels to include in the cursor of an iterato...
RebinLattice< T > & operator=(const RebinLattice< T > &other)
Assignment (reference semantics)
MaskedLattice< T > * itsLatticePtr
RebinLattice(const MaskedLattice< T > &lattice, const IPosition &bin)
Constructor.
virtual Bool ok() const
Check class internals - used for debugging.
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
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