简体   繁体   中英

Where in Python can I find real_fft() these days? It's not in numpy.fft

I have some ancient code (5 years old) and how I used to access real_fft() method was this:

from FFT import *
real_fft(data, fft_length)

I guess the FFT module came with NumPy. Now, years later I installed the NumPy 1.6.1 with

pip install numpy

And all I see in the docs http://www.scipy.org/Numpy_Functions_by_Category , are these functions:

fft()

fftfreq()

fftshift()

ifft()

It is strange, because in this numpy docs, real_fft() is there:

http://numpy.sourceforge.net/numdoc/HTML/numdoc.htm#pgfId-304711

It looks like NumPy underwent some reorganisation in recent years.

http://www.scipy.org/Numpy_Example_List_With_Doc#fft

FFT is now numpy.fft, and real_fft() seems to be renamed into rfft()

>>> from numpy import *
>>> 
>>> signal = array([-2.,  8., -6.,  4.,  1., 0.,  3.,  5.]) 
>
>>> from numpy.fft import *
>>> 
>>> 
>>> f = fft(signal)
>>> 
>>> 
>>> print f
[ 13.00000000 +0.j           3.36396103 +4.05025253j   2.00000000 +1.j
  -9.36396103-13.94974747j -21.00000000 +0.j          -9.36396103+13.94974747j
   2.00000000 -1.j           3.36396103 -4.05025253j]
>>> 
>>> 
>>> 
>>> 
>>> f = rfft(signal)
>>> 
>>> print f
[ 13.00000000 +0.j           3.36396103 +4.05025253j   2.00000000 +1.j
  -9.36396103-13.94974747j -21.00000000 +0.j        ]
>>> 
>>> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM