load_array_from_file

load_array_from_file#

ptyrad.load.load_array_from_file(path, key=None, ndims=None, shape=None, offset=None, gap=None)[source]#

Load array from a file. The file type is inferred from the extension. Currently supports .tif, .tiff, .npy, .mat, .h5, .hdf5, and .raw.

Parameters:
  • path (str) – Path to the file.

  • key (str) – Key to specify the dataset (optional).

  • ndims (list) – List of desired dimensions for filtering datasets.

  • shape (tuple) – Shape of the data for .raw files (optional).

  • offset (int) – Offset for .raw files (optional).

  • gap (int) – Gap for .raw files (optional).

Returns:

The loaded array.

Return type:

numpy.ndarray

Raises:

ValueError – If the file type is unsupported or no valid dataset is found.