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