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