nabu.io
Classes
-
NPReader — Reader for NPY/NPZ files. Mostly used for internal development. Please refer to the documentation of nabu.io.reader.Reader
-
EDFReader — A class for reading series of EDF Files. Multi-frames EDF are not supported.
-
HDF5Loader — An alternative class to HDF5Reader where information is first passed at class instantiation
-
ChunkReader — A reader of chunk of images.
-
NXProcessWriter — A class to write Nexus file with a processing result.
source class NPReader(sub_region=None, mmap=True)
Bases : Reader
Reader for NPY/NPZ files. Mostly used for internal development. Please refer to the documentation of nabu.io.reader.Reader
Methods
source method NPReader.get_data(data_url)
source method NPReader.release()
source class EDFReader(sub_region=None)
source method EDFReader.read(fname)
source method EDFReader.get_data(data_url)
source class HDF5Loader(fname, data_path, sub_region=None, data_buffer=None, pre_allocate=True, dtype='f')
An alternative class to HDF5Reader where information is first passed at class instantiation
Methods
source method HDF5Loader.load_data(force_load=False, output=None)
source class ChunkReader(files, sub_region=None, detector_corrector=None, pre_allocate=True, data_buffer=None, convert_float=False, shape=None, dtype=None, binning=None, dataset_subsampling=None, num_threads=None)
A reader of chunk of images.
Initialize a "ChunkReader". A chunk is a stack of images.
Parameters
-
files : dict — Dictionary where the key is the file/data index, and the value is a silx.io.url.DataUrl pointing to the data. The dict must contain only the files which shall be used ! Note: the shape and data type is infered from the first data file.
-
sub_region : tuple, optional — If provided, this must be a tuple in the form (start_x, end_x, start_y, end_y). Each image will be cropped to this region. This is used to specify a chunk of files. Each of the parameters can be None, in this case the default start and end are taken in each dimension.
-
pre_allocate : bool — Whether to pre-allocate data before reading.
-
data_buffer : array-like, optional — If
pre_allocate
is set to False, this parameter has to be provided. It is an array-like object which will hold the data. -
convert_float : bool — Whether to convert data to float32, regardless of the input data type.
-
shape : tuple, optional — Shape of each image. If not provided, it is inferred from the first image in the collection.
-
dtype :
numpy.<span class="mkapi-tooltip" title="numpy._core.dtype">dtype</span>
, optional — Data type of each image. If not provided, it is inferred from the first image in the collection. -
binning : int or tuple of int, optional — Whether to bin the data. If multi-dimensional binning is done, the parameter must be in the form (binning_x, binning_y). Each image will be binned by these factors.
-
dataset_subsampling : int or tuple, optional — Subsampling factor when reading the images. If an integer
n
is provided, then one image out ofn
will be read. If a tuple of integers (step, begin) is given, the data is read as data[begin::step] -
num_threads : int, optional — Number of threads to use for binning the data. Default is to use all available threads. This parameter has no effect when binning is disabled.
Notes
The files are provided as a collection of silx.io.DataURL
. The file type
is inferred from the extension.
Binning is different from subsampling. Using binning will not speed up the data retrieval (quite the opposite), since the whole (subregion of) data is read and then binning is performed.
Methods
-
get_data — Get the data associated to a file url.
-
load_files — Load the files whose links was provided at class instantiation.
source method ChunkReader.get_data(file_url)
Get the data associated to a file url.
source method ChunkReader.load_files(overwrite: bool = False)
Load the files whose links was provided at class instantiation.
Parameters
-
overwrite : bool, optional — Whether to force reloading the files if already loaded.
Raises
-
ValueError
source property ChunkReader.data
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.