S变换的Python代码
- S变换简介
- S变换Python程序
S变换简介
S变换,又称为Stockwell变换,由R. G. Stockwell于1996年提出。具体的定义如下:
S变换在傅里叶域的表示形式为:
离散的S变换为:
S变换克服了短时傅里叶变换固定窗函数宽度的缺陷,采用了一个随频率变化的高斯窗函数。它的窗函数宽度与频率的倒数成正比,高频时用窄窗,低频用宽窗。所以具有多分辨率分析的思想,也可以看作相位校正的小波变换。
S变换Python程序
def st(t,s, freqlow, freqhigh, alpha):TimeLen=len(t)dt=t[1]-t[0]nLevel=int((freqhigh-freqlow)/alpha)+1fre=np.linspace(freqlow,freqhigh,nLevel)wcoefs=np.zeros((nLevel,TimeLen),dtype=complex)temp = np.zeros((1, TimeLen),dtype=complex)sigma_f = np.power(fre,-1)for m in range(0,nLevel):f=fre[m]for n in range(0,TimeLen):Gauss_st= (1/(math.sqrt(2*math.pi)*sigma_f[m]))*np.exp(-0.5*(np.power(n*dt-t,2)/(sigma_f[m]*sigma_f[m])))*np.exp(-1.0j*2*math.pi*f*t)temp[0,n]=np.sum(np.dot(s, Gauss_st))*dtwcoefs[[m],:]=tempreturn wcoefs
R. G. Stockwell, L. Mansinha, and R. Lowe, “Localization of the
complex spectrum: the S transform,” IEEE transactions on signal
processing, vol. 44, no. 4, pp. 998–1001, 1996.