HDF5 (.h5)

HDF data format Version 5.
General purpose format for representing multidimensional datasets and images.
Used for storage, management, and exchange of scientific data.
HDF is an acronym for Hierarchical Data Format.
Developed by the US National Center for Supercomputing Applications (NCSA).
Binary file format.
Incompatible with HDF Version 4 and earlier.
  • Import and Export support the HDF5 format.
  • The Wolfram Language reads and writes HDF5 images as data arrays.
  • Compound data structures are ignored by Import.

Import and ExportImport and Export

  • Import["file.h5"] imports an HDF5 file, returning the names of the datasets stored in the file.
  • Export["file.h5",expr] exports a numeric array to HDF5.
  • Import["file.h5"] returns a list of strings representing the names of all datasets contained in the file.
  • Export["file.h5",{expr1,},{"Datasets", {"dataset1",}}] creates an HDF5 file, storing the data arrays as separate datasets.
  • Import["file.h5",elem] imports the specified element from an HDF5 file.
  • Import["file.h5",{elem,suba,subb,}] imports a subelement.
  • Import["file.h5",{{elem1,elem2,}}] imports multiple elements.
  • The import format can be specified with Import["file","HDF5"] or Import["file",{"HDF5",elem,}].
  • Export["file.h5",expr, elem] creates an HDF5 file by treating expr as specifying element elem.
  • Export["file.h5",{expr1,expr2,},{{elem1,elem2,}}] treats each as specifying the corresponding .
  • Export["file.h5",expr,opt1->val1,] exports expr with the specified option elements taken to have the specified values.
  • Export["file.h5",{elem1->expr1,elem2->expr2,},"Rules"] uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the HDF5 format.

ElementsElements

  • General Import elements:
  • "Elements"list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties, and settings
  • Data representation elements:
  • "Data"all datasets imported as a list of arrays
    "Datasets"names of all datasets
  • Import by default uses the element for the HDF5 format.
  • Specifying and selecting datasets:
  • "Datasets",nn^(th) dataset
    "Datasets",datasetnamed dataset
  • Meta-information elements:
  • "Annotations"meta-information for each dataset
    "DataEncoding"specifies how each dataset is compressed
    "DataFormat"type used to represent each dataset
    "Dimensions"data dimensions of each dataset
  • The following values can be given for :
  • "Integer8"8-bit integers
    "Integer16"16-bit integers
    "Integer32"32-bit integers
    "Integer64"64-bit integers (Import only)
    "Integer128"128-bit integers (Import only)
    "UnsignedInteger8"8-bit unsigned integers
    "UnsignedInteger16"16-bit unsigned integers
    "UnsignedInteger32"32-bit unsigned integers
    "UnsignedInteger64"64-bit unsigned integers (Import only)
    "UnsignedInteger128"128-bit unsigned integers (Import only)
    "Real32"IEEE singleprecision numbers
    "Real64"IEEE doubleprecision numbers
    "Real128"IEEE quadprecision numbers (Import only)
    "String"string of ASCII characters (Import only)
  • can take the following values:
  • Noneno data compression is used
    "GZIP"GZIP compression
    "SZIP"SZIP compression (Import only)

OptionsOptions

  • Export option:
  • "Append"Falsewhether to append to an existing file

ExamplesExamplesopen allclose all

Basic Examples  (4)Basic Examples  (4)

Show the datasets stored in a sample file:

In[1]:=
Click for copyable input
Out[1]=

Import 8-bit RGB raster data and render it as an Image object:

In[1]:=
Click for copyable input
Out[1]=

Export a matrix to HDF5:

In[1]:=
Click for copyable input
Out[1]=

Show the datasets contained in this file:

In[2]:=
Click for copyable input
Out[2]=

Import :

In[3]:=
Click for copyable input
Out[3]=

Export a named dataset:

In[1]:=
Click for copyable input
Out[1]=

Export two matrices to HDF5:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
Introduced in 2004
(5.1)
| Updated in 2007
(6.0)