hdf images hdf images

This web site is no longer maintained (but will remain online).
Please see The HDF Group's new Support Portal for the latest information.

HDF5 Tutorial:   Learning The Basics
Creating Groups Using Absolute and Relative Names

Contents:


Absolute vs. Relative Names

Recall that to create an HDF5 object, we have to specify the location where the object is to be created. This location is determined by the identifier of an HDF5 object and the name of the object to be created. The name of the created object can be either an absolute name or a name relative to the specified identifier. In the previous example, we used the file identifier and the absolute name /MyGroup to create a group.

In this section, we discuss HDF5 names and show how to use absolute and relative names.

Names

HDF5 object names are a slash-separated list of components. There are few restrictions on names: component names may be any length except zero and may contain any character except slash (/) and the null terminator. A full name may be composed of any number of component names separated by slashes, with any of the component names being the special name . (a dot or period). A name which begins with a slash is an absolute name which is accessed beginning with the root group of the file; all other names are relative names and and the named object is accessed beginning with the specified group. A special case is the name / (or equivalent) which refers to the root group.

Functions which operate on names generally take a location identifier, which can be either a file identifier or a group identifier, and perform the lookup with respect to that location. Several possibilities are described in the following table:

Location Type Object Name Description
File identifier
/foo/bar
The object bar in group foo in the root group.
Group identifier
/foo/bar
The object bar in group foo in the root group of the file containing the specified group. In other words, the group identifier's only purpose is to specify a file.
File identifier
/
The root group of the specified file.
Group identifier
/
The root group of the file containing the specified group.
Group identifier
foo/bar
The object bar in group foo in the specified group.
File identifier
.
The root group of the file.
Group identifier
.
The specified group.
Other identifier
.
The specified object.

Programming Example

Description

The following example code shows how to create groups using absolute and relative names. It creates three groups: the first two groups are created using the file identifier and the group absolute names while the third group is created using a group identifier and a name relative to the specified group.

See HDF5 Introductory Examples for the examples used in the Learning the Basics tutorial. There are examples for several other languages, including Java.

For details on compiling an HDF5 application: [ Compile Information ]

Remarks

File Contents

The file contents are shown below:

Fig. 9.1   The Contents of groups.h5 (groupsf.h5 for FORTRAN)

Fig. 9.2   groups.h5 in DDL (for FORTRAN, the name in the first line is groupsf.h5)

HDF5 "groups.h5" {
GROUP "/" {
 GROUP "MyGroup" {
    GROUP "Group_A" {
    }
    GROUP "Group_B" {
    }
 }
}
}


- - Last modified: 21 December 2016