casacore
Loading...
Searching...
No Matches
ExtendLattice.h
Go to the documentation of this file.
1//# ExtendLattice.h: A subset of a Lattice or MaskedLattice
2//# Copyright (C) 2001,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 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_EXTENDLATTICE_H
27#define LATTICES_EXTENDLATTICE_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/lattices/Lattices/MaskedLattice.h>
33#include <casacore/casa/Arrays/ExtendSpecifier.h>
34
35namespace casacore { //# NAMESPACE CASACORE - BEGIN
36
37//# Forward Declarations
38
39
40// <summary>
41// An extension of a Lattice or MaskedLattice
42// </summary>
43
44// <use visibility=export>
45
46// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
47// </reviewed>
48
49// <prerequisite>
50// <li> <linkto class="Lattice">Lattice</linkto>
51// <li> <linkto class="LatticeRegion">LatticeRegion</linkto>
52// </prerequisite>
53
54// <synopsis>
55// An ExtendLattice is a lattice virtually extending another lattice
56// by stretching axes with length 1 and/or by adding new axes.
57// It is useful for e.g. LEL to have the same shapes for lattices.
58// An ExtendLattice is not writable (since many pixels map to the same
59// underlying pixel).
60// </synopsis>
61
62// <example>
63// <srcblock>
64// </srcblock>
65// </example>
66
67// <templating arg=T>
68// <li> Any type that can be used by the Tables System can also be used by
69// this class.
70// </templating>
71
72//# <todo asof="yyyy/mm/dd">
73//# </todo>
74
75template<class T> class ExtendLattice: public MaskedLattice<T>
76{
77public:
78 // The default constructor creates a ExtendLattice that is useless for just
79 // about everything, except that it can be assigned to with the assignment
80 // operator.
82
83 // Create a ExtendLattice from a Lattice.
84 // <br><src>newShape</src> gives the new shape.
85 // <br><src>newAxes</src> gives the new axes in newShape.
86 // <br><src>stretchAxes</src> gives the stretched axes in newShape.
87 // <br>E.g. lattice has shape [32,1,5,1], newShape=[32,1,4,5,10],
88 // newAxes=[2], and stretchAxes=[4]. It means that axes 2 in the newShape
89 // is a new axes and that axes 4 in the new shape is stretched. The other
90 // axes in the new shape have to match the other axes in the old shape.
91 // Note that stretched axes have to have length 1 in the old shape.
92 // <group>
93 ExtendLattice (const Lattice<T>& lattice, const IPosition& newShape,
94 const IPosition& extendAxes, const IPosition& stretchAxes);
95 ExtendLattice (const MaskedLattice<T>& lattice, const IPosition& newShape,
96 const IPosition& newAxes, const IPosition& stretchAxes);
97 // </group>
98
99 // Copy constructor (reference semantics).
101
102 virtual ~ExtendLattice();
103
104 // Assignment (reference semantics).
106
107 // Make a copy of the object (reference semantics).
108 virtual MaskedLattice<T>* cloneML() const;
109
110 // Is the lattice masked?
111 // It is if its parent lattice is masked.
112 virtual Bool isMasked() const;
113
114 // An ExtendLattice is not persistent.
115 virtual Bool isPersistent() const;
116
117 // Is the ExtendLattice paged to disk?
118 virtual Bool isPaged() const;
119
120 // An ExtendLattice is not writable.
121 virtual Bool isWritable() const;
122
123 // Handle locking of the ExtendLattice which is delegated to its parent.
124 // <br>It is strongly recommended to use class
125 // <linkto class=LatticeLocker>LatticeLocker</linkto> to
126 // handle lattice locking. It also contains a more detailed
127 // explanation of the locking process.
128 // <group>
129 virtual Bool lock (FileLocker::LockType, uInt nattempts);
130 virtual void unlock();
132 // </group>
133
134 // Resynchronize the Lattice object with the lattice file.
135 // This function is only useful if no read-locking is used, ie.
136 // if the table lock option is UserNoReadLocking or AutoNoReadLocking.
137 // In that cases the table system does not acquire a read-lock, thus
138 // does not synchronize itself automatically.
139 virtual void resync();
140
141 // Flush the data.
142 virtual void flush();
143
144 // Close the Lattice temporarily (if it is paged to disk).
145 // It'll be reopened automatically when needed or when
146 // <src>reopen</src> is called explicitly.
147 virtual void tempClose();
148
149 // If needed, reopen a temporarily closed Lattice.
150 virtual void reopen();
151
152 // Does the ExtendLattice have a pixelmask?
153 virtual Bool hasPixelMask() const;
154
155 // Get access to the pixelmask.
156 // An exception is thrown if the ExtendLattice does not have a pixelmask.
157 // <group>
158 virtual const Lattice<Bool>& pixelMask() const;
160 // </group>
161
162 // Get the region used (always returns 0).
163 virtual const LatticeRegion* getRegionPtr() const;
164
165 // Returns the shape of the ExtendLattice.
166 virtual IPosition shape() const;
167
168 // Return the name of the parent lattice.
169 virtual String name (Bool stripPath=False) const;
170
171 // This function returns the recommended maximum number of pixels to
172 // include in the cursor of an iterator.
173 virtual uInt advisedMaxPixels() const;
174
175 // Check class internals - used for debugging. Should always return True
176 virtual Bool ok() const;
177
178 // Do the actual getting of an array of values.
179 virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section);
180
181 // Putting data is not possible.
182 virtual void doPutSlice (const Array<T>& sourceBuffer,
183 const IPosition& where,
184 const IPosition& stride);
185
186 // Get a section of the mask.
187 virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section);
188
189 // Get the best cursor shape.
190 virtual IPosition doNiceCursorShape (uInt maxPixels) const;
191
192private:
193 // Set the various pointer needed to construct the object.
194 // One of the pointers should be zero.
195 // It takes over the pointer and deletes the object in the destructor.
196 void setPtr (Lattice<T>* latticePtr, MaskedLattice<T>* maskLatPtr);
197
198 // Get mask data from mask.
199 Bool getMaskDataSlice (Array<Bool>& buffer, const Slicer& section);
200
206};
207
208
209
210} //# NAMESPACE CASACORE - END
211
212#ifndef CASACORE_NO_AUTO_TEMPLATES
213#include <casacore/lattices/Lattices/ExtendLattice.tcc>
214#endif //# CASACORE_NO_AUTO_TEMPLATES
215#endif
ExtendLattice(const MaskedLattice< T > &lattice, const IPosition &newShape, const IPosition &newAxes, const IPosition &stretchAxes)
virtual void doPutSlice(const Array< T > &sourceBuffer, const IPosition &where, const IPosition &stride)
Putting data is not possible.
virtual void reopen()
If needed, reopen a temporarily closed Lattice.
virtual Lattice< Bool > & pixelMask()
ExtendSpecifier itsExtendSpec
ExtendLattice< T > & operator=(const ExtendLattice< T > &other)
Assignment (reference semantics).
ExtendLattice(const Lattice< T > &lattice, const IPosition &newShape, const IPosition &extendAxes, const IPosition &stretchAxes)
Create a ExtendLattice from a Lattice.
virtual const Lattice< Bool > & pixelMask() const
Get access to the pixelmask.
virtual Bool isWritable() const
An ExtendLattice is not writable.
virtual const LatticeRegion * getRegionPtr() const
Get the region used (always returns 0).
virtual String name(Bool stripPath=False) const
Return the name of the parent lattice.
virtual void flush()
Flush the data.
ExtendLattice(const ExtendLattice< T > &other)
Copy constructor (reference semantics).
Bool getMaskDataSlice(Array< Bool > &buffer, const Slicer &section)
Get mask data from mask.
virtual Bool hasLock(FileLocker::LockType) const
void setPtr(Lattice< T > *latticePtr, MaskedLattice< T > *maskLatPtr)
Set the various pointer needed to construct the object.
virtual uInt advisedMaxPixels() const
This function returns the recommended maximum number of pixels to include in the cursor of an iterato...
virtual Bool doGetMaskSlice(Array< Bool > &buffer, const Slicer &section)
Get a section of the mask.
virtual void tempClose()
Close the Lattice temporarily (if it is paged to disk).
virtual Bool hasPixelMask() const
Does the ExtendLattice have a pixelmask?
virtual void unlock()
virtual MaskedLattice< T > * cloneML() const
Make a copy of the object (reference semantics).
virtual Bool isPaged() const
Is the ExtendLattice paged to disk?
virtual Bool ok() const
Check class internals - used for debugging.
ExtendLattice< Bool > * itsPixelMask
virtual void resync()
Resynchronize the Lattice object with the lattice file.
ExtendLattice()
The default constructor creates a ExtendLattice that is useless for just about everything,...
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking of the ExtendLattice which is delegated to its parent.
virtual Bool isPersistent() const
An ExtendLattice is not persistent.
virtual Bool isMasked() const
Is the lattice masked? It is if its parent lattice is masked.
virtual Bool doGetSlice(Array< T > &buffer, const Slicer &section)
Do the actual getting of an array of values.
Lattice< T > * itsLatticePtr
virtual IPosition shape() const
Returns the shape of the ExtendLattice.
MaskedLattice< T > * itsMaskLatPtr
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Get the best cursor shape.
LockType
Define the possible lock types.
Definition FileLocker.h:93
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