Page tree

The license could not be verified: License Certificate has expired!

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Anchor
contstruct
contstruct
File Content and Structure

The h5dump and h5ls tools can both be used to view the contents of an HDF5 file. The tools are discussed below:

Anchor
h5dump
h5dump
h5dump

The h5dump tool dumps or displays the contents of an HDF5 file (textually). By default if you specify no options, h5dump will display the entire contents of a file. There are many h5dump options for examining specific details of a file. To see all of the available h5dump options, specify the -h or --help option: 

...

OptionDescriptionComment
-n, --contents
Displays a list of the objects in a fileSee  Example 1
-n 1, --contents=1
Displays a list of the objects and attributes in a fileSee  Example 6
-H, --header
Displays header information only (no data)See  Example 2
-A 0, --onlyattr=0
Suppresses the display of attributesSee  Example 2
-N P, --any_path=P
Displays any object or attribute that matches path PSee  Example 6

 

Anchor
ex1
ex1
Example 1

The following command displays a list of the objects in the file OMI-Aura.he5 (an HDF-EOS5 file):

...

HDF5 "OMI-Aura.he5" {
GROUP "/" {
   GROUP "HDFEOS" {
      GROUP "ADDITIONAL" {
         GROUP "FILE_ATTRIBUTES" {
         }
      }
      GROUP "GRIDS" {
         GROUP "OMI Column Amount O3" {
            GROUP "Data Fields" {
               DATASET "ColumnAmountO3" {
                  DATATYPE  H5T_IEEE_F32LE
                  DATASPACE  SIMPLE { ( 720, 1440 ) / ( 720, 1440 ) }
               }
               DATASET "RadiativeCloudFraction" {
                  DATATYPE  H5T_IEEE_F32LE
                  DATASPACE  SIMPLE { ( 720, 1440 ) / ( 720, 1440 ) }
               }
               DATASET "SolarZenithAngle" {
                  DATATYPE  H5T_IEEE_F32LE
                  DATASPACE  SIMPLE { ( 720, 1440 ) / ( 720, 1440 ) }
               }
               DATASET "ViewingZenithAngle" {
                  DATATYPE  H5T_IEEE_F32LE
                  DATASPACE  SIMPLE { ( 720, 1440 ) / ( 720, 1440 ) }
               }
            }
         }
      }
   }
   GROUP "HDFEOS INFORMATION" {
      DATASET "StructMetadata.0" {
         DATATYPE  H5T_STRING {
            STRSIZE 32000;
            STRPAD H5T_STR_NULLTERM;
            CSET H5T_CSET_ASCII;
            CTYPE H5T_C_S1;
         }
         DATASPACE  SCALAR
      }
   }
}
}

 

Anchor
h5ls
h5ls
h5ls

The h5ls tool by default just displays the objects in the root group. It will not display items in groups beneath the root group unless specified. Useful h5ls options for viewing file content and structure are:

OptionDescriptionComment
-r
Lists all groups and objects recursivelySee  Example 3
-v
Generates verbose output (lists dataset properties, attributes 
and attribute values, but no dataset values)
 

...

/                        Group
/HDFEOS                  Group
/HDFEOS/ADDITIONAL       Group
/HDFEOS/ADDITIONAL/FILE_ATTRIBUTES Group
/HDFEOS/GRIDS            Group
/HDFEOS/GRIDS/OMI\ Column\ Amount\ O3 Group
/HDFEOS/GRIDS/OMI\ Column\ Amount\ O3/Data\ Fields Group
/HDFEOS/GRIDS/OMI\ Column\ Amount\ O3/Data\ Fields/ColumnAmountO3 Dataset {720, 1440}
/HDFEOS/GRIDS/OMI\ Column\ Amount\ O3/Data\ Fields/RadiativeCloudFraction Dataset {720, 1440}
/HDFEOS/GRIDS/OMI\ Column\ Amount\ O3/Data\ Fields/SolarZenithAngle Dataset {720, 1440}
/HDFEOS/GRIDS/OMI\ Column\ Amount\ O3/Data\ Fields/ViewingZenithAngle Dataset {720, 1440}
/HDFEOS\ INFORMATION     Group
/HDFEOS\ INFORMATION/StructMetadata.0 Dataset {SCALAR}

 

...

Anchor
dataset
dataset
Datasets and Dataset Properties

Both h5dump and h5ls can be used to view specific datasets.

Anchor
dh5dump
dh5dump
h5dump

Useful h5dump options for examining specific datasets include:

OptionDescriptionComment
 -d D, --dataset=D
Displays dataset DSee  Example 4
 -H, --header
Displays header information onlySee  Example 4
 -p, --properties
Displays dataset filters, storage layout, and fill value propertiesSee  Example 5
 -A 0, --onlyattr=0
Suppresses the display of attributesSee  Example 2
-N P, --any_path=P
Displays any object or attribute that matches path PSee  Example 6

 

Anchor
ex4
ex4
Example 4

A specific dataset can be viewed with h5dump using the -d D option and specifying the entire path and name of the dataset for D. The path is important in identifying the correct dataset, as there can be multiple datasets with the same name. The path can be determined by looking at the objects in the file with h5dump -n.

...

You can obtain the h5ex_d_gzip.c program that created this file, as well as the file created, from the HDF5 C Examples by API page.

Anchor
dh5ls
dh5ls
h5ls

