Ńň
\ĐKc @ sw d Z d d d g Z d d k l Z l Z l Z l Z l Z l Z d d k 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 | i } | d j o t | } n | } x\ | D]T } | i | } | d d } t t | | t | f } t | | | } qE 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 rangeR R R ( t xt axest tmpt ndimt yt kt nt p2t mylist( ( s6 /usr/lib64/python2.6/site-packages/numpy/fft/helper.pyR s ,
!c C sĽ t | } t | i } | d j o t | } n | } x` | D]X } | i | } | | d d } t t | | t | f } t | | | } qE 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 ( ( s6 /usr/lib64/python2.6/site-packages/numpy/fft/helper.pyR E s !
!g đ?c C s¤ t | t i p t | t p t d | | } t | t } | d d d } t d | d t } | | | *t | d d d t } | | | )| | S( s|
Return the Discrete Fourier Transform sample frequencies.
The returned float array contains the frequency bins in
cycles/unit (with zero at the start) given a window length `n` and a
sample spacing `d`::
f = [0, 1, ..., n/2-1, -n/2, ..., -1] / (d*n) if n is even
f = [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (d*n) if n is odd
Parameters
----------
n : int
Window length.
d : scalar
Sample spacing.
Returns
-------
out : ndarray
The array of length `n`, containing the sample frequencies.
Examples
--------
>>> signal = np.array([-2, 8, 6, 4, 1, 0, 3, 5], dtype=float)
>>> fourier = np.fft.fft(signal)
>>> n = signal.size
>>> timestep = 0.1
>>> freq = np.fft.fftfreq(n, d=timestep)
>>> freq
array([ 0. , 1.25, 2.5 , 3.75, -5. , -3.75, -2.5 , -1.25])
g đ?i i i t dtype( t
isinstancet typest IntTypeR t AssertionErrorR t intR ( R t dt valt resultst Nt p1R ( ( s6 /usr/lib64/python2.6/site-packages/numpy/fft/helper.pyR r s "*
( t __doc__t __all__t
numpy.coreR R R R R R R R R R R ( ( ( s6 /usr/lib64/python2.6/site-packages/numpy/fft/helper.pyt