This module provides functions to convert a SpecFile into a HDF5 file.
Read the documentation of silx.io.spech5 for information on the structure of the output HDF5 files.
Strings are written to the HDF5 datasets as fixed-length ASCII (NumPy S type). This is done in order to produce files that have maximum compatibility with other HDF5 libraries, as recommended in the h5py documentation.
If you read the files back with h5py in Python 3, you will recover strings as bytes, which you should decode to transform them into python strings:
>>> import h5py
>>> f = h5py.File("myfile.h5")
>>> f["/1.1/instrument/specfile/scan_header"][0]
b'#S 94 ascan del -0.5 0.5 20 1'
>>> f["/1.1/instrument/specfile/scan_header"][0].decode()
'#S 94 ascan del -0.5 0.5 20 1'
Arrays of strings, such as file and scan headers, are stored as fixed-length strings. The length of all strings in an array is equal to the length of the longest string. Shorter strings are right-padded with blank spaces.
Note
This module has a dependency on the h5py library, which is not a mandatory dependency for silx. You might need to install it if you don’t already have it.
Write content of a SpecFile in a HDF5 file.
Parameters: |
|
---|
The structure of the spec data in an HDF5 file is described in the documentation of silx.io.spech5.
Convert a SpecFile into an HDF5 file, write scans into the root (/) group.
Parameters: |
|
---|
This is a convenience shortcut to call:
write_spec_to_h5(specfile, h5file, h5path='/',
mode="w-", link_type="hard")