I would like to output a spectrogram that can be drawn with pylab as data.

Asked 2 years ago, Updated 2 years ago, 45 views

from pylab import*
# short
pxx, freqs, bins, im=specgram(data,NFFT=N,Fs=wf.getframerate(), noverlap=0, window=hammingWindow)
axis([0, length, 0, wf.getframerate()/2])
show()

I can make a spectrogram with a code like this, but what should I do if I want you to write it down in a file with numerical data?

python

2022-09-30 21:14

1 Answers

pxx has a spectrogram, freqs has a frequency, and bins has a time, so you can save them to a file in an easy-to-use format.
To plot them: np=numpy, plt=matplotlib.pyplot

W,T=np.meshgrid(bins, freq)
plt.pcolormesh(W,T,pxx)

I think this specgram is matplotlib.pyplot.specgram, but since this is for illustration purposes only, it may be appropriate for scipy.signal.spectrogram.As you can see in the sample,

f,t,Sxx=signal.spectrogram(x,fs)
plt.pcolormesh(t,f,Sxx)

You can see it in


2022-09-30 21:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.