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