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