nabu.io.utils module¶
- nabu.io.utils.get_compacted_dataslices(urls, subsampling=None)[source]¶
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 – Dictionary with the same keys as the urls parameter, and where the values are the corresponding silx.io.url.DataUrl with merged data_slice.
- Return type:
dict
- nabu.io.utils.get_h5_str_value(dataset_ptr)[source]¶
Get a HDF5 field which can be bytes or str (depending on h5py version !).
- nabu.io.utils.create_dict_of_indices(images_stack, images_indices)[source]¶
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}
- nabu.io.utils.convert_dict_values(dic, val_replacements, bytes_tostring=False)[source]¶
Modify a dictionary to be able to export it with silx.io.dicttoh5
- class nabu.io.utils.EntryReader(url: DataUrl)[source]¶
Bases:
_BaseReader
Context manager used to read a bliss node