8000 fftshift incompatible with fft for even n (Trac #1077) · Issue #1675 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

fftshift incompatible with fft for even n (Trac #1077) #1675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
thouis opened this issue Oct 19, 2012 · 4 comments
Closed

fftshift incompatible with fft for even n (Trac #1077) #1675

thouis opened this issue Oct 19, 2012 · 4 comments

Comments

@thouis
Copy link
Contributor
thouis commented Oct 19, 2012

Original ticket http://projects.scipy.org/numpy/ticket/1077 on 2009-04-03 by trac user alk, assigned to unknown.

If n is even (for example n = 8, then fft is described, to return the frequencies at:

[0, 1, 2, 3, 4, -3, -2, -1].

But fftshift(array([0,1,2,3,4,-3,-2,-1]))

returns:
[ 4, -3, -2, -1, 0, 1, 2, 3]

and not:

[-3, -2, -1, 0, 1, 2, 3, 4]

@numpy-gitbot
Copy link

Attachment added by trac user alk on 2009-04-03: helper.py.patch

@numpy-gitbot
Copy link

@pv wrote on 2009-04-03

See comment in #1674

@numpy-gitbot
Copy link

Milestone changed to 1.4.0 by @cournape on 2009-06-01

@numpy-gitbot
Copy link

@rgommers wrote on 2010-07-26

If n is even, there is one more negative than positive value. This is a choice, and consistently done in numpy as far as I'm aware.

In [27]: np.fft.fftshift(np.array([0,1,2,3,-4,-3,-2,-1])) 
Out[27]: array([-4, -3, -2, -1,  0,  1,  2,  3])

From docstring:

    >>> 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.])

certik pushed a commit to certik/numpy that referenced this issue Nov 14, 2012
@mwiebe mwiebe mentioned this issue Dec 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
0