Skip to content

Instantly share code, notes, and snippets.

@jaidevd
Created August 16, 2012 17:08
Show Gist options
  • Save jaidevd/3371737 to your computer and use it in GitHub Desktop.
Save jaidevd/3371737 to your computer and use it in GitHub Desktop.
Harshad's problem
# You need to have matplotlib installed to be able to plot anything in Python.
# Suppose your data is a variable 'data'
from matplotlib.pyplot import plot, show
try:
from numpy.fft import fft
except:
from numpy import fft
x = data[:,1] # 2nd column
y = data[:,4] # 5th column
plot(x,y)
show()
# you should be able to see the plot now in a popped up window.
F1 = fft(*) # whatever you want to take an fft of, goes in the place of the *
figure()
plot(abs(F))
show()
# another popped up window showing the FFT amplitude spectrum
# Do the same with the other text file and call the other FFT F2
F_div = abs(F1)/abs(F2)
# the division of the two FFTs.
@harshadsurdi
Copy link

in the program why have you done the "try: ........ except:......" thing?

@jaidevd
Copy link
Author

jaidevd commented Aug 19, 2012

I'm not sure if the fft function is available directly in numpy or if it is a part of another module 'fft' within numpy. If it is the latter case, the try loop will be run.

@jaidevd
Copy link
Author

jaidevd commented Aug 19, 2012

It's possible that there is a module called numpy.fft which has all Fourier related methods, and the fast Fourier transform is one of them, in which case the function in numpy.fft.fft
Else it could just be numpy.fft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment