casacore
Loading...
Searching...
No Matches
LatticeConcat.h
Go to the documentation of this file.
1//# LatticeConcat.h: concatenate lattices along an axis
2//# Copyright (C) 1996,1997,1998,1999,2000,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_LATTICECONCAT_H
27#define LATTICES_LATTICECONCAT_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/lattices/Lattices/MaskedLattice.h>
33#include <casacore/casa/Containers/Block.h>
34
35namespace casacore { //# NAMESPACE CASACORE - BEGIN
36
37//# Forward Declarations
38class IPosition;
39class Slicer;
40
41
42// <summary>
43// Concatenates lattices along a specified axis
44// </summary>
45
46// <use visibility=export>
47
48// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
49// </reviewed>
50
51// <prerequisite>
52// <li> <linkto class=MaskedLattice>MaskedLattice</linkto> (base class)
53// </prerequisite>
54
55// <etymology>
56// This is a class designed to concatenate lattices along a specified axis
57// </etymology>
58
59// <synopsis>
60// This is a class designed to concatenate lattices along a specified
61// axis. This means you can join them together. E.g.,
62// join lattices of shape [10,20,30] and [10,20,40] into a lattice
63// of shape [10,20,70].
64//
65// In addition, you can increase the dimensionality
66// and join lattices [10,20] and [10,20] to [10,20,2]. This is
67// done by specifying the concatenation axis to be higher than
68// currently exists in the input lattices
69//
70// The LatticeConcat object does not copy the input lattices, it
71// just references them. You can use the Lattice<T>::copyData(Lattice<T>)
72// function to fill an output lattice with the concatenated input lattices.
73//
74// If you use the putSlice function, be aware that it will change the
75// underlying lattices if they are writable.
76// </synopsis>
77//
78// <example>
79// <srcBlock>
80//
82//
83// ArrayLattice<Float> al1(a1); al1.set(1.0);
84// ArrayLattice<Float> al2(a2); al2.set(10.0);
85//
87//
88// SubLattice<Float> ml1(al1, True);
89// SubLattice<Float> ml2(al2, True);
90//
92//
93// LatticeConcat<Float> lc (1);
94// lc.setLattice(ml1);
95// lc.setLattice(ml2);
96//
98//
99// ArrayLattice<Float> al3(lc.shape());
100// SubLattice<Float> ml3(al3, True);
101//
103//
104// ml3.copyData(lc);
105//
106//
107// </srcBlock>
108// In this example no masks are involved. See tLatticeConcat
109// for more examples.
110// </example>
111
112//
113// <motivation>
114// Image concatentation is a useful enduser requirement. An object of
115// this class is contained by an ImageConcat object.
116// </motivation>
117
118// <todo asof="1999/10/23">
119// </todo>
120
121
122template <class T> class LatticeConcat : public MaskedLattice<T>
123{
124public:
125
126// Constructor. Argument <src>axis</src> specifies the concatenation
127// axis (0 relative). If this is one more than the number of axes
128// in the input lattices (set with function <src>setLattice</src>)
129// then the resultant concatenated lattice has dimension
130// one greater than that the input lattices.
131// Argument <src>tempClose</src> specifies whether you wish
132// all internal lattice copies to be
133// opened/closed on demand, rather than just being left open.
134// This prevents open file limits being reached
136
137// Default constructor. Sets the concatenation axis to 0
138// and tempClose is True
140
141// Copy constructor (reference semantics)
143
144// Destructor
145 virtual ~LatticeConcat ();
146
147// Assignment operator (reference semantics)
149
150// Adds a clone of the lattice to the list to be concatenated.
151// Exception thrown if lattices are incompatible
153
154// Return the number of lattices set so far
156 {return lattices_p.nelements();}
157
158// Returns the current concatenation axis (0 relative)
159 uInt axis () const
160 {return axis_p;}
161
162// Set the tempClose state.
163 void setTempClose (Bool tmpClose)
164 { tempClose_p = tmpClose; }
165
166// Returns the tempClose constructor state
168 {return tempClose_p;}
169
170// Returns the number of dimensions of the *input* lattices (may be different
171// by one from output lattice). Returns 0 if none yet set.
173
174// Return pointer for specified lattice. Do not delete it.
176 { return lattices_p[i]; }
177
178// Handle the (un)locking and syncing, etc.
179// <group>
180 virtual Bool lock (FileLocker::LockType, uInt nattempts);
181 virtual void unlock();
183 virtual void resync();
184 virtual void flush();
185 virtual void tempClose();
186 virtual void reopen();
187// </group>
188
189// Close/reopen a specific lattice. It is your responsibility to leave the
190// LatticeConcat object in a fully closed state. So always pair
191// a reopen with a tempClose.
192// <group>
193 void tempClose(uInt which);
194 void reopen(uInt which);
195// </group>
196
197// Name. Since many lattices may go into the concatenation, the name
198// is rather meaningless. Returns the string "Concatenation :"
199 virtual String name (Bool stripPath=False) const;
200
201// Make a copy of the derived object (reference semantics).
202 virtual LatticeConcat<T>* cloneML() const;
203
204// Has the object really a mask?
205 virtual Bool isMasked() const;
206
207// Get the region used (always returns 0).
208 virtual const LatticeRegion* getRegionPtr() const;
209
210// If all of the underlying lattices are writable returns True
211 virtual Bool isWritable() const;
212
213// Does the lattice have a pixelmask?
214 virtual Bool hasPixelMask() const;
215
216// Get access to the pixelmask.
217// An exception is thrown if the lattice does not have a pixelmask
218// <group>
219 virtual const Lattice<Bool>& pixelMask() const;
221// </group>
222
223// Find the shape that the concatenated lattice will be.
224// Returns a null IPosition if function setLattice has not yet
225// been called
226 virtual IPosition shape () const;
227
228// Return the best cursor shape. This isn't very meaningful for a LatticeConcat
229// Lattice since it isn't on disk ! But if you do copy it out, this is
230// what you should use. The maxPixels aregument is ignored.
231 virtual IPosition doNiceCursorShape (uInt maxPixels) const;
232
233// Do the actual get of the data.
234// The return value is always False, thus the buffer does not reference
235// another array. Generally the user should use function getSlice
236 virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section);
237
238// Do the actual get of the mask data.
239// The return value is always False, thus the buffer does not reference
240// another array. Generally the user should use function getMaskSlice
241 virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section);
242
243// Do the actual put of the data into the Lattice. This will change the underlying
244// lattices (if they are writable) that were used to create the
245// LatticeConcat object. It throws an exception if not writable.
246// Generally the user should use function putSlice
247 virtual void doPutSlice (const Array<T>& sourceBuffer,
248 const IPosition& where,
249 const IPosition& stride);
250
251
252private:
258//
260//
261 void setup1 (IPosition& blc, IPosition& trc, IPosition& stride,
262 IPosition& blc2, IPosition& trc2,
263 IPosition& blc3, IPosition& trc3, IPosition& stride3,
264 const Slicer& section);
266 Int shape2, Int axis, const IPosition& blc,
267 const IPosition& trc, const IPosition& stride, Int start);
268 Bool getSlice1 (Array<T>& buffer, const Slicer& section,
269 uInt nLattices);
270 Bool getSlice2 (Array<T>& buffer, const Slicer& section,
271 uInt nLattices);
272 Bool putSlice1 (const Array<T>& buffer, const IPosition& where,
273 const IPosition& stride, uInt nLattices);
274
275 Bool putSlice2 (const Array<T>& buffer, const IPosition& where,
276 const IPosition& stride, uInt nLattices);
277 Bool getMaskSlice1 (Array<Bool>& buffer, const Slicer& section,
278 uInt nLattices);
279 Bool getMaskSlice2 (Array<Bool>& buffer, const Slicer& section,
280 uInt nLattices);
281};
282
283
284
285} //# NAMESPACE CASACORE - END
286
287#ifndef CASACORE_NO_AUTO_TEMPLATES
288#include <casacore/lattices/Lattices/LatticeConcat.tcc>
289#endif //# CASACORE_NO_AUTO_TEMPLATES
290#endif
LockType
Define the possible lock types.
Definition FileLocker.h:93
virtual uInt ndim() const
Return the number of axes in this Lattice.
virtual const Lattice< Bool > & pixelMask() const
Get access to the pixelmask.
LatticeConcat< T > & operator=(const LatticeConcat< T > &other)
Assignment operator (reference semantics)
virtual LatticeConcat< T > * cloneML() const
Make a copy of the derived object (reference semantics).
Bool isTempClose() const
Returns the tempClose constructor state.
virtual void tempClose()
Temporarily close the lattice.
LatticeConcat()
Default constructor.
Bool getMaskSlice1(Array< Bool > &buffer, const Slicer &section, uInt nLattices)
Slicer setup2(Bool &first, IPosition &blc2, IPosition &trc2, Int shape2, Int axis, const IPosition &blc, const IPosition &trc, const IPosition &stride, Int start)
virtual IPosition shape() const
Find the shape that the concatenated lattice will be.
Bool getSlice2(Array< T > &buffer, const Slicer &section, uInt nLattices)
virtual ~LatticeConcat()
Destructor.
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle the (un)locking and syncing, etc.
virtual void resync()
Resynchronize the Lattice object with the lattice file.
void setup1(IPosition &blc, IPosition &trc, IPosition &stride, IPosition &blc2, IPosition &trc2, IPosition &blc3, IPosition &trc3, IPosition &stride3, const Slicer &section)
virtual Lattice< Bool > & pixelMask()
virtual void reopen()
Explicitly reopen the temporarily closed lattice.
void setTempClose(Bool tmpClose)
Set the tempClose state.
uInt nlattices() const
Return the number of lattices set so far.
virtual void flush()
Flush the data (but do not unlock).
uInt latticeDim() const
Returns the number of dimensions of the input lattices (may be different by one from output lattice).
virtual Bool doGetSlice(Array< T > &buffer, const Slicer &section)
Do the actual get of the data.
void setLattice(MaskedLattice< T > &lattice)
Adds a clone of the lattice to the list to be concatenated.
virtual Bool hasPixelMask() const
Does the lattice have a pixelmask?
LatticeConcat(uInt axis, Bool tempClose=True)
Constructor.
LatticeConcat(const LatticeConcat< T > &other)
Copy constructor (reference semantics)
virtual Bool hasLock(FileLocker::LockType) const
Bool putSlice2(const Array< T > &buffer, const IPosition &where, const IPosition &stride, uInt nLattices)
virtual void unlock()
void reopen(uInt which)
virtual void doPutSlice(const Array< T > &sourceBuffer, const IPosition &where, const IPosition &stride)
Do the actual put of the data into the Lattice.
MaskedLattice< T > * lattice(uInt i) const
Return pointer for specified lattice.
virtual String name(Bool stripPath=False) const
Name.
virtual Bool doGetMaskSlice(Array< Bool > &buffer, const Slicer &section)
Do the actual get of the mask data.
void checkAxis(uInt axis, uInt ndim) const
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Return the best cursor shape.
uInt axis() const
Returns the current concatenation axis (0 relative)
virtual const LatticeRegion * getRegionPtr() const
Get the region used (always returns 0).
Bool getSlice1(Array< T > &buffer, const Slicer &section, uInt nLattices)
Bool getMaskSlice2(Array< Bool > &buffer, const Slicer &section, uInt nLattices)
LatticeConcat< Bool > * pPixelMask_p
PtrBlock< MaskedLattice< T > * > lattices_p
virtual Bool isWritable() const
If all of the underlying lattices are writable returns True.
void tempClose(uInt which)
Close/reopen a specific lattice.
Bool putSlice1(const Array< T > &buffer, const IPosition &where, const IPosition &stride, uInt nLattices)
virtual Bool isMasked() const
Has the object really a mask?
A drop-in replacement for Block<T*>.
Definition Block.h:812
String: the storage and methods of handling collections of characters.
Definition String.h:223
struct Node * first
Definition malloc.h:328
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
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41