[SciPy-User] Inconsistency using fft.fftfreq with real input FFT

Juan Luis Cano Rodríguez juanlu001@gmail....
Mon Sep 17 12:19:03 CDT 2012

Hi all, I was playing around with FFTs in NumPy and observed what seems to
me an inconsistency with the output of fft.fftfreq. When I transform a
general complex valued function using fft.fft, as it is stated in the
documentation, A[1:n/2] contains the positive-frequency terms, and
A[n/2+1:]contains the negative-frequency terms for even
n. OTOH, for n even fft.fftfreq includes the Nyquist frequency in the
negative ones. This is irrelevant in this case as A[n/2] represents both
positive and negative Nyquist frequency.

Nevertheless, if I transform a real valued signal and use fft.rfft, the
negative frecuencies are not calculated and the output is cropped to n/2 so
its length is n/2+1. But if I choose to crop the output of fft.fftfreq in a
similar way, it appears that all the frecuencies are positive but the last

  >>> fft.fftfreq(10, 0.1)[:10 / 2 + 1]
  array([ 0.,  1.,  2.,  3.,  4., -5.])

This is uncomfortable because if I want to plot the result of fft.rfft vs
fft.fftfreq[:N / 2 + 1] the last frequency is plotted far away on the left,
for example. I wonder what are the reasons not to consider the Nyquist
frequency positive.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120917/51bfa2ff/attachment.html 

More information about the SciPy-User mailing list