def plot_deriv_fft(df):
# Number of samplepoints
N = len(df)
# sample spacing
T = BINSIZE*60.0
x = np.linspace(0.0, N*T, N-1)
y = [df.values[i]-df.values[i-1] for i in range(1,len(df.values))] #np.sin(50.0 * 2.0*np.pi*x) + 0.5*np.sin(80.0 * 2.0*np.pi*x)
yf = fftpack.fft(y)
xf = np.linspace(0.0, 1.0/(2.0*T), N/2)
fig, ax = plt.subplots()
ax.plot(x, y)
plt.savefig(FIG_DIR+'deriv.png', bbox_inches='tight')
fig, ax = plt.subplots()
ax.plot(xf, 2.0/N * np.abs(yf[:N//2]))
plt.savefig(FIG_DIR+'fft_deriv.png', bbox_inches='tight')
评论列表
文章目录