Utility Functions#

The sarcomp.utils module provides useful utility functions.

Functions#

Below is the list of functions provided by the sarcomp.utils module.

sarcomp.utils.cvt_bytes(data: ndarray, imag: ndarray = None, out: ndarray = None, dtype: str | dtype = 'float32', center: bool = False) Array#

Convert a uint8 array to the specified floating-point or complex dtype, with optional support for providing an output array.

Parameters:
  • data (np.ndarray) – The real part of the input data array in uint8 format.

  • imag (np.ndarray, optional) – The imaginary part of the input data array (for split-complex input). Defaults to None.

  • out (np.ndarray, optional) – An optional output array where the results will be stored.

  • dtype (Union[str, np.dtype], optional) – The target data type for the conversion. Default is “float32”.

  • center (bool, optional) – If True, center the uint8 data by subtracting 127.5 after converting to float.

Returns:

A new Array instance containing the converted data.

Return type:

Array

Raises:

ValueError – If data or imag is not uint8, or out does not match the target dtype and shape.