casacore
|
#include <TempLattice.h>
Public Member Functions | |
TempLattice () | |
The default constructor creates a TempLattice containing a default ArrayLattice object. More... | |
TempLattice (const TiledShape &shape, Int maxMemoryInMB=-1) | |
Create a TempLattice of the specified shape. More... | |
TempLattice (const TiledShape &shape, Double maxMemoryInMB) | |
TempLattice (const TempLattice< T > &other) | |
The copy constructor uses reference semantics. More... | |
virtual | ~TempLattice () |
The destructor removes the Lattice from memory and if necessary disk. More... | |
TempLattice< T > & | operator= (const TempLattice< T > &other) |
The assignment operator with reference semantics. More... | |
virtual Lattice< T > * | clone () const |
Make a copy of the object (reference semantics). More... | |
virtual Bool | isPaged () const |
Is the TempLattice paged to disk? More... | |
virtual Bool | canReferenceArray () const |
Can the lattice data be referenced as an array section? More... | |
virtual Bool | isWritable () const |
Is the TempLattice writable? It should be. More... | |
virtual void | flush () |
Flush the data. More... | |
virtual void | tempClose () |
Close the Lattice temporarily (if it is paged to disk). More... | |
virtual void | reopen () |
If needed, reopen a temporarily closed TempLattice. More... | |
virtual IPosition | shape () const |
Return the shape of the Lattice including all degenerate axes. More... | |
virtual void | set (const T &value) |
Set all of the elements in the Lattice to the given value. More... | |
virtual void | apply (T(*function)(T)) |
Replace every element, x, of the Lattice with the result of f(x). More... | |
virtual void | apply (T(*function)(const T &)) |
virtual void | apply (const Functional< T, T > &function) |
virtual uInt | advisedMaxPixels () const |
This function returns the recommended maximum number of pixels to include in the cursor of an iterator. More... | |
virtual IPosition | doNiceCursorShape (uInt maxPixels) const |
Get the best cursor shape. More... | |
virtual uInt | maximumCacheSize () const |
Maximum size - not necessarily all used. More... | |
virtual void | setMaximumCacheSize (uInt howManyPixels) |
Set the maximum (allowed) cache size as indicated. More... | |
virtual void | setCacheSizeFromPath (const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath) |
Set the cache size as to "fit" the indicated path. More... | |
virtual void | setCacheSizeInTiles (uInt howManyTiles) |
Set the actual cache size for this Array to be be big enough for the indicated number of tiles. More... | |
virtual void | clearCache () |
Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSize was called. More... | |
virtual void | showCacheStatistics (ostream &os) const |
Report on cache success. More... | |
virtual T | getAt (const IPosition &where) const |
Get or put a single element in the lattice. More... | |
virtual void | putAt (const T &value, const IPosition &where) |
Put the value of a single element. More... | |
virtual Bool | ok () const |
Check class internals - used for debugging. More... | |
virtual LatticeIterInterface< T > * | makeIter (const LatticeNavigator &navigator, Bool useRef) const |
This function is used by the LatticeIterator class to generate an iterator of the correct type for this Lattice. More... | |
virtual Bool | doGetSlice (Array< T > &buffer, const Slicer §ion) |
Do the actual getting of an array of values. More... | |
virtual void | doPutSlice (const Array< T > &sourceBuffer, const IPosition &where, const IPosition &stride) |
Do the actual getting of an array of values. More... | |
Public Member Functions inherited from casacore::Lattice< T > | |
virtual | ~Lattice () |
a virtual destructor is needed so that it will use the actual destructor in the derived class More... | |
virtual DataType | dataType () const |
Get the data type of the lattice. More... | |
T | operator() (const IPosition &where) const |
Return the value of the single element located at the argument IPosition. More... | |
Bool | get (COWPtr< Array< T > > &buffer, Bool removeDegenerateAxes=False) const |
Functions which extract an Array of values from a Lattice. More... | |
Bool | getSlice (COWPtr< Array< T > > &buffer, const Slicer §ion, Bool removeDegenerateAxes=False) const |
Bool | getSlice (COWPtr< Array< T > > &buffer, const IPosition &start, const IPosition &shape, Bool removeDegenerateAxes=False) const |
Bool | getSlice (COWPtr< Array< T > > &buffer, const IPosition &start, const IPosition &shape, const IPosition &stride, Bool removeDegenerateAxes=False) const |
Bool | get (Array< T > &buffer, Bool removeDegenerateAxes=False) |
Bool | getSlice (Array< T > &buffer, const Slicer §ion, Bool removeDegenerateAxes=False) |
Bool | getSlice (Array< T > &buffer, const IPosition &start, const IPosition &shape, Bool removeDegenerateAxes=False) |
Bool | getSlice (Array< T > &buffer, const IPosition &start, const IPosition &shape, const IPosition &stride, Bool removeDegenerateAxes=False) |
Array< T > | get (Bool removeDegenerateAxes=False) const |
Array< T > | getSlice (const Slicer §ion, Bool removeDegenerateAxes=False) const |
Array< T > | getSlice (const IPosition &start, const IPosition &shape, Bool removeDegenerateAxes=False) const |
Array< T > | getSlice (const IPosition &start, const IPosition &shape, const IPosition &stride, Bool removeDegenerateAxes=False) const |
void | putSlice (const Array< T > &sourceBuffer, const IPosition &where, const IPosition &stride) |
A function which places an Array of values within this instance of the Lattice at the location specified by the IPosition "where", incrementing by "stride". More... | |
void | putSlice (const Array< T > &sourceBuffer, const IPosition &where) |
void | put (const Array< T > &sourceBuffer) |
void | operator+= (const Lattice< T > &other) |
Add, subtract, multiple, or divide by another Lattice. More... | |
void | operator-= (const Lattice< T > &other) |
void | operator*= (const Lattice< T > &other) |
void | operator/= (const Lattice< T > &other) |
virtual void | copyData (const Lattice< T > &from) |
Copy the data from the given lattice to this one. More... | |
virtual void | copyDataTo (Lattice< T > &to) const |
Copy the data from this lattice to the given lattice. More... | |
Public Member Functions inherited from casacore::LatticeBase | |
virtual | ~LatticeBase () |
A virtual destructor is needed so that it will use the actual destructor in the derived class. More... | |
virtual String | imageType () const |
Get the image type (returns name of derived class). More... | |
virtual Bool | isPersistent () const |
Is the lattice persistent and can it be loaded by other processes as well? That is the case for a PagedArray or PagedImage and for an ImageExpr which does not use transient lattices or regions. More... | |
virtual void | save (const String &fileName) const |
Save the image in an AipsIO file with the given name. More... | |
virtual Bool | lock (FileLocker::LockType, uInt nattempts) |
It is strongly recommended to use class LatticeLocker to handle lattice locking. More... | |
virtual void | unlock () |
virtual Bool | hasLock (FileLocker::LockType) const |
virtual void | resync () |
Resynchronize the Lattice object with the lattice file. More... | |
virtual String | name (Bool stripPath=False) const |
Return the name of the current Lattice object. More... | |
virtual uInt | ndim () const |
Return the number of axes in this Lattice. More... | |
virtual size_t | nelements () const |
Return the total number of elements in this Lattice. More... | |
size_t | size () const |
Bool | conform (const LatticeBase &other) const |
Return a value of "True" if this instance of Lattice and 'other' have the same shape, otherwise returns a value of "False". More... | |
virtual LELCoordinates | lelCoordinates () const |
Return the coordinates of the lattice. More... | |
IPosition | niceCursorShape (uInt maxPixels) const |
Returns a recommended cursor shape for iterating through all the pixels in the Lattice. More... | |
IPosition | niceCursorShape () const |
Private Attributes | |
CountedPtr< TempLatticeImpl< T > > | itsImpl |
Additional Inherited Members | |
Protected Member Functions inherited from casacore::Lattice< T > | |
Lattice () | |
Define default constructor to satisfy compiler. More... | |
virtual void | handleMath (const Lattice< T > &from, int oper) |
Handle the Math operators (+=, -=, *=, /=). More... | |
virtual void | handleMathTo (Lattice< T > &to, int oper) const |
Lattice (const Lattice< T > &) | |
Copy constructor and assignment can only be used by derived classes. More... | |
Lattice< T > & | operator= (const Lattice< T > &) |
void | handleMathTo (Lattice< Bool > &, int) const |
Protected Member Functions inherited from casacore::LatticeBase | |
LatticeBase () | |
Define default constructor to be used by derived classes. More... | |
LatticeBase (const LatticeBase &) | |
Copy constructor and assignment can only be used by derived classes. More... | |
LatticeBase & | operator= (const LatticeBase &) |
void | throwBoolMath () const |
Throw an exception for arithmetic on a Bool Lattice. More... | |
A Lattice that can be used for temporary storage
Public interface
A TempLattice disappears from both memory and disk when it goes out of scope. Hence it is only useful for temporary storage of data.
Lattice classes are designed to allow the memory-efficient handling of large amounts of data. But they can also used with much smaller arrays. With large amounts of data the PagedArray class should be used, as this will store the data on disk and efficiently access specified portions of the data on request. With small amounts of data the ArrayLattice class should be used as all the data is always in memory avoiding the I/O associated with PagedArrays.
Applications often cannot predict until run time whether they will be dealing with a large or small amount of data. So the use of a PagedArray or an ArrayLattice cannot be made until the size of the arrays are known. TempLattice makes this decision given the size of the Array. To help in making a good choice the TempLattice class also examines how much memory the operating system has (using an aipsrc variable) and compares it with the size of the requested Array.
The algorithm currently used is: create an ArrayLattice if the size of the array is less than a quarter of the total system memory; otherwise a PagedArray is created. The PagedArray is stored in the current working directory and given a unique name that contains the string "pagedArray". This pagedArray will be deleted once the TempLattice goes out of scope. So unlike PagedArrays which can be made to exist longer than the time they are used by a process, the PagedArrays created by the TempLattice class are always scratch arrays.
It is possible to temporarily close a TempLattice, which only takes effect when it is created as a PagedArray. In this way it is possible to reduce the number of open files in case a lot of TempLattice objects are used. A temporarily closed TempLattice will be reopened automatically when needed. It can also be reopened explicitly.
You can force the TempLattice to be disk based by setting the memory argument in the constructors to 0
TempLattice is implemented using TempLatticeImpl for reasons explained in that class.
I needed a temporary Lattice when converting the Convolver class to using Lattices. This was to store the Transfer function.
Definition at line 132 of file TempLattice.h.
|
inline |
The default constructor creates a TempLattice containing a default ArrayLattice object.
Definition at line 137 of file TempLattice.h.
|
inlineexplicit |
Create a TempLattice of the specified shape.
You can specify how much memory the Lattice can consume before it becomes disk based by giving a non-negative value to the maxMemoryInMB argument. Otherwise it will assume it can use up to 25% of the memory on your machine as defined in aipsrc (this algorithm may change). Setting maxMemoryInMB to zero will force the lattice to disk.
Definition at line 147 of file TempLattice.h.
|
inline |
Definition at line 149 of file TempLattice.h.
|
inline |
The copy constructor uses reference semantics.
ie modifying data in the copied TempLattice also modifies the data in the original TempLattice. Passing by value doesn't make sense, because it may require the creation of a temporary (but possibly huge) file on disk.
Definition at line 157 of file TempLattice.h.
|
virtual |
The destructor removes the Lattice from memory and if necessary disk.
|
virtual |
This function returns the recommended maximum number of pixels to include in the cursor of an iterator.
Reimplemented from casacore::Lattice< T >.
|
virtual |
Reimplemented from casacore::Lattice< T >.
|
virtual |
Reimplemented from casacore::Lattice< T >.
|
virtual |
Replace every element, x, of the Lattice with the result of f(x).
You must pass in the address of the function – so the function must be declared and defined in the scope of your program. All versions of apply require a function that accepts a single argument of type T (the Lattice template type) and return a result of the same type. The first apply expects a function with an argument passed by value; the second expects the argument to be passed by const reference; the third requires an instance of the class Functional<T,T>
. The first form ought to run faster for the built-in types, which may be an issue for large Lattices stored in memory, where disk access is not an issue.
Reimplemented from casacore::Lattice< T >.
|
virtual |
Can the lattice data be referenced as an array section?
Reimplemented from casacore::LatticeBase.
|
virtual |
Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSize was called.
Reimplemented from casacore::LatticeBase.
|
virtual |
Make a copy of the object (reference semantics).
Implements casacore::Lattice< T >.
|
virtual |
Do the actual getting of an array of values.
Implements casacore::Lattice< T >.
|
virtual |
Get the best cursor shape.
Reimplemented from casacore::LatticeBase.
|
virtual |
Do the actual getting of an array of values.
Implements casacore::Lattice< T >.
|
virtual |
Flush the data.
Reimplemented from casacore::LatticeBase.
|
virtual |
Get or put a single element in the lattice.
Note that Lattice::operator() can also be used to get a single element.
Reimplemented from casacore::Lattice< T >.
|
virtual |
Is the TempLattice paged to disk?
Reimplemented from casacore::LatticeBase.
|
virtual |
Is the TempLattice writable? It should be.
Reimplemented from casacore::LatticeBase.
|
virtual |
This function is used by the LatticeIterator class to generate an iterator of the correct type for this Lattice.
Not recommended for general use.
Reimplemented from casacore::Lattice< T >.
|
virtual |
|
virtual |
Check class internals - used for debugging.
Should always return True
Reimplemented from casacore::LatticeBase.
|
inline |
The assignment operator with reference semantics.
As with the copy constructor assigning by value does not make sense.
Definition at line 165 of file TempLattice.h.
References casacore::TempLattice< T >::itsImpl.
|
virtual |
Put the value of a single element.
The default implementation uses putSlice.
Reimplemented from casacore::Lattice< T >.
|
virtual |
If needed, reopen a temporarily closed TempLattice.
Reimplemented from casacore::LatticeBase.
|
virtual |
Set all of the elements in the Lattice to the given value.
Reimplemented from casacore::Lattice< T >.
|
virtual |
Set the cache size as to "fit" the indicated path.
Reimplemented from casacore::LatticeBase.
|
virtual |
Set the actual cache size for this Array to be be big enough for the indicated number of tiles.
This cache is not shared with PagedArrays in other rows and is always clipped to be less than the maximum value set using the setMaximumCacheSize member function. tiles. Tiles are cached using a first in first out algorithm.
Reimplemented from casacore::LatticeBase.
|
virtual |
Set the maximum (allowed) cache size as indicated.
Reimplemented from casacore::LatticeBase.
|
virtual |
Return the shape of the Lattice including all degenerate axes.
(ie. axes with a length of one)
Implements casacore::LatticeBase.
|
virtual |
Report on cache success.
Reimplemented from casacore::LatticeBase.
|
virtual |
Close the Lattice temporarily (if it is paged to disk).
It'll be reopened automatically when needed or when reopen
is called explicitly.
Reimplemented from casacore::LatticeBase.
|
private |
Definition at line 273 of file TempLattice.h.
Referenced by casacore::TempLattice< T >::operator=().