I have time associated data that I would like to perform a Fourier transform on. Data is located at http://pastebin.com/2i0UGJW9. The problem is that the data is not uniformly spaced. To solve this, I attempted to interpolate the data and then perform the Fast Fourier Transform.
import numpy as np
from scipy.fftpack import fft, fftfreq, fftshift
from scipy.interpolate import interp1d
import matplotlib.pyplot as plt
x = np.linspace(min(times), max(times), len(times))
y = interp1d(times, data)(x)
yf = fft(y)
xf = fftfreq(len(times), (max(times)-min(times))/len(times))
xf = fftshift(xf)
yplot = fftshift(yf)
plt.figure()
plt.plot(xf, 1.0/len(times) * np.abs(yplot))
plt.grid()
plt.show()
However, this gives a single spike centered on zero instead of an expected frequency graph. How can I get this to give accurate results?
f=0
. Try subtracting the average before the FFT. – tom10data = np.subtract(data,np.average(data))
– gbear605