spacepy.datamodel.toHDF5

spacepy.datamodel.toHDF5(fname, SDobject, **kwargs)[source]

Create an HDF5 file from a SpacePy datamodel representation

Parameters
fnamestr

Filename to write to

SDobjectspacepy.datamodel.SpaceData

SpaceData with associated attributes and variables in dmarrays

Returns
None
Other Parameters
overwritebool (optional)

allow overwrite of an existing target file (default True)

modestr (optional)

HDF5 file open mode (a, w, r) (default ‘a’)

compressionstr (optional)

compress all the variables using this method (default None) (gzip, shuffle, fletcher32, szip, lzf)

compression_optsstr (optional)

options to the compression, see h5py documentation for more details

Examples

>>> import spacepy.datamodel as dm
>>> a = dm.SpaceData()
>>> a['data'] = dm.dmarray(range(100000), dtype=float)
>>> dm.toHDF5('test_gzip.h5', a, overwrite=True, compression='gzip')
>>> dm.toHDF5('test.h5', a, overwrite=True)
>>> # test_gzip.h5 was 118k, test.h5 was 785k