Specific datasets can be specified with h5ls by simply adding the dataset path and dataset after the file name. As an example, this command displays dataset  dset2  in the groups.h5 file used in Example 4:

...

   $ h5ls -d groups.h5/MyGroup/Group_A/dset2
   dset2                    Dataset {2, 10}
       Data:
           (0,0) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

 

...

Anchor
group
group
Groups

Both h5dump and h5ls can be used to view specific groups in a file:

Anchor
gh5dump
gh5dump
h5dump

The h5dump options that are useful for examining groups are:

...

   HDF5 "OMI-Aura.he5" {
   GROUP "/HDFEOS" {
      GROUP "ADDITIONAL" {
         GROUP "FILE_ATTRIBUTES" {
         }
      }
      GROUP "GRIDS" {
         GROUP "OMI Column Amount O3" {
            GROUP "Data Fields" {
               DATASET "ColumnAmountO3" {
                  DATATYPE  H5T_IEEE_F32LE
                  DATASPACE  SIMPLE { ( 720, 1440 ) / ( 720, 1440 ) }
               }
               DATASET "RadiativeCloudFraction" {
                  DATATYPE  H5T_IEEE_F32LE
                  DATASPACE  SIMPLE { ( 720, 1440 ) / ( 720, 1440 ) }
               }
               DATASET "SolarZenithAngle" {
                  DATATYPE  H5T_IEEE_F32LE
                  DATASPACE  SIMPLE { ( 720, 1440 ) / ( 720, 1440 ) }
               }
               DATASET "ViewingZenithAngle" {
                  DATATYPE  H5T_IEEE_F32LE
                  DATASPACE  SIMPLE { ( 720, 1440 ) / ( 720, 1440 ) }
               }
            }
         }
      }
   }
   }

 

Anchor
gh5ls
gh5ls
h5ls

You can view the contents of a group with h5ls by specifying the group after the file name. To use h5ls to view the contents of the  /HDFEOS  group in the OMI-Aura.he5 file, type:

...

If you specify the -v option, you can also see the attributes and properties of the datasets.

...

Anchor
attribute
attribute
Attributes

h5ls

If you include the -v (verbose) option for h5ls, you will see all of the attributes for the specified file, dataset or group. You cannot display individual attributes.

h5dump

Attributes are displayed by default if using h5dump. Some files contain many attributes, which can make it difficult to examine the objects in the file. Shown below are options that can help when using h5dump to work with files that have attributes.

OptionDescriptionComment
-a A, --attribute=A
Displays attribute ASee  Example 6
-A 0, --onlyattr=0
Suppresses the display of attributesSee  Example 2
-n 1, --contents=1
Lists file contents with attributesSee  Example 6
-N P, --any_path=P
Displays any object or attribute that matches path PSee  Example 6


Anchor
ex6
ex6
Example 6

The -a A option will display an attribute. However, the path to the attribute must be included when specifying this option. For example, to see the ScaleFactor attribute in the OMI-Aura.he5 file, type:

...

HDF5 "OMI-Aura.he5" {
ATTRIBUTE "ScaleFactor" {
   DATATYPE  H5T_IEEE_F64LE
   DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
   DATA {
   (0): 1
   }
}
ATTRIBUTE "ScaleFactor" {
   DATATYPE  H5T_IEEE_F64LE
   DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
   DATA {
   (0): 1
   }
}
ATTRIBUTE "ScaleFactor" {
   DATATYPE  H5T_IEEE_F64LE
   DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
   DATA {
   (0): 1
   }
}
ATTRIBUTE "ScaleFactor" {
   DATATYPE  H5T_IEEE_F64LE
   DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
   DATA {
   (0): 1
   }
}
}

 

...

Anchor
subset
subset
Dataset Subset

h5dump

If you have a very large dataset, you may wish to subset or see just a portion of the dataset. This can be done with the following h5dump options.

...

   HDF5 "OMI-Aura.he5" {
   DATASET "HDFEOS/GRIDS/OMI Column Amount O3/Data Fields/SolarZenithAngle" {
      DATATYPE  H5T_IEEE_F32LE
      DATASPACE  SIMPLE { ( 720, 1440 ) / ( 720, 1440 ) }
      SUBSET {
         START ( 1, 0 );
         STRIDE ( 2, 3 );
         COUNT ( 3, 3 );
         BLOCK ( 2, 3 );
         DATA {
          (1,0): 79.071, 79.071, 79.071, 79.071, 79.071, 79.071, 79.071, 79.071, 79.071,
          (2,0): 78.867, 78.867, 78.867, 78.867, 78.867, 78.867, 78.867, 78.867, 78.867,
          (3,0): 78.632, 78.632, 78.632, 78.632, 78.632, 78.632, 78.632, 78.632, 78.632,
          (4,0): 78.429, 78.429, 78.429, 78.429, 78.429, 78.429, 78.429, 78.429, 78.429,
          (5,0): 78.225, 78.225, 78.225, 78.225, 78.225, 78.225, 78.225, 78.225, 78.225,
          (6,0): 78.021, 78.021, 78.021, 78.021, 78.021, 78.021, 78.021, 78.021, 78.021
         }
      }
   }
   }

 

...

Anchor
datatypes
datatypes
Datatypes

h5dump

The following datatypes are discussed, using the output of h5dump with HDF5 files from the HDF5 C Examples by API page:

 

...

Anchor
array
array
Array

Users have been confused by the difference between an Array datatype (H5T_ARRAY) and a dataset that (has a dataspace that) is an array.

...