欢迎来到虫虫下载站 | 资源下载 资源专辑 关于我们
虫虫下载站

specgram_demo.py

非原创。很好的python例子
PY
字号:
#!/usr/bin/env pythonfrom pylab import *dt = 0.0005t = arange(0.0, 20.0, dt)s1 = sin(2*pi*100*t)s2 = 2*sin(2*pi*400*t)# create a transient "chirp"mask = where(logical_and(t>10, t<12), 1.0, 0.0)s2 = s2 * mask# add some noise into the mixnse = 0.01*randn(len(t))x = s1 + s2 + nse # the signalNFFT = 1024       # the length of the windowing segmentsFs = int(1.0/dt)  # the sampling frequency# Pxx is the segments x freqs array of instantaneous power, freqs is# the frequency vector, bins are the centers of the time bins in which# the power is computed, and im is the matplotlib.image.AxesImage# instancePxx, freqs, bins, im = specgram(x, NFFT=NFFT, Fs=Fs, noverlap=900)colorbar()show()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -