Python - EEMD分解

# 导入工具包
import numpy as np
from PyEMD import EEMD, EMD, Visualisation
import pylab as plt

def Signal():
global E_imfNo
E_imfNo = np.zeros(50, dtype=np.int)

# EEMD options
max_imf = -1

"""
信号参数:
N:采样频率500Hz
tMin:采样开始时间
tMax:采样结束时间 2*np.pi
"""
N = 500
tMin, tMax = 0, 2 * np.pi
T = np.linspace(tMin, tMax, N)
# 信号S:是多个信号叠加信号
S = 3 * np.sin(4 * T) + 4 * np.cos(9 * T) + np.sin(8.11 * T + 1.2)

# EEMD计算
eemd = EEMD()
eemd.trials = 50
eemd.noise_seed(12345)

E_IMFs = eemd.eemd(S, T, max_imf)
imfNo = E_IMFs.shape[0]

# Plot results in a grid
c = np.floor(np.sqrt(imfNo + 1))
r = np.ceil((imfNo + 1) / c)
    plt.ioff()
plt.subplot(r, c, 1)
plt.plot(T, S, 'r')
plt.xlim((tMin, tMax))
plt.title("Original signal")

for num in range(imfNo):
plt.subplot(r, c, num + 2)
plt.plot(T, E_IMFs[num], 'g')
plt.xlim((tMin, tMax))
plt.title("Imf " + str(num + 1))

plt.show()
if __name__ == "__main__":
Signal()


转自:https://www.cnblogs.com/RoseVorchid/p/12030980.html
posted @ 2020-06-24 09:33  学渣奋进  阅读(5254)  评论(0编辑  收藏  举报