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
// Create a temporary lattice and initialize to 0. TempLattice<Float> myLat (IPosition(2,1024,1024)); myLat.set (0.); // Temporarily close the lattice. myLat.tempClose(); // Do an operation, which will automatically reopen the lattice. myLat.set (1.); // Note that the destructor deletes the table (if the TempLattice // was created on disk).
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.
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.
The destructor removes the Lattice from memory and if necessary disk.
The assignment operator with reference semantics. As with the copy constructor assigning by value does not make sense.
Make a copy of the object (reference semantics).
Is the TempLattice paged to disk?
Can the lattice data be referenced as an array section?
Is the TempLattice writable? It should be.
Flush the data.
Close the Lattice temporarily (if it is paged to disk). It'll be reopened automatically when needed or when reopen is called explicitly.
If needed, reopen a temporarily closed TempLattice.
Return the shape of the Lattice including all degenerate axes. (ie. axes with a length of one)
Return the number of axes in this Lattice. This includes all degenerate axes.
Return the total number of elements in this Lattice.
Set all of the elements in the Lattice to the given value.
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.
This function returns the recommended maximum number of pixels to include in the cursor of an iterator.
Get the best cursor shape.
Maximum size - not necessarily all used. In pixels.
Set the maximum (allowed) cache size as indicated.
Set the cache size as to "fit" the indicated path.
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.
Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSize was called
Report on cache success.
Get or put a single element in the lattice. Note that Lattice::operator() can also be used to get a single element.
Check class internals - used for debugging. Should always return True
This function is used by the LatticeIterator class to generate an iterator of the correct type for this Lattice. Not recommended for general use.
Do the actual getting of an array of values.
Do the actual getting of an array of values.
Make sure that the temporary table gets deleted.