larray.LGroup.to_hdf

LGroup.to_hdf(filepath, key=None, axis_key=None) None

Write group to a HDF file.

A HDF file can contain multiple groups. The ‘key’ parameter is a unique identifier for the group. The ‘axis_key’ parameter is the unique identifier for the associated axis. The associated axis will be saved if not already present in the HDF file.

Parameters
filepathstr

Path where the hdf file has to be written.

keystr or Group, optional

Key (path) of the group within the HDF file (see Notes below). If None, the name of the group is used. Defaults to None.

axis_keystr, optional

Key (path) of the associated axis in the HDF file (see Notes below). If None, the name of the axis associated with the group is used. Defaults to None.

Notes

Objects stored in a HDF file can be grouped together in HDF groups. If an object ‘my_obj’ is stored in a HDF group ‘my_group’, the key associated with this object is then ‘my_group/my_obj’. Be aware that a HDF group can have subgroups.

Examples

>>> from larray import Axis
>>> a = Axis("a=a0..a2")
>>> a.to_hdf('test.h5')                     
>>> a01 = a['a0,a1'] >> 'a01'

Save group

>>> # by default, the key is the name of the group
>>> # and axis_key the name of the associated axis
>>> a01.to_hdf('test.h5')                   

Save group with a specific key

>>> a01.to_hdf('test.h5', 'a_01')           

Save group in a specific HDF group

>>> a.to_hdf('test.h5', 'groups/a01')       

The associated axis is saved with the group if not already present in the HDF file

>>> b = Axis("b=b0..b2")
>>> b01 = b['b0,b1'] >> 'b01'
>>> # save both the group 'b01' and the associated axis 'b'
>>> b01.to_hdf('test.h5')