I'm trying to test some intuition using the matplotlib specgram routine. I first generate a simple sine wave
import matplotlib.mlab as mlab import matplotlib.pyplot as plt import numpy as np t = linspace(0,100,1000) omega = 2*np.pi*1 y = np.sin(omega*t) plt.plot(t,y) plt.show()
This generates the expected image of a sine wave
I can also look at the mod squared of the FFT of this signal:
the_fft = np.fft(y) spacing = t - t ps = the_fft * np.conj(the_fft) freqs = np.fft.fftfreq(len(t),spacing) idx = np.argsort(freqs) plt.plot(freqs[idx],ps[idx]) plt.show()
which gives me the square of the Fourier transform, which has a peak at 1 as expected (since my frequency is 1).
I then try to compute the specgram, as
_ = plt.specgram(the_fft,NFFT=100,noverlap=0,Fs=1./spacing,window=mlab.window_none)
which then gives me this .
From this it's not easy to tell that the only frequency present in the signal is 1. What needs to be done in the specgram call to see this? Of course this is probably the expected output of this, so I'm really also asking a basic DSP question at the same time.