I'm puzzled by some very simple concept with building up a spectrogram.
Here is a toy example of the issue:
import numpy as np import scipy from scipy import signal import matplotlib.pyplot as plt f0 = 5 t = 2 fs = 250 N = t*fs t = np.linspace(0, t, N, endpoint=False) x = np.sin(2*scipy.pi*f0*t) f, t, Sxx = signal.spectrogram(x, fs) plt.pcolormesh(t, f, Sxx) plt.ylabel('Frequency [Hz]') plt.xlabel('Time [sec]') plt.show()
What I get for
t puzzles me, I get
[0.512,1.408]. I would expect to get an array starting from
2.0 seconds long - so if I want to see the power spectrum density in 1.8 seconds I could easily do so.
I probably miss something pretty basic, so it would be great if someone could shed some light on this.