SubLattice.h

Classes

SubLattice -- A subset of a Lattice or MaskedLattice (full description)

template<class T> class SubLattice: public MaskedLattice<T>

Interface

Public Members
SubLattice()
SubLattice (const Lattice<T>& lattice, lattice=lattice())
SubLattice (Lattice<T>& lattice, Bool writableIfPossible, AxesSpecifier=AxesSpecifier())
SubLattice (const MaskedLattice<T>& lattice, lattice=lattice())
SubLattice (MaskedLattice<T>& lattice, Bool writableIfPossible, AxesSpecifier=AxesSpecifier())
SubLattice (const Lattice<T>& lattice, const LatticeRegion& region, Region=Region())
SubLattice (Lattice<T>& lattice, const LatticeRegion& region, Bool writableIfPossible, AxesSpecifier=AxesSpecifier())
SubLattice (const MaskedLattice<T>& lattice, const lattice& region, AxesSpecifier=AxesSpecifier())
SubLattice (MaskedLattice<T>& lattice, const lattice& region, Bool writableIfPossible, region=region())
SubLattice (const Lattice<T>& lattice, const lattice& slicer, AxesSpecifier=AxesSpecifier())
SubLattice (Lattice<T>& lattice, const lattice& slicer, Bool writableIfPossible, slicer=slicer())
SubLattice (const MaskedLattice<T>& lattice, const lattice& slicer, AxesSpecifier=AxesSpecifier())
SubLattice (MaskedLattice<T>& lattice, const lattice& slicer, Bool writableIfPossible, slicer=slicer())
SubLattice (const SubLattice<T>& other)
virtual ~SubLattice()
SubLattice<T>& operator= (const SubLattice<T>& other)
virtual MaskedLattice<T>* cloneML() const
virtual Bool isMasked() const
virtual Bool isPersistent() const
virtual Bool isPaged() const
virtual Bool canReferenceArray() const
virtual Bool isWritable() const
virtual Bool lock (FileLocker::LockType, uInt nattempts)
virtual void unlock()
virtual Bool hasLock (FileLocker::LockType) const
virtual void resync()
virtual void flush()
virtual void tempClose()
virtual void reopen()
virtual Bool hasPixelMask() const
virtual const Lattice<Bool>& pixelMask() const
virtual Lattice<Bool>& pixelMask()
void setPixelMask (const Lattice<Bool>& pixelMask, Bool mayExist)
virtual const LatticeRegion* getRegionPtr() const
virtual IPosition shape() const
virtual String name (Bool stripPath=False) const
virtual uInt advisedMaxPixels() const
virtual T getAt (const IPosition& where) const
virtual void putAt (const T& value, const IPosition& where)
virtual Bool ok() const
virtual LatticeIterInterface<T>* makeIter (const T& navigator, Bool useRef) const
virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section)
virtual void doPutSlice (const Array<T>& sourceBuffer, const IPosition& where, const IPosition& stride)
virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section)
virtual IPosition doNiceCursorShape (uInt maxPixels) const
const AxesMapping& getAxesMap() const
Protected Members
void setPtr (Lattice<T>* latticePtr, MaskedLattice<T>* maskLatPtr, Bool writableIfPossible)
void setRegion (const LatticeRegion& region)
void setRegion (const Slicer& slicer)
void setRegion()
void setAxesMap (const AxesSpecifier&)
Private Members
Bool getRegionDataSlice (Array<Bool>& buffer, const Slicer& section)
Bool getMaskDataSlice (Array<Bool>& buffer, const Slicer& section)
void andMask (Array<Bool>& buffer, Bool ref, const Array<Bool>& tmpbuf) const

Description

Review Status

Date Reviewed:
yyyy/mm/dd

Prerequisite

Synopsis

A SubLattice is a lattice referencing a subset of another lattice by means of a Slicer object.
It is useful when only a subset of a lattice needs to be accessed.

When the SubLattice is created from a const Lattice object, it is not writable, thus it can only be used as an rvalue.

Using an AxesSpecifier object it is possible to remove some or all degenerate axes (i.e. axes with length 1) to get a lattice with a lower dimensionality.

Example


 

Template Type Argument Requirements (T)

Member Description

SubLattice()

The default constructor creates a SubLattice that is useless for just about everything, except that it can be assigned to with the assignment operator.

SubLattice (const Lattice<T>& lattice, lattice=lattice())
SubLattice (Lattice<T>& lattice, Bool writableIfPossible, AxesSpecifier=AxesSpecifier())

Create a SubLattice from a Lattice. This results in a SubLattice without a real mask.
The "const Lattice" version yields a non-writable SubLattice, while for the non-const version one has to specify if the SubLattice should be writable (if the original lattice is non-writable, the SubLattice is always set to non-writable).

SubLattice (const MaskedLattice<T>& lattice, lattice=lattice())
SubLattice (MaskedLattice<T>& lattice, Bool writableIfPossible, AxesSpecifier=AxesSpecifier())

Create a SubLattice from a MaskedLattice.
The "const MaskedLattice" version yields a non-writable SubLattice, while for the non-const version one has to specify if the SubLattice should be writable (if the original lattice is non-writable, the SubLattice is always set to non-writable).

SubLattice (const Lattice<T>& lattice, const LatticeRegion& region, Region=Region())
SubLattice (Lattice<T>& lattice, const LatticeRegion& region, Bool writableIfPossible, AxesSpecifier=AxesSpecifier())
SubLattice (const MaskedLattice<T>& lattice, const lattice& region, AxesSpecifier=AxesSpecifier())
SubLattice (MaskedLattice<T>& lattice, const lattice& region, Bool writableIfPossible, region=region())

