nabu.io.writer
source module nabu.io.writer
Classes
-
Writer — Base class for all writers.
-
NXProcessWriter — A class to write Nexus file with a processing result.
-
NXVolVolume — An interface to NXProcessWriter with the same API than tomoscan.esrf.volume.
-
HSTVolWriter — A writer to mimic PyHST2 ".vol" files
-
HSTVolVolume — An interface to HSTVolWriter with the same API than tomoscan.esrf.volume. This is really not ideal, see nabu:#381
Functions
-
get_datetime — Function used by some writers to indicate the current date.
-
export_dict_to_h5 — Wrapper on top of silx.io.dictdump.dicttoh5 replacing None with "None"
-
create_virtual_layout — Create a HDF5 virtual layout.
-
merge_hdf5_files — 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.
Function used by some writers to indicate the current date.
source method Writer.get_filename()
source h5_write_object(h5group, key, value, overwrite=False, default_val=None)
Raises
-
OSError
source class NXProcessWriter(fname, entry=None, filemode='a', overwrite=False)
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"
Methods
-
write — Write the result in the current NXProcess group.
source method NXProcessWriter.write(result, process_name, processing_index=0, config=None, data_name='data', is_frames_stack=True, direct_access=True)
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.
source class NXVolVolume(**kwargs)
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
Methods
source method NXVolVolume.save()
Raises
-
ValueError
source method NXVolVolume.save_metadata()
source method NXVolVolume.browse_data_files()
source export_dict_to_h5(dic, h5file, h5path, overwrite_data=True, mode='a')
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).
source create_virtual_layout(files_or_pattern, h5_path, base_dir=None, axis=0, dtype='f')
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.
Raises
-
ValueError
source 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')
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.
source class HSTVolWriter(fname, append=False, **kwargs)
source method HSTVolWriter.generate_metadata(data, **kwargs)
source staticmethod HSTVolWriter.sanitize_metadata(metadata)
source method HSTVolWriter.write(data, *args, config=None, **kwargs)
source class HSTVolVolume(**kwargs)
Bases : HSTVolWriter
An interface to HSTVolWriter with the same API than tomoscan.esrf.volume. This is really not ideal, see nabu:#381
Methods
source method HSTVolVolume.save()
Raises
-
ValueError
source method HSTVolVolume.save_metadata()
source method HSTVolVolume.browse_data_files()