casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Member Functions | Private Attributes
casa::HDF5Lattice< T > Class Template Reference

A Lattice that is read from or written to an HDF5 dataset. More...

#include <HDF5Lattice.h>

Inheritance diagram for casa::HDF5Lattice< T >:
casa::Lattice< T > casa::LatticeBase

List of all members.

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 StringarrayName () 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 &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 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< HDF5FileitsFile
CountedPtr< HDF5GroupitsGroup
CountedPtr< HDF5DataSetitsDataSet

Detailed Description

template<typename T>
class casa::HDF5Lattice< T >

A Lattice that is read from or written to an HDF5 dataset.

Intended use:

Public interface

Review Status

Test programs:
tHDF5Lattice

Prerequisite

Synopsis

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):

  1. Use a LatticeIterator
  2. Use the getSlice and putSlice member functions
  3. Use the parenthesis operator or getAt and putAt functions

Class PagedArray contains some more info and examples.

Example

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. 

Motivation

There was a need to be able to use HDF5 files to hold image data.

Template Type Argument Requirements (T)

Definition at line 108 of file HDF5Lattice.h.


Constructor & Destructor Documentation

template<typename T>
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.

template<typename T>
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.

template<typename T>
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.

template<typename T>
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.

template<typename T>
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.

template<typename T>
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.

template<typename T>
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.

template<typename T>
casa::HDF5Lattice< T >::~HDF5Lattice ( )

The destructor flushes the HDF5Lattice's contents to disk.


Member Function Documentation

template<typename T>
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 >.

template<typename T>
const String& casa::HDF5Lattice< T >::arrayName ( ) const [inline]

Returns the name of this HDF5Lattice.

Definition at line 192 of file HDF5Lattice.h.

template<typename T>
void casa::HDF5Lattice< T >::checkWritable ( ) const [private]

Check if the file is writable.

template<typename T>
virtual Lattice<T>* casa::HDF5Lattice< T >::clone ( ) const [virtual]

Make a copy of the object (reference semantics).

Implements casa::Lattice< T >.

template<typename 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 >.

template<typename T>
virtual IPosition casa::HDF5Lattice< T >::doNiceCursorShape ( uInt  maxPixels) const [virtual]

Get the best cursor shape.

Reimplemented from casa::LatticeBase.

template<typename T>
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 >.

template<typename T>
const CountedPtr<HDF5File>& casa::HDF5Lattice< T >::file ( ) const [inline]

Return the current HDF5File object.

Definition at line 188 of file HDF5Lattice.h.

template<typename T>
virtual void casa::HDF5Lattice< T >::flush ( ) [virtual]

Flush the data (but do not unlock).

Reimplemented from casa::LatticeBase.

template<typename T>
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 >.

template<typename T>
virtual Bool casa::HDF5Lattice< T >::isPaged ( ) const [virtual]

A HDF5Lattice is always paged to disk.

Reimplemented from casa::LatticeBase.

template<typename T>
virtual Bool casa::HDF5Lattice< T >::isPersistent ( ) const [virtual]

A HDF5Lattice is always persistent.

Reimplemented from casa::LatticeBase.

template<typename T>
virtual Bool casa::HDF5Lattice< T >::isWritable ( ) const [virtual]

Is the HDF5Lattice writable?

Reimplemented from casa::LatticeBase.

template<typename T>
void casa::HDF5Lattice< T >::makeArray ( const TiledShape shape,
const String arrayName,
const String groupName 
) [private]

Make the Array in the HDF5 file and group.

template<typename T>
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 >.

template<typename 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.

template<typename T>
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.

template<typename T>
void casa::HDF5Lattice< T >::openArray ( const String arrayName,
const String groupName 
) [private]

Open the Array in the HDF5 file and group.

template<typename T>
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.

template<typename T>
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 >.

template<typename 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.

template<typename T>
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.

template<typename T>
virtual IPosition casa::HDF5Lattice< T >::shape ( ) const [virtual]

Returns the shape of the HDF5Lattice.

Implements casa::LatticeBase.

template<typename T>
IPosition casa::HDF5Lattice< T >::tileShape ( ) const

Returns the current tile shape for this HDF5Lattice.


Member Data Documentation

template<typename T>
CountedPtr<HDF5DataSet> casa::HDF5Lattice< T >::itsDataSet [private]

Definition at line 259 of file HDF5Lattice.h.

Referenced by casa::HDF5Lattice< Bool >::arrayName().

template<typename T>
CountedPtr<HDF5File> casa::HDF5Lattice< T >::itsFile [private]

Definition at line 257 of file HDF5Lattice.h.

Referenced by casa::HDF5Lattice< Bool >::file().

template<typename T>
CountedPtr<HDF5Group> casa::HDF5Lattice< T >::itsGroup [private]

Definition at line 258 of file HDF5Lattice.h.


The documentation for this class was generated from the following file: