how to check .h5 attributs

h5dump example.h5
HDF5 "example.h5" {
GROUP "/" {
   DATASET "dset" {
      DATATYPE  H5T_STD_I32LE
      DATASPACE  SIMPLE { ( 6, 15 ) / ( 6, 15 ) }
      DATA {
      (0,0): 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
      (1,0): 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
      (2,0): 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
      (3,0): 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
      (4,0): 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
      (5,0): 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90
      }
   }
}
}
ref
http://www2.epcc.ed.ac.uk/~amrey/ARCHER_Data_Management/
http://matlab.izmiran.ru/help/techdoc/matlab_prog/ch_imp41.html
https://cran.r-project.org/web/packages/h5/h5.pdf
--------------------------------------------------------------------------------------

fileinfo = hdf5info('example.h5');

hdf5info returns a structure that contains various information about the HDF5 file, including the name of the file and the version of the HDF5 library that MATLAB is using:

  • fileinfo = 
              Filename: 'example.h5'
            LibVersion: '1.4.2'
                Offset: 0
              FileSize: 8172
        GroupHierarchy: [1x1 struct]
    
  • toplevel = fileinfo.GroupHierarchy
    
    toplevel = 
    
          Filename: 'C:\matlab\toolbox\matlab\demos\example.h5'
              Name: '/'
            Groups: [1x2 struct]
          Datasets: []
         Datatypes: []
             Links: []
        Attributes: [1x2 struct]
    

The following figure illustrates the organization of the root group.

  • data = hdf5read('example.h5','/g2/dset2.1');
    

The return value contains the values in the data set, in this case a 1-by-10 vector of single-precision values:

  • data =
    
      Columns 1 through 8 
    
        1.0000    1.1000    1.2000    1.3000    1.4000    1.5000    1.6000    1.7000
    
      Columns 9 through 10 
    
        1.8000    1.9000

-=======================================================================

  • h5ls --full -r data.h5
    /                        Group
    /data                    Group
    /data/data               Dataset {11, 612}
    /data_descr              Group
    /data_descr/names        Dataset {11}
    /data_descr/ordering     Dataset {1}
    
  • $ h5dump -d /data/data data.h5
    HDF5 "data.h5" {
    DATASET "/data/data" {
       DATATYPE  H5T_IEEE_F64LE
       DATASPACE  SIMPLE { ( 11, 612 ) / ( 11, 612 ) }
       DATA {
       (0,0): -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1,
       (0,18): -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1,
       (0,36): -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1,
       (0,55): -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
       (0,74): 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1,
       (0,92): 1, 1, 1, -1, -1, 1, 1, -1, 2, 2, -2, 2, -2, -2, -2, 2, 2, -2, -2,
       (0,111): -2, -2, -2, 2, 2, 2, 2, -2, -2, 2, -2, -2, -2, -2, -2, -2, 2, -2,
    ...
    

Access in Matlab

info=hdf5info('data.h5');

x=hdf5read('data.h5','/data/data')

ans =

  Columns 1 through 7

   -1.0000    0.2107    0.0044    0.0013    0.0001    0.0000    0.0000
   -1.0000    0.2152    0.0042    0.0014    0.0002    0.0000    0.0000
    1.0000    0.1972    0.0023    0.0015    0.0000    0.0000   -0.0000
...

Access in python

h5py will come to your aid:

$ python
>>> import h5py
>>> f = h5py.File('data.h5','r')
>>> f.values()
[<HDF5 group "/data" (1 members)>, <HDF5 group "/data_descr" (2 members)>]
>>> f["/data/data"]
<HDF5 dataset "data": shape (11, 612), type "<f8">
>>> f["/data/data"][:,:]
array([[ -1.00000000e+00,  -1.00000000e+00,   1.00000000e+00, ...,
          3.00000000e+00,  -3.00000000e+00,   3.00000000e+00],
       [  2.10663000e-01,   2.15192000e-01,   1.97153000e-01, ...,
          3.15029000e-01,   2.96945000e-01,   4.08534000e-01],
       [  4.43414000e-03,   4.18483000e-03,   2.30872000e-03, ...,
          3.37745000e-02,   5.68704000e-02,   6.02136000e-02],
       ...,
       [  2.23000000e+00,   2.20000000e+00,   2.35000000e+00, ...,
          9.40000000e-01,   6.00000000e-01,   1.00000000e+00],
       [  1.27000000e+00,   1.28000000e+00,   1.28000000e+00, ...,
          1.24000000e+00,   1.31000000e+00,   1.30000000e+00],
       [  1.28000000e+00,   1.28000000e+00,   1.28000000e+00, ...,
          1.33000000e+00,   1.33000000e+00,   1.32000000e+00]])
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s