nabu.io.writer module¶
- class nabu.io.writer.NXProcessWriter(fname, entry=None, filemode='a', overwrite=False)[source]¶
Bases:
Writer
A class to write Nexus file with a processing result.
Initialize a NXProcessWriter.
- Parameters:
fname (str) – Path to the HDF5 file.
entry (str, optional) – Entry in the HDF5 file. Default is “entry”
- write(result, process_name, processing_index=0, config=None, data_name='data', is_frames_stack=True, direct_access=True)[source]¶
Write the result in the current NXProcess group.
- Parameters:
result (numpy.ndarray) – Array containing the processing result
process_name (str) – Name of the processing
processing_index (int) – Index of the processing (in a pipeline)
config (dict, optional) – Dictionary containing the configuration.
- class nabu.io.writer.NXVolVolume(**kwargs)[source]¶
Bases:
NXProcessWriter
An interface to NXProcessWriter with the same API than tomoscan.esrf.volume.
NX files are written in two ways:
Partial files containing sub-volumes
Final volume: master file with virtual dataset pointing to partial files
This class handles the first one, therefore expects the “start_index” parameter. In the case of HDF5, a sub-directory is creating to contain the partial files. In other words, if file_prefix=”recons” and output_dir=”/path/to/out”:
/path/to/out/recons.h5 # final master file /path/to/out/recons/
/path/to/out/recons/recons_00000.h5 /path/to/out/recons/recons_00100.h5 …
Initialize a NXProcessWriter.
- Parameters:
fname (str) – Path to the HDF5 file.
entry (str, optional) – Entry in the HDF5 file. Default is “entry”
- nabu.io.writer.LegacyNXProcessWriter¶
alias of
NXProcessWriter
- nabu.io.writer.export_dict_to_h5(dic, h5file, h5path, overwrite_data=True, mode='a')[source]¶
Wrapper on top of silx.io.dictdump.dicttoh5 replacing None with “None”
- Parameters:
dic (dict) – Dictionary containing the options
h5file (str) – File name
h5path (str) – Path in the HDF5 file
overwrite_data (bool, optional) – Whether to overwrite data when writing HDF5. Default is True
mode (str, optional) – File mode. Default is “a” (append).
- nabu.io.writer.create_virtual_layout(files_or_pattern, h5_path, base_dir=None, axis=0, dtype='f')[source]¶
Create a HDF5 virtual layout.
- Parameters:
files_or_pattern (str or list) – A list of file names, or a wildcard pattern. If a list is provided, it will not be sorted! This will have to be done before calling this function.
h5_path (str) – Path inside the HDF5 input file(s)
base_dir (str, optional) – Base directory when using relative file names.
axis (int, optional) – Data axis to merge. Default is 0.
- nabu.io.writer.merge_hdf5_files(files_or_pattern, h5_path, output_file, process_name, output_entry=None, output_filemode='a', data_name='data', processing_index=0, config=None, base_dir=None, axis=0, overwrite=False, dtype='f')[source]¶
- Parameters:
files_or_pattern (str or list) – A list of file names, or a wildcard pattern. If a list is provided, it will not be sorted! This will have to be done before calling this function.
h5_path (str) – Path inside the HDF5 input file(s)
output_file (str) – Path of the output file
process_name (str) – Name of the process
output_entry (str, optional) – Output HDF5 root entry (default is “/entry”)
output_filemode (str, optional) – File mode for output file. Default is “a” (append)
processing_index (int, optional) – Processing index for the output file. Default is 0.
config (dict, optional) – Dictionary describing the configuration needed to get the results.
base_dir (str, optional) – Base directory when using relative file names.
axis (int, optional) – Data axis to merge. Default is 0.
overwrite (bool, optional) – Whether to overwrite already existing data in the final file. Default is False.