xdas.fft.rfft#
- xdas.fft.rfft(da, n=None, dim={'last': 'spectrum'}, norm=None, parallel=None)[source]#
Compute the discrete Fourier Transform for real inputs along a given dimension.
This function computes the one-dimensional n-point discrete Fourier Transform (DFT) or real-valued inputs with the efficient Fast Fourier Transform (FFT) algorithm.
- Parameters:
da (DataArray) – The data array to process, can be complex.
n (int, optional) – Length of transformed dimension of the output. If n is smaller than the length of the input, the input is cropped. If it is larger, the input is padded with zeros. If n is not given, the length of the input along the dimension specified by dim is used.
dim ({str: str}, optional) – A mapping indicating as a key the dimension along which to compute the FFT, and as value the new name of the dimension. Default to {“last”: “spectrum”}.
norm ({“backward”, “ortho”, “forward”}, optional) – Normalization mode (see numpy.fft). Default is “backward”. Indicates which direction of the forward/backward pair of transforms is scaled and with what normalization factor.
- Returns:
The transformed input with an updated dimension name and values. The length of the transformed dimension is (n/2)+1 if n is even or (n+1)/2 if n is odd.
- Return type:
Notes
To perform a multidimensional Fourier operations, repeat this function on the desired dimensions.
Examples
>>> import xdas as xd >>> import xdas.fft as xfft >>> signal = xd.DataArray([0., 1., 0., -1.], coords={"time": [0, 1, 2, 3]}) >>> xfft.rfft(signal, dim={"time": "frequency"}) <xdas.DataArray (frequency: 3)> [0.+0.j 0.-2.j 0.+0.j] Coordinates: * frequency (frequency): [0. ... 0.5]