安装:pip install EMD-signal
我大概看了原理,看的不是特别明白,只记录一下我觉得有用的地方
EMD,经验模态分解,是一种信号分解的技术;
它提出了一个概念叫 基本模态分量 IMF,
EMD 用于处理非平稳信号,可用于任意数据,基于数据本身进行分解;
EMD 把一个信号分解成 多个 IMF,每个 IMF 具有线性和非线性的特点,还有一个 信号残余分量,常常代表信号的直流分量或者信号的趋势;
EMD 分解得到的 IMF,频率逐渐降低,尺度各不相同;
EMD 分解得到的前几个模态分量,通常集中了原始信号中最显著、最重要的信息;
EMD 分解容易造成 模态混合,表现为下列现象之一:
1. 在同一个 IMF 中,尺度分布范围很宽却又各不相同的信号;
2. 在不同 IMF 中,存在尺度相近的信号;
模态混合使得 IMF 失去单一特征尺度,形成尺度混杂的震荡,失去原有的物理意义
EEMD,集合经验模态分解,解决了 EMD 模态混合的现象
Python EMD 用法
##### 基本用法
importnumpy as npfrom PyEMD importEMDimportpylab as plt
s= np.random.random(100)
emd=EMD()
IMFs=emd.emd(s)##### 示例#Define signal
t = np.linspace(0, 1, 200)
s= np.cos(11*2*np.pi*t*t) + 6*t*t#Execute EMD on signal
IMF =EMD().emd(s,t)
N= IMF.shape[0]+1
#Plot results
plt.subplot(N,1,1)
plt.plot(t, s,‘r‘)
plt.title("Input signal: $S(t)=cos(22\pi t^2) + 6t^2$")
plt.xlabel("Time [s]")for n, imf inenumerate(IMF):
plt.subplot(N,1,n+2)
plt.plot(t, imf,‘g‘)
plt.title("IMF"+str(n+1))
plt.xlabel("Time [s]")
plt.tight_layout()
plt.savefig(‘simple_example‘)
plt.show()
输出
Python EEMD 用法
from PyEMD importEEMDimportnumpy as npimportpylab as pltdefmain():#Define signal
t = np.linspace(0, 1, 200)
sin= lambda x,p: np.sin(2*np.pi*x*t+p)
S= 3*sin(18,0.2)*(t-0.2)**2S+= 5*sin(11,2.7)
S+= 3*sin(14,1.6)
S+= 1*np.sin(4*2*np.pi*(t-0.8)**2)
S+= t**2.1 -t#Assign EEMD to `eemd` variable
eemd =EEMD()#Say we want detect extrema using parabolic method
#emd = eemd.EMD
#emd.extrema_detection="parabol"
#eemd.trials = 50
#eemd.noise_seed(12345)
#Execute EEMD on S
eIMFs = eemd.eemd(S, t, -1)
nIMFs=eIMFs.shape[0]#Plot results
plt.figure(figsize=(12,9))
plt.subplot(nIMFs+1, 1, 1)
plt.plot(t, S,‘r‘)for n inrange(nIMFs):
plt.subplot(nIMFs+1, 1, n+2)
plt.plot(t, eIMFs[n],‘g‘)
plt.ylabel("eIMF %i" %(n+1))
plt.locator_params(axis=‘y‘, nbins=5)
plt.xlabel("Time [s]")
plt.tight_layout()
plt.savefig(‘eemd_example‘, dpi=120)
plt.show()if __name__ == ‘__main__‘:
main()
参考资料:
《Adaboost_SVM集成模型的滚动轴承早期故障诊断》 电子书