Current File : //proc/self/root/proc/self/root/lib64/python2.7/site-packages/numpy/fft/helper.pyc |
�
E�`Qc @ s� d Z d d d g Z d d l m Z m Z m Z m Z m Z m Z d d l j
j Z d d l
Z
d d � Z d d � Z d d
� Z d S( s)
Discrete Fourier Transforms - helper.py
t fftshiftt ifftshiftt fftfreqi����( t asarrayt concatenatet aranget taket integert emptyNc C s� t | � } t | j � } | d k r6 t | � } n$ t | t t j f � rZ | f } n | } x\ | D]T } | j | } | d d } t t
| | � t
| � f � } t | | | � } qg W| S( ss
Shift the zero-frequency component to the center of the spectrum.
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.
See Also
--------
ifftshift : The inverse of `fftshift`.
Examples
--------
>>> freqs = np.fft.fftfreq(10, 0.1)
>>> freqs
array([ 0., 1., 2., 3., 4., -5., -4., -3., -2., -1.])
>>> np.fft.fftshift(freqs)
array([-5., -4., -3., -2., -1., 0., 1., 2., 3., 4.])
Shift the zero-frequency component only along the second axis:
>>> freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3)
>>> freqs
array([[ 0., 1., 2.],
[ 3., 4., -4.],
[-3., -2., -1.]])
>>> np.fft.fftshift(freqs, axes=(1,))
array([[ 2., 0., 1.],
[-4., 3., 4.],
[-1., -3., -2.]])
i i N( R t lent shapet Nonet ranget
isinstancet intt ntR R R R ( t xt axest tmpt ndimt yt kt nt p2t mylist( ( s6 /usr/lib64/python2.7/site-packages/numpy/fft/helper.pyR
s ,
!c C s� t | � } t | j � } | d k r6 t | � } n$ t | t t j f � rZ | f } n | } x` | D]X } | j | } | | d d } t t
| | � t
| � f � } t | | | � } qg W| S( s�
The inverse of fftshift.
Parameters
----------
x : array_like
Input array.
axes : int or shape tuple, optional
Axes over which to calculate. Defaults to None, which shifts all axes.
Returns
-------
y : ndarray
The shifted array.
See Also
--------
fftshift : Shift zero-frequency component to the center of the spectrum.
Examples
--------
>>> freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3)
>>> freqs
array([[ 0., 1., 2.],
[ 3., 4., -4.],
[-3., -2., -1.]])
>>> np.fft.ifftshift(np.fft.fftshift(freqs))
array([[ 0., 1., 2.],
[ 3., 4., -4.],
[-3., -2., -1.]])
i i N( R R R
R R R
R R R R R R ( R R R R R R R R R ( ( s6 /usr/lib64/python2.7/site-packages/numpy/fft/helper.pyR H s !
!g �?c C s� t | t j � s'