This module provides functions to convert a SpecFile into a HDF5 file.
Note
These functions depend on the h5py
library, which is not a mandatory dependency for silx.
-
silx.io.spectoh5.write_spec_to_h5(specfile, h5file, h5path='/', mode='a', overwrite_data=False, link_type='hard', create_dataset_args=None)[source]
Write content of a SpecFile in a HDF5 file.
Parameters: |
- specfile – Path of input SpecFile or SpecH5 instance
- h5file – Path of output HDF5 file or HDF5 file handle
- h5path – Target path in HDF5 file in which scan groups are created.
Default is root ("/")
- mode – Can be "r+" (read/write, file must exist),
"w" (write, existing file is lost), "w-" (write, fail
if exists) or "a" (read/write if exists, create otherwise).
This parameter is ignored if h5file is a file handle.
- overwrite_data – If True, existing groups and datasets can be
overwritten, if False they are skipped. This parameter is only
relevant if file_mode is "r+" or "a".
- link_type – "hard" (default) or "soft"
- create_dataset_args – Dictionary of args you want to pass to
h5f.create_dataset. This allows you to specify filters and
compression parameters. Don’t specify name and data.
These arguments don’t apply to scalar datasets.
|
The structure of the spec data in an HDF5 file is described in the
documentation of silx.io.spech5.
-
silx.io.spectoh5.convert(specfile, h5file, mode='w-', create_dataset_args=None)[source]
Convert a SpecFile into an HDF5 file, write scans into the root (/)
group.
Parameters: |
- specfile – Path of input SpecFile or SpecH5 instance
- h5file – Path of output HDF5 file or HDF5 file handle
- mode – Can be "w" (write, existing file is
lost), "w-" (write, fail if exists). This is ignored
if h5file is a file handle.
- create_dataset_args – Dictionary of args you want to pass to
h5f.create_dataset. This allows you to specify filters and
compression parameters. Don’t specify name and data.
|
This is a convenience shortcut to call:
write_spec_to_h5(specfile, h5file, h5path='/',
mode="w-", link_type="hard")