casa
$Rev:20696$
|
A Lattice that is read from or written to an HDF5 dataset. More...
#include <HDF5Lattice.h>
Public Member Functions | |
HDF5Lattice () | |
The default constructor creates an HDF5Lattice that is useless for just about everything, except that it can be assigned to with the assignment operator. | |
HDF5Lattice (const TiledShape &shape, const String &filename, const String &arrayName="array", const String &groupName=String()) | |
Construct a new HDF5Lattice with the specified shape. | |
HDF5Lattice (const TiledShape &shape) | |
Construct a temporary HDF5Lattice with the specified shape. | |
HDF5Lattice (const TiledShape &shape, const CountedPtr< HDF5File > &file, const String &arrayName, const String &groupName=String()) | |
Construct a new HDF5Lattice, with the specified shape, in the given HDF5 file. | |
HDF5Lattice (const String &fileName, const String &arrayName="array", const String &groupName=String()) | |
Reconstruct from a pre-existing HDF5Lattice in the HDF5 file and group with the given names. | |
HDF5Lattice (const CountedPtr< HDF5File > &file, const String &arrayName, const String &groupName=String()) | |
Reconstruct from a pre-existing HDF5Lattice in the HDF5 file and group with the given name. | |
HDF5Lattice (const HDF5Lattice< T > &other) | |
The copy constructor which uses reference semantics. | |
~HDF5Lattice () | |
The destructor flushes the HDF5Lattice's contents to disk. | |
HDF5Lattice< T > & | operator= (const HDF5Lattice< T > &other) |
The assignment operator with reference semantics. | |
virtual Lattice< T > * | clone () const |
Make a copy of the object (reference semantics). | |
virtual Bool | isPersistent () const |
A HDF5Lattice is always persistent. | |
virtual Bool | isPaged () const |
A HDF5Lattice is always paged to disk. | |
virtual Bool | isWritable () const |
Is the HDF5Lattice writable? | |
virtual IPosition | shape () const |
Returns the shape of the HDF5Lattice. | |
virtual String | name (Bool stripPath=False) const |
Return the current HDF5 file name. | |
const CountedPtr< HDF5File > & | file () const |
Return the current HDF5File object. | |
const String & | arrayName () const |
Returns the name of this HDF5Lattice. | |
IPosition | tileShape () const |
Returns the current tile shape for this HDF5Lattice. | |
virtual void | setCacheSizeInTiles (uInt howManyTiles) |
Set the actual cache size for this Array to be big enough for the indicated number of tiles. | |
virtual void | setCacheSizeFromPath (const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath) |
Set the cache size as to "fit" the indicated access pattern. | |
virtual T | getAt (const IPosition &where) const |
Return the value of the single element located at the argument IPosition. | |
virtual void | putAt (const T &value, const IPosition &where) |
Put the value of a single element. | |
virtual Bool | ok () const |
A function which checks for internal consistency. | |
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 a specified Lattice. | |
virtual Bool | doGetSlice (Array< T > &buffer, const Slicer §ion) |
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 uInt | advisedMaxPixels () const |
Returns the maximum recommended number of pixels for a cursor. | |
virtual IPosition | doNiceCursorShape (uInt maxPixels) const |
Get the best cursor shape. | |
virtual void | flush () |
Flush the data (but do not unlock). | |
Private Member Functions | |
void | makeArray (const TiledShape &shape, const String &arrayName, const String &groupName) |
Make the Array in the HDF5 file and group. | |
void | openArray (const String &arrayName, const String &groupName) |
Open the Array in the HDF5 file and group. | |
void | checkWritable () const |
Check if the file is writable. | |
Private Attributes | |
CountedPtr< HDF5File > | itsFile |
CountedPtr< HDF5Group > | itsGroup |
CountedPtr< HDF5DataSet > | itsDataSet |
A Lattice that is read from or written to an HDF5 dataset.
Public interface
Astronomical data arrays (like images) have to be persistent. A Lattice is a templated abstract base class to hold any AIPS++ array. The PagedArray class is a Lattice specialization which stores the data in an AIPS++ table.
HDF5Lattice ia another Lattice specialization making it possible to store an array as a dataset in a group in an HDF5 file.
When you construct an HDF5Lattice you do not read any data into memory. Instead an HDF5 disk file is created, in a place you specify, to hold the data. This means you need to have enough disk space to hold the array. Constructing a new HDF5Lattice is equivalent to creating a data set in an HDF5 file.
To access the data in a HDF5Lattice you can (in order of preference):
Class PagedArray contains some more info and examples.
Create a HDF5Lattice of Floats of shape [1024,1024,4,256] in a file called "myData_tmp.array" and initialize it to zero.
const IPosition arrayShape(4,1024,1024,4,256); const String filename("myData_tmp.array"); HDF5Lattice<Float> diskArray(arrayShape, filename); cout << "Created a HDF5Lattice of shape " << diskArray.shape() << " (" << diskArray.shape().product()/1024/1024*sizeof(Float) << " MBytes)" << endl << "in the table called " << diskArray.tableName() << endl; diskArray.set(0.0f); // Using the set function is an efficient way to initialize the HDF5Lattice // as it uses a LatticeIterator internally. Note that the set function is // defined in the Lattice class that HDF5Lattice is derived from.
There was a need to be able to use HDF5 files to hold image data.
Definition at line 108 of file HDF5Lattice.h.
casa::HDF5Lattice< T >::HDF5Lattice | ( | ) |
The default constructor creates an HDF5Lattice that is useless for just about everything, except that it can be assigned to with the assignment operator.
casa::HDF5Lattice< T >::HDF5Lattice | ( | const TiledShape & | shape, |
const String & | filename, | ||
const String & | arrayName = "array" , |
||
const String & | groupName = String() |
||
) |
Construct a new HDF5Lattice with the specified shape.
A new HDF5 file with the specified filename is constructed to hold the array. The file will remain on disk after the HDF5Lattice goes out of scope or is deleted. Optionally the name of an HDF5 group can be given to create the array in. The group is created if not existing yet.
casa::HDF5Lattice< T >::HDF5Lattice | ( | const TiledShape & | shape | ) | [explicit] |
Construct a temporary HDF5Lattice with the specified shape.
A scratch file is created in the current working directory to hold the array. This file will be deleted automatically when the HDF5Lattice goes out of scope or is deleted.
casa::HDF5Lattice< T >::HDF5Lattice | ( | const TiledShape & | shape, |
const CountedPtr< HDF5File > & | file, | ||
const String & | arrayName, | ||
const String & | groupName = String() |
||
) |
Construct a new HDF5Lattice, with the specified shape, in the given HDF5 file.
The array gets the given name. Optionally the name of an HDF5 group can be given to create the array in. The group is created if not existing yet.
casa::HDF5Lattice< T >::HDF5Lattice | ( | const String & | fileName, |
const String & | arrayName = "array" , |
||
const String & | groupName = String() |
||
) | [explicit] |
Reconstruct from a pre-existing HDF5Lattice in the HDF5 file and group with the given names.
casa::HDF5Lattice< T >::HDF5Lattice | ( | const CountedPtr< HDF5File > & | file, |
const String & | arrayName, | ||
const String & | groupName = String() |
||
) | [explicit] |
Reconstruct from a pre-existing HDF5Lattice in the HDF5 file and group with the given name.
casa::HDF5Lattice< T >::HDF5Lattice | ( | const HDF5Lattice< T > & | other | ) |
The copy constructor which uses reference semantics.
Copying by value doesn't make sense, because it would require the creation of a temporary (but possibly huge) file on disk.
casa::HDF5Lattice< T >::~HDF5Lattice | ( | ) |
The destructor flushes the HDF5Lattice's contents to disk.
virtual uInt casa::HDF5Lattice< T >::advisedMaxPixels | ( | ) | const [virtual] |
Returns the maximum recommended number of pixels for a cursor.
This is the number of pixels in a tile.
Reimplemented from casa::Lattice< T >.
const String& casa::HDF5Lattice< T >::arrayName | ( | ) | const [inline] |
Returns the name of this HDF5Lattice.
Definition at line 192 of file HDF5Lattice.h.
void casa::HDF5Lattice< T >::checkWritable | ( | ) | const [private] |
Check if the file is writable.
virtual Lattice<T>* casa::HDF5Lattice< T >::clone | ( | ) | const [virtual] |
Make a copy of the object (reference semantics).
Implements casa::Lattice< T >.
virtual Bool casa::HDF5Lattice< T >::doGetSlice | ( | Array< T > & | buffer, |
const Slicer & | section | ||
) | [virtual] |
Do the actual getting of an array of values.
Implements casa::Lattice< T >.
virtual IPosition casa::HDF5Lattice< T >::doNiceCursorShape | ( | uInt | maxPixels | ) | const [virtual] |
Get the best cursor shape.
Reimplemented from casa::LatticeBase.
virtual void casa::HDF5Lattice< T >::doPutSlice | ( | const Array< T > & | sourceBuffer, |
const IPosition & | where, | ||
const IPosition & | stride | ||
) | [virtual] |
Do the actual getting of an array of values.
Implements casa::Lattice< T >.
const CountedPtr<HDF5File>& casa::HDF5Lattice< T >::file | ( | ) | const [inline] |
Return the current HDF5File object.
Definition at line 188 of file HDF5Lattice.h.
virtual void casa::HDF5Lattice< T >::flush | ( | ) | [virtual] |
Flush the data (but do not unlock).
Reimplemented from casa::LatticeBase.
virtual T casa::HDF5Lattice< T >::getAt | ( | const IPosition & | where | ) | const [virtual] |
Return the value of the single element located at the argument IPosition.
Note that Lattice::operator()
can also be used.
Reimplemented from casa::Lattice< T >.
virtual Bool casa::HDF5Lattice< T >::isPaged | ( | ) | const [virtual] |
A HDF5Lattice is always paged to disk.
Reimplemented from casa::LatticeBase.
virtual Bool casa::HDF5Lattice< T >::isPersistent | ( | ) | const [virtual] |
A HDF5Lattice is always persistent.
Reimplemented from casa::LatticeBase.
virtual Bool casa::HDF5Lattice< T >::isWritable | ( | ) | const [virtual] |
Is the HDF5Lattice writable?
Reimplemented from casa::LatticeBase.
void casa::HDF5Lattice< T >::makeArray | ( | const TiledShape & | shape, |
const String & | arrayName, | ||
const String & | groupName | ||
) | [private] |
Make the Array in the HDF5 file and group.
virtual LatticeIterInterface<T>* casa::HDF5Lattice< T >::makeIter | ( | const LatticeNavigator & | navigator, |
Bool | useRef | ||
) | const [virtual] |
This function is used by the LatticeIterator class to generate an iterator of the correct type for a specified Lattice.
Not recommended for general use.
Reimplemented from casa::Lattice< T >.
virtual String casa::HDF5Lattice< T >::name | ( | Bool | stripPath = False | ) | const [virtual] |
Return the current HDF5 file name.
By default this includes the full path. The path preceeding the file name can be stripped off on request.
Reimplemented from casa::LatticeBase.
virtual Bool casa::HDF5Lattice< T >::ok | ( | ) | const [virtual] |
A function which checks for internal consistency.
Returns False if something nasty has happened to the HDF5Lattice. In that case it also throws an exception.
Reimplemented from casa::LatticeBase.
void casa::HDF5Lattice< T >::openArray | ( | const String & | arrayName, |
const String & | groupName | ||
) | [private] |
Open the Array in the HDF5 file and group.
HDF5Lattice<T>& casa::HDF5Lattice< T >::operator= | ( | const HDF5Lattice< T > & | other | ) |
The assignment operator with reference semantics.
As with the copy constructor assigning by value does not make sense.
virtual void casa::HDF5Lattice< T >::putAt | ( | const T & | value, |
const IPosition & | where | ||
) | [virtual] |
Put the value of a single element.
Reimplemented from casa::Lattice< T >.
virtual void casa::HDF5Lattice< T >::setCacheSizeFromPath | ( | const IPosition & | sliceShape, |
const IPosition & | windowStart, | ||
const IPosition & | windowLength, | ||
const IPosition & | axisPath | ||
) | [virtual] |
Set the cache size as to "fit" the indicated access pattern.
Reimplemented from casa::LatticeBase.
virtual void casa::HDF5Lattice< T >::setCacheSizeInTiles | ( | uInt | howManyTiles | ) | [virtual] |
Set the actual cache size for this Array to be big enough for the indicated number of tiles.
This cache is not shared with other HDF5Lattices, Tiles are cached using an LRU algorithm.
Reimplemented from casa::LatticeBase.
virtual IPosition casa::HDF5Lattice< T >::shape | ( | ) | const [virtual] |
Returns the shape of the HDF5Lattice.
Implements casa::LatticeBase.
IPosition casa::HDF5Lattice< T >::tileShape | ( | ) | const |
Returns the current tile shape for this HDF5Lattice.
CountedPtr<HDF5DataSet> casa::HDF5Lattice< T >::itsDataSet [private] |
Definition at line 259 of file HDF5Lattice.h.
Referenced by casa::HDF5Lattice< Bool >::arrayName().
CountedPtr<HDF5File> casa::HDF5Lattice< T >::itsFile [private] |
Definition at line 257 of file HDF5Lattice.h.
Referenced by casa::HDF5Lattice< Bool >::file().
CountedPtr<HDF5Group> casa::HDF5Lattice< T >::itsGroup [private] |
Definition at line 258 of file HDF5Lattice.h.