Next Previous Contents

3. High Level API

3.1 h5_new

Synopsis

Create a new HDF5 file

Usage

 file_id = h5_new(name, [,access_flags]) 

Description

This function attempts to create & open the named file and return a corresponding handle/file id. The access flags may be either H5F_ACC_EXCL or H5F_ACC_TRUNC: the first causes an error to be thrown if the file already exists, while the second causes any existing file of the same name to be erased first (the default).

Notes

This function is vectorized on its first parameter: if an array of file names is passed then an array of file identifiers will be returned.

Unlike with the HDF5 C library, files do not need to be explicitly closed with SLh5; instead, they will be closed automatically when the returned handle goes out of scope.

See Also

h5_open, h5_close, h5_read

3.2 h5_open

Synopsis

Open an HDF5 file, and optionally group, dataset, or attribute

Usage

 hid_t = h5_open(name, [,access_flags]) 

Description

This function attempts to open the HDF5 file specified by name and return a corresponding handle/file id. The access flags may be either H5F_ACC_RDWR (read/write) or H5F_ACC_RDONLY (read-only, and the default if omitted).

The name parameter may optionally contain a path to an object with the file being opened. For example, d = h5_open("test.h5:/G/D") opens the file test.h5, the group G, and the dataset D, assigning an identifier for the latter to the variable d.

Notes

This function is vectorized on its first parameter: if an array of file names is passed then an array of file identifiers will be returned.

Unlike with the HDF5 C library, files do not need to be explicitly closed with SLh5; instead, they will be closed automatically when the returned handle goes out of scope.

See Also

h5_read, h5_close

3.3 h5_close

Synopsis

Close an HDF5 file

Usage

 h5_close(file_id) 

Description

This function will close the HDF5 file associated with the specified file id.

Notes

This function is vectorized: if an array of file ids is passed then the file associated with each element will be closed.

Unlike with the HDF5 C library, files do not need to be explicitly closed with SLh5; instead, they will be closed automatically when the returned handle goes out of scope.

See Also

h5_open

3.4 h5_read

Synopsis

Read an HDF5 dataset into a S-Lang array

Usage

array = h5_read(from [, dataset_or_attribute_name])

Description

This function will read an HDF5 dataset or attribute into a S-Lang array of the appropriate type. The from parameter may be any string acceptable to h5_open() or any valid HDF5 identifier (such as might be returned by h5_open, H5Dopen, or other open calls). If no dataset or attribute name is supplied the routine will attempt to open the first dataset it can find within the root group hierarchy.

Notes

This function is vectorized on either its first or second parameter: if an array is passed for either then an array (e.g. of arrays) of commensurate size will be returned. A dataset/attribute name of "*" may be used as shorthand for "everything," in which case a vectored value will be returned, containing all datasets or attributes in the given container.

Partial I/O is not yet supported.

See Also

h5_write

3.5 h5_write

Synopsis

Create an HDF5 file, dataset, or attribute from a S-Lang object

Usage

 h5_write(to, data [,name [, kind ]])

Description

This function attempts to create a new dataset or attribute in the HDF5 file specified by the to parameter, which may either a file name or an HDF5 identifier associated with an open file. Named files will be created if they don't already exist, or overwritten if they do. The data parameter is typically an array of values. If a name is not specified then if a dataset is created it will have the same name as the file, minus any extension. If kind is not specified a dataset object will be written, otherwise H5I_DATASET or H5I_ATTR may be specified to explicitly request that either a dataset or attribute be created.

Notes

Writing compound types is currently unsupported.

See Also

h5_new

3.6 h5_list

Synopsis

List named members of an HDF5 file, group, or dataset

Usage

 StringType[] = h5_list(from [,flags])

Description

This function may be used to browse the contents of an HDF5 container, and is loosely analogous to the h5dump utility. The from parameter may either be a file name or an identifier associated with an opened HDF5 object. The flags option may be any OR-ed combination of H5_LIST_OBJECTS, H5_LIST_ATTRIBUTES, or H5_LIST_RECURSE; a value of H5_LIST_OBJECTS | H5_LIST_ATTRIBUTES will be assigned to flags when it is omitted.

Notes

Recursive listing has not been implemented yet; only one level of the container object hierarchy may be inspected at a time.

See Also

h5_open

3.7 read_amr

Synopsis

Load FLASH HDF5 adaptive mesh refinement simulation

Usage

(tree, params, unknowns) = read_amr(file [, variable_name])

Description

This function attempts to read FLASH simulation data, in the form of an adaptive mesh, from the given file. If variable_name is specified only a single simulation unknown is loaded, otherwise all unknowns will be loaded. Upon success three S-Lang structures are returned.

Notes

This is a S-Lang translation of read_amr.pro contained in the FLASH IDL(tm) package (FIDLR3). Consult the FLASH documentation for details.

See Also

SLh5, h5_open, h5_read


Next Previous Contents