{ } Raw JSON

bundles / scipy latest / scipy / fft / _helper / fftshift

function

scipy.fft._helper:fftshift

source: /scipy/fft/_helper.py :262

Signature

def   fftshift ( x axes = None )

Summary

Shift the zero-frequency component to the center of the spectrum.

Extended Summary

This function swaps half-spaces for all axes listed (defaults to all). Note that y[0] is the Nyquist component only if len(x) is even.

Parameters

x : array_like

Input array.

axes : int or shape tuple, optional

Axes over which to shift. Default is None, which shifts all axes.

Returns

y : ndarray

The shifted array.

Notes

Array API Standard Support

fftshift has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.

====================  ====================  ====================
Library               CPU                   GPU
====================  ====================  ====================
NumPy                 ✅                     n/a                 
CuPy                  n/a                   ✅                   
PyTorch               ✅                     ✅                   
JAX                   ✅                     ✅                   
Dask                  ✅                     n/a                 
====================  ====================  ====================

See dev-arrayapi for more information.

Examples

import numpy as np
freqs = np.fft.fftfreq(10, 0.1)
freqs
np.fft.fftshift(freqs)
Shift the zero-frequency component only along the second axis:
freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3)
freqs
np.fft.fftshift(freqs, axes=(1,))

See also

ifftshift

The inverse of fftshift.

Aliases

  • scipy.fft.fftshift