Industrial Data Science
in C# and .NET:
Simple. Fast. Reliable.
 
 

ILNumerics - Technical Computing

Modern High Performance Tools for Technical

Computing and Visualization in Industry and Science

tgt

Files in ILNumerics.IO.HDF5

HDF5 files in ILNumerics are represented by H5File. H5File is a slim proxy, which provides access to the underlying HDF5 file. At the moment, this will always be a file on the local file system. Support for other drivers may be added, once required.

Open / Create

The general process of handling HDF5 data files is as follows:

Open HDF5 file Add/Access/manipulate objects in the file Close the file.

In ILNumerics this is realized as shown below:

'Using' blocks come in handy when working with H5File. All instructions, which read or write to any objects in the file, go into the body of the 'using' block. .NET ensures that even in an error situation the file will be closed and not left open after a program crash or any other abnormal execution.

By default the constructor of H5File will create the file corresponding to the name given. If the file already exists, it will be opened for read/write access.

Two optional parameters allow the specification of deviant behavior: fileMode and accessMode. Both are conform to the way file access is handled in .NET. Combined they provide more variants than those supported by HDF5. Take a look at the following table to see which parameter settings cause which access method and which combinations are not allowed, i.e. will throw an exception. The table also shows the corresponding settings chosen for the HDF5 access property list:

HDF5 File Access Compatibility Table ILNumerics

Example: In an empty directory the following sequence of H5File constructions could be processed:

File Configuration

The constructor of an H5File enables to set one more optional parameter: userblocklength with the default value 0. The file will begin to write its content from the beginning of the file on disk. Any positive numbers defined here will offset the beginning of the HDF5 objects in the file by that number of bytes. This setting is useful, if you want to add additional non-HDF5 specific data to your HDF5 file.