Skip to content

Instantly share code, notes, and snippets.

@TestSubjector
Last active September 29, 2020 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TestSubjector/d2ff68b68bf38fb2fdc012dff535fffb to your computer and use it in GitHub Desktop.
Save TestSubjector/d2ff68b68bf38fb2fdc012dff535fffb to your computer and use it in GitHub Desktop.
Sample HDF5 Content
// Given below is a view of what the HDF5 files content can look like.
// This information can be found by using the `H5DUMP` command.
// File Start
HDF5 "point/point.h5" {
GROUP "/" {
GROUP "1" {
ATTRIBUTE "total" {
DATATYPE H5T_STD_I32LE
DATASPACE SIMPLE { ( 1 ) / ( 1 ) }
DATA {
(0): 9600
}
}
GROUP "ghost" {
}
GROUP "local" {
DATASET "1" {
DATATYPE H5T_STD_I32LE
DATASPACE SIMPLE { ( 9 ) / ( 9 ) }
DATA {
(0): 160, 2, 320, 161, 162, 159, 3, 319, 163
}
ATTRIBUTE "val1" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SIMPLE { ( 5 ) / ( 5 ) }
DATA {
(0): 1, -3e-09, 3.15512e-317, 6.95279e-310, 0.000388863
}
}
ATTRIBUTE "val2" {
DATATYPE H5T_STD_I32LE
DATASPACE SIMPLE { ( 7 ) / ( 7 ) }
DATA {
(0): 1, 160, 2, 0, 1, 1, 9
}
}
}
DATASET "10" {
//
// Rest of the file contents
//
// File End

To access specific data in a HDF5 file, you need to open the enclosing attribute, dataset or group.
Groups can contain more groups or datasets and so on leading to a hierarchical structure for accessing the file data.

The sample HDF5 content shown before can then be downsized to just a relation between these attributes, datasets and groups. Simply locate the parameter you require and open it to access the data inside.

HDF5 "point/point.h5"
GROUP "/"
   GROUP "1"
      ATTRIBUTE "total"
      GROUP "ghost"
      GROUP "local"
         DATASET "1"
            ATTRIBUTE "val1"
            ATTRIBUTE "val2"
         DATASET "10" 
         
            #
            # Rest of the file contents
            #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment