larray.Session.to_hdf

Session.to_hdf(fname, names=None, overwrite=True, display=False, **kwargs) None[source]

Dump objects from the current session to an HDF file.

Parameters
fnamestr

Path of the file for the dump.

nameslist of str or None, optional

Names of objects to dump. Defaults to all objects present in the Session.

overwrite: bool, optional

Whether to overwrite an existing file, if any. If False, file is updated. Defaults to True.

displaybool, optional

Whether to display which file is being worked on. Defaults to False.

Examples

>>> # scalars
>>> i, s = 5, 'string'                                                      
>>> # axes
>>> a, b = Axis("a=a0..a2"), Axis("b=b0..b2")                               
>>> # groups
>>> a01 = a['a0,a1'] >> 'a01'                                               
>>> # arrays
>>> arr1, arr2 = ndtest((a, b)), ndtest(a)                                  
>>> ses = Session({'i': i, 's': s, 'a': a, 'b': b, 'a01': a01,
...                'arr1': arr1, 'arr2': arr2})                             
>>> # metadata
>>> ses.meta.title = 'my title'                                             
>>> ses.meta.author = 'John Smith'                                          

Save all objects

>>> ses.to_hdf('output.h5', display=True)                                   
dumping i ... done
dumping s ... done
dumping a ... done
dumping b ... done
dumping a01 ... done
dumping arr1 ... done
dumping arr2 ... done

Save only some objects

>>> ses.to_hdf('output.h5', names=['s', 'a', 'b', 'arr1', 'arr2'], display=True)    
dumping s ... done
dumping a ... done
dumping b ... done
dumping arr1 ... done
dumping arr2 ... done