xrscipy.fft.rfftn

xrscipy.fft.rfftn(x, coord, n=None, norm=None)

Compute the N-D discrete Fourier Transform for real input.

This function computes the N-D discrete Fourier Transform over any number of axes in an M-D real array by means of the Fast Fourier Transform (FFT). By default, all axes are transformed, with the real transform performed over the last axis, while the remaining transforms are complex.

Parameters:
  • x (xarray object) – The data to transform.

  • s (mapping from coords to size, optional) – the shape of the result.

  • axes (sequence of ints, optional) – Axes over which to compute the FFT. If not given, the last len(s) axes are used, or all axes if s is also not specified.

  • norm ({"backward", "ortho", "forward"}, optional) – Normalization mode (see fft). Default is “backward”.

Returns:

out – The truncated or zero-padded input, transformed along the axes indicated by axes, or by a combination of s and x, as explained in the parameters section above. The length of the last axis transformed will be s[-1]//2+1, while the remaining transformed axes will have lengths according to s, or unchanged from the input.

Return type:

complex ndarray

Raises:
  • ValueError – If s and axes have different length.

  • IndexError – If an element of axes is larger than the number of axes of x.

See also

irfftn

The inverse of rfftn, i.e., the inverse of the N-D FFT of real input.

fft

The 1-D FFT, with definitions and conventions used.

rfft

The 1-D FFT of real input.

fftn

The N-D FFT.

rfft2

The 2-D FFT of real input.

scipy.fft.rfftn

scipy.fft.rfftn : Original scipy implementation

Notes

The transform for real input is performed over the last transformation axis, as by rfft, then the transform over the remaining axes is performed as by fftn. The order of the output is as for rfft for the final transformation axis, and as for fftn for the remaining transformation axes.

See fft for details, definitions and conventions used.

Examples

>>> import scipy.fft
>>> import numpy as np
>>> x = np.ones((2, 2, 2))
>>> scipy.fft.rfftn(x)
array([[[8.+0.j,  0.+0.j], # may vary
        [0.+0.j,  0.+0.j]],
       [[0.+0.j,  0.+0.j],
        [0.+0.j,  0.+0.j]]])

Examples

>>> scipy.fft.rfftn(x, axes=(2, 0))
array([[[4.+0.j,  0.+0.j], # may vary
        [4.+0.j,  0.+0.j]],
       [[0.+0.j,  0.+0.j],
        [0.+0.j,  0.+0.j]]])