xrscipy.fft.irfftn

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

Computes the inverse of rfftn

This function computes the inverse of the N-D discrete Fourier Transform for real input over any number of axes in an M-D array by means of the Fast Fourier Transform (FFT). In other words, irfftn(rfftn(x), x.shape) == x to within numerical accuracy. (The a.shape is necessary like len(a) is for irfft, and for the same reason.)

The input should be ordered in the same way as is returned by rfftn, i.e., as for irfft for the final transformation axis, and as for ifftn along all the other axes.

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 inverse 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 or x, as explained in the parameters section above. The length of each transformed axis is as given by the corresponding element of s, or the length of the input in every axis except for the last one if s is not given. In the final transformed axis the length of the output when s is not given is 2*(m-1), where m is the length of the final transformed axis of the input. To get an odd number of output points in the final axis, s must be specified.

Return type:

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

rfftn

The forward N-D FFT of real input, of which ifftn is the inverse.

fft

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

irfft

The inverse of the 1-D FFT of real input.

irfft2

The inverse of the 2-D FFT of real input.

scipy.fft.irfftn

scipy.fft.irfftn : Original scipy implementation

Notes

See fft for definitions and conventions used.

See rfft for definitions and conventions used for real input.

The default value of s assumes an even output length in the final transformation axis. When performing the final complex to real transformation, the Hermitian symmetry requires that the last imaginary component along that axis must be 0 and so it is ignored. To avoid losing information, the correct length of the real input must be given.

Examples

>>> import scipy.fft
>>> import numpy as np
>>> x = np.zeros((3, 2, 2))
>>> x[0, 0, 0] = 3 * 2 * 2
>>> scipy.fft.irfftn(x)
array([[[1.,  1.],
        [1.,  1.]],
       [[1.,  1.],
        [1.,  1.]],
       [[1.,  1.],
        [1.,  1.]]])