sidpy.hdf.dtype_utils.flatten_complex_to_real

sidpy.hdf.dtype_utils.flatten_complex_to_real(dataset, lazy=False)[source]

Stacks the real values followed by the imaginary values in the last dimension of the given N dimensional matrix. Thus a complex matrix of shape (2, 3, 5) will turn into a matrix of shape (2, 3, 10)

Parameters:
Returns:

retval – real valued dataset

Return type:

numpy.ndarray, or dask.array.core.Array

Examples

>>> import numpy as np
>>> import sidpy
>>> length = 3
>>> complex_array = np.random.randint(-5, high=5, size=length) + 1j * np.random.randint(-5, high=5, size=length)
>>> print('Complex value: {} has shape: {}'.format(complex_array, complex_array.shape))
Complex value: [2.-2.j 0.-3.j 0.-4.j] has shape: (3,)
>>> stacked_real_array = sidpy.dtype_utils.flatten_complex_to_real(complex_array)
>>> print('Stacked real value: {} has shape: '
>>>       '{}'.format(stacked_real_array, stacked_real_array.shape))
Stacked real value: [ 2.  0.  0. -2. -3. -4.] has shape: (6,)