资源简介
传统的经验模态分解,适合初级的研究生学习故障诊断,信号处理方式。
代码片段和文件信息
#-*- coding: utf-8 -*-
import math
import numpy as np
import pylab as pl
import matplotlib.pyplot as plt
import scipy.signal as signal
from scipy import fftpack
from scipy.fftpack import fft ifft
import scipy.signal as signal
from scipy import interpolate
# 判定当前的时间序列是否是单调序列
def ismonotonic(x):
max_peaks = signal.argrelextrema(x np.greater)[0]
min_peaks = signal.argrelextrema(x np.less)[0]
all_num = len(max_peaks) + len(min_peaks)
if all_num > 0:
return False
else:
return True
# 寻找当前时间序列的极值点
def findpeaks(x):
return signal.argrelextrema(x np.greater)[0]
# 判断当前的序列是否为 IMF 序列
def isImf(x):
N = np.size(x)
pass_zero = np.sum(x[0:N - 2] * x[1:N - 1] < 0) # 过零点的个数
peaks_num = np.size(findpeaks(x)) + np.size(findpeaks(-x)) # 极值点的个数
if abs(pass_zero - peaks_num) > 1:
return False
else:
return True
# 获取当前样条曲线
def getspline(x):
N = np.size(x)
peaks = findpeaks(x)
print (‘当前极值点个数:‘ len(peaks))
if (len(peaks) <= 3):
if (len(peaks) < 2):
peaks = np.concatenate(([0] peaks))
peaks = np.concatenate((peaks [N - 1])) # 这里是为了防止样条次数不够,无法插值的情况
t = interpolate.splrep(peaks y=x[peaks] w=None xb=None xe=None k=len(peaks) - 1)
return interpolate.splev(np.arange(N) t)
t = interpolate.splr
评论
共有 条评论