Create a SubLattice from the given MaskedLattice and region. Note that the region can be constructed from an LCRegion object or Slicer object (with an optional stride).
An exception is thrown if the lattice shape used in the region differs from the shape of the lattice.

SubLattice (const Lattice<T>& lattice, const lattice& slicer, AxesSpecifier=AxesSpecifier())
SubLattice (Lattice<T>& lattice, const lattice& slicer, Bool writableIfPossible, slicer=slicer())
SubLattice (const MaskedLattice<T>& lattice, const lattice& slicer, AxesSpecifier=AxesSpecifier())
SubLattice (MaskedLattice<T>& lattice, const lattice& slicer, Bool writableIfPossible, slicer=slicer())

Create a SubLattice from the given (Masked)Lattice and slicer. The slicer can be strided.
An exception is thrown if the slicer exceeds the lattice shape.

SubLattice (const SubLattice<T>& other)

Copy constructor (reference semantics).

virtual ~SubLattice()

SubLattice<T>& operator= (const SubLattice<T>& other)

Assignment (reference semantics).

virtual MaskedLattice<T>* cloneML() const

Make a copy of the object (reference semantics).

virtual Bool isMasked() const

Is the lattice masked? It is if its parent lattice or its region is masked.

virtual Bool isPersistent() const

A SubLattice is persistent if no region is applied to the parent lattice. That is true if the region has the same shape as the parent lattice and the region has no mask.

virtual Bool isPaged() const

Is the SubLattice paged to disk?

virtual Bool canReferenceArray() const

Can the lattice data be referenced as an array section?

virtual Bool isWritable() const

Is the SubLattice writable?

virtual Bool lock (FileLocker::LockType, uInt nattempts)
virtual void unlock()
virtual Bool hasLock (FileLocker::LockType) const

Handle locking of the SubLattice which is delegated to its parent.
It is strongly recommended to use class LatticeLocker to handle lattice locking. It also contains a more detailed explanation of the locking process.

virtual void resync()

Resynchronize the Lattice object with the lattice file. This function is only useful if no read-locking is used, ie. if the table lock option is UserNoReadLocking or AutoNoReadLocking. In that cases the table system does not acquire a read-lock, thus does not synchronize itself automatically.

virtual void flush()

Flush the data.

virtual void tempClose()

Close the Lattice temporarily (if it is paged to disk). It'll be reopened automatically when needed or when reopen is called explicitly.

virtual void reopen()

If needed, reopen a temporarily closed Lattice.

virtual Bool hasPixelMask() const

Does the SubLattice have a pixelmask?

virtual const Lattice<Bool>& pixelMask() const
virtual Lattice<Bool>& pixelMask()

Get access to the pixelmask. An exception is thrown if the SubLattice does not have a pixelmask.

void setPixelMask (const Lattice<Bool>& pixelMask, Bool mayExist)

Use the given mask as the pixelmask. If another mask was already used, the new one will be used instead. It checks if its shape matches the shape of the sublattice.
If mayExist=False, setting the pixelmask is only possible if the underlying lattice does not have a pixelmask.
If mayExist=True, the resulting pixelmask is the AND of the given pixelmask and the pixelmask of the underlying lattice.

virtual const LatticeRegion* getRegionPtr() const

Get a pointer the region/mask object describing this sublattice.

virtual IPosition shape() const

Returns the shape of the SubLattice including all degenerate axes (i.e. axes with a length of one).

virtual String name (Bool stripPath=False) const

Return the name of the parent lattice.

virtual uInt advisedMaxPixels() const

This function returns the recommended maximum number of pixels to include in the cursor of an iterator.

virtual T getAt (const IPosition& where) const
virtual void putAt (const T& value, const IPosition& where)

Get or put a single element in the lattice.

virtual Bool ok() const

Check class internals - used for debugging. Should always return True

virtual LatticeIterInterface<T>* makeIter (const T& navigator, Bool useRef) const

This function is used by the LatticeIterator class to generate an iterator of the correct type for this Lattice. Not recommended for general use.

virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section)

Do the actual getting of an array of values.

virtual void doPutSlice (const Array<T>& sourceBuffer, const IPosition& where, const IPosition& stride)

Do the actual getting of an array of values.

virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section)

Get a section of the mask.

virtual IPosition doNiceCursorShape (uInt maxPixels) const

Get the best cursor shape.

const AxesMapping& getAxesMap() const

Set the axes mapping from the specification.

void setPtr (Lattice<T>* latticePtr, MaskedLattice<T>* maskLatPtr, Bool writableIfPossible)

Set the various pointer needed to construct the object. One of the pointers should be zero. It takes over the pointer and deletes the object in the destructor.

void setRegion (const LatticeRegion& region)
void setRegion (const Slicer& slicer)
void setRegion()

Set the region object. It also fills in the parent pointer when the SubLattice is taken from a MaskedLattice. The default region is the entire lattice.

void setAxesMap (const AxesSpecifier&)

Set the axes mapping from the specification.

Bool getRegionDataSlice (Array<Bool>& buffer, const Slicer& section)
Bool getMaskDataSlice (Array<Bool>& buffer, const Slicer& section)

Get mask data from region and mask.

void andMask (Array<Bool>& buffer, Bool ref, const Array<Bool>& tmpbuf) const

And tmpbuf into buffer. If buffer is a reference, first a copy is made.