octaveh5: Octave HDF5 compatibility

Python h5 module and octave h5 module have different ways to deal with h5 files. This module is used to make the link between octave and python using such files. (python is using a dictionary and octave a struct )

This module provides tool to set HDF5 file for fasttomo input.

Here is an example of a simple read and write :

# writing a structure
myStruct = {'MKEEP_MASK': 0.0, 'UNSHARP_SIGMA': 0.80000000000000004 }
writer = Octaveh5().open("my_h5file", 'a')
writer.write('mt_struct_name', myStruct)

# reading a h5 file
reader = Octaveh5().open("my_h5file")
strucDict = reader.get('mt_struct_name')

Note

These functions depend on the h5py library, which is a mandatory dependency for silx.

class Octaveh5(octave_targetted_version=3.8)[source]

Bases: object

This class allows communication between octave and python using hdf5 format.

open(h5file, mode='r')[source]

Open the h5 file which has been write by octave

Parameters
  • h5file – The path of the file to read

  • mode – the opening mode of the file :’r’, ‘w’…

get(struct_name)[source]

Read octave equivalent structures in hdf5 file

Parameters

struct_name – the identification of the top level identity we want to get from an hdf5 structure

Returns

the dictionnary of the requested struct. None if can t find it

write(struct_name, data_dict)[source]

write data_dict under the group struct_name in the open hdf5 file

Parameters
  • struct_name – the identificatioon of the structure to write in the hdf5

  • data_dict – The python dictionnary containing the informations to write

close()[source]

Close the file after calling read function