Python环境下小波函数的绘制

B站影视 2025-01-11 12:34 2

摘要:import itertoolsimport matplotlib.pyplot as pltimport pywtplot_data = [('db', (4, 3)),('sym', (4, 3)),('coif', (3, 2))]for family,

import itertoolsimport matplotlib.pyplot as pltimport pywtplot_data = [('db', (4, 3)),('sym', (4, 3)),('coif', (3, 2))]for family, (rows, cols) in plot_data:fig = plt.figurefig.subplots_adjust(hspace=0.2, wspace=0.2, bottom=.02, left=.06,right=.97, top=.94)colors = itertools.cycle('bgrcmyk')wnames = pywt.wavelist(family)i = iter(wnames)for col in range(cols):for row in range(rows):try:wavelet = pywt.Wavelet(next(i))except StopIteration:breakphi, psi, x = wavelet.wavefun(level=5)color = next(colors)ax = fig.add_subplot(rows, 2 * cols, 1 + 2 * (col + row * cols))ax.set_title(wavelet.name + " phi")ax.plot(x, phi, color)ax.set_xlim(min(x), max(x))ax = fig.add_subplot(rows, 2*cols, 1 + 2*(col + row*cols) + 1)ax.set_title(wavelet.name + " psi")ax.plot(x, psi, color)ax.set_xlim(min(x), max(x))for family, (rows, cols) in [('bior', (4, 3)), ('rbio', (4, 3))]:fig = plt.figurefig.subplots_adjust(hspace=0.5, wspace=0.2, bottom=.02, left=.06,right=.97, top=.94)colors = itertools.cycle('bgrcmyk')wnames = pywt.wavelist(family)i = iter(wnames)for col in range(cols):for row in range(rows):try:wavelet = pywt.Wavelet(next(i))except StopIteration:breakphi, psi, phi_r, psi_r, x = wavelet.wavefun(level=5)row *= 2color = next(colors)ax = fig.add_subplot(2*rows, 2*cols, 1 + 2*(col + row*cols))ax.set_title(wavelet.name + " phi")ax.plot(x, phi, color)ax.set_xlim(min(x), max(x))ax = fig.add_subplot(2*rows, 2*cols, 2*(1 + col + row*cols))ax.set_title(wavelet.name + " psi")ax.plot(x, psi, color)ax.set_xlim(min(x), max(x))row += 1ax = fig.add_subplot(2*rows, 2*cols, 1 + 2*(col + row*cols))ax.set_title(wavelet.name + " phi_r")ax.plot(x, phi_r, color)ax.set_xlim(min(x), max(x))ax = fig.add_subplot(2*rows, 2*cols, 1 + 2*(col + row*cols) + 1)ax.set_title(wavelet.name + " psi_r")ax.plot(x, psi_r, color)ax.set_xlim(min(x), max(x))plt.show

知乎学术咨询:

https://www.zhihu.com/consult/people/792359672131756032?isMe=1

担任《Mechanical System and Signal Processing》《中国电机工程学报》等期刊审稿专家,擅长领域:信号滤波/降噪,机器学习/深度学习,时间序列预分析/预测,设备故障诊断/缺陷检测/异常检测。

分割线分割线分割线

信号的交叉循环调制谱(MATLAB)

完整代码:

基于Teager-Kaiser能量算子 (TKEO)的肌电信号EMG降噪方法(MATLAB)

基于Transformer和时间嵌入的外汇股价预测(Python,ipynb文件)

完整代码:

非平稳信号的恒Q时频分析方法(Python)

完整代码:

基于经验模态分解、离散小波变换和AR模型的肌电图信号降噪(Python,ipynb文件)

来源:彤茜教育

相关推荐