Skip to content

nabu.io.utils

source module nabu.io.utils

Classes

Functions

source get_compacted_dataslices(urls, subsampling=None, begin=0)

Regroup urls to get the data more efficiently. Build a structure mapping files indices to information on how to load the data: {indices_set: data_location} where data_location contains contiguous indices.

Parameters

  • urls : dict Dictionary where the key is an integer and the value is a silx DataUrl.

  • subsampling : int, optional Subsampling factor when reading the frames. If an integer n is provided, then one frame out of n will be read.

Returns

  • merged_urls : dict Dictionary with the same keys as the urls parameter, and where the values are the corresponding silx.io.url.DataUrl with merged data_slice.

source get_first_hdf5_entry(fname)

source hdf5_entry_exists(fname, entry)

source get_h5_value(fname, h5_path, default_ret=None)

source get_h5_str_value(dataset_ptr)

Get a HDF5 field which can be bytes or str (depending on h5py version !).

source create_dict_of_indices(images_stack, images_indices)

From an image stack with the images indices, create a dictionary where each index is the image index, and the value is the corresponding image.

Parameters

  • images_stack : numpy.ndarray A 3D numpy array in the layout (n_images, n_y, n_x)

  • images_indices : array or list of int Array containing the indices of images in the stack

Examples

Given a simple array stack:

images_stack = np.arange(3*4*5).reshape((3,4,5))
images_indices = [2, 7, 1]
create_dict_of_indices(images_stack, images_indices)
# returns {2: array1, 7: array2, 1: array3}

Raises

  • ValueError

source convert_dict_values(dic, val_replacements, bytes_tostring=False)

Modify a dictionary to be able to export it with silx.io.dicttoh5

source class EntryReader(url: DataUrl)

Bases : _BaseReader

Context manager used to read a bliss node

source class DatasetReader(url: DataUrl)

Bases : _BaseReader

Context manager used to read a bliss node

source file_format_is_edf(file_format: str)

source file_format_is_jp2k(file_format: str)

source file_format_is_tiff(file_format: str)

source file_format_is_hdf5(file_format: str)

source get_output_volume(location: str, file_prefix: str | None, file_format: str, multitiff=False)

Raises

  • ValueError