Hilbert变换提取信号特征的Python实现

本文通过Python的Scipy库展示了希尔伯特变换如何用于信号处理,特别是如何提取信号的幅度包络和瞬时频率。示例中,创建了一个随时间频率变化的信号并应用了幅度调制。希尔伯特变换将实数信号转换为复数信号,其幅度和相位揭示了信号的幅度包络和瞬时特性。
摘要由CSDN通过智能技术生成

Hilbert变换的物理意义:将一个一维实数信号变为二维复平面上的信号,复数的模和角度代表了信号的幅度和相位。换句话说,频谱的负一半被清零,从而将实数信号转换为复数信号。

参数:

x:array_like信号数据。必须是真实的。

N:int, 可选参数傅立叶分量的数量。默认:x.shape[axis]

axis:int, 可选参数沿其进行转换的轴。默认值:-1

返回值:

xa:ndarray沿轴的每个1-D数组x的解析信号

  import numpy as np

  import matplotlib.pyplot as plt

 from scipy.signal import hilbert, chirp

  duration = 1.0

  fs = 400.0

  samples = int(fs*duration)

 t = np.arange(samples) / fs

我们创建一个rp,其频率从20 Hz增加到100 Hz,并应用幅度调制。

  signal = chirp(t, 20.0, t[-1], 100.0)

  signal *= (1.0 + 0.5 * np.sin(2.0*np.pi*3.0*t) )

幅度包络由分析信号的幅度给出。瞬时频率可以通过相对于时间区分瞬时相位来获得。瞬时相位对应于分析信号的相位角。

  analytic_signal = hilbert(signal)

 amplitude_envelope = np.abs(analytic_signal)

  instantaneous_phase = np.unwrap(np.angle(analytic_signal))

  instantaneous_frequency = (np.diff(instantaneous_phase) /

... (2.0*np.pi) * fs)

  fig = plt.figure()

  ax0 = fig.add_subplot(211)

  ax0.plot(t, signal, label='signal')

  ax0.plot(t, amplitude_envelope, label='envelope')

  ax0.set_xlabel("time in seconds")

  ax0.legend()

  ax1 = fig.add_subplot(212)

  ax1.plot(t[1:], instantaneous_frequency)

  ax1.set_xlabel("time in seconds")

  ax1.set_ylim(0.0, 120.0)

感谢原文出自于python 希尔伯特变换_python scipy signal.hilbert用法及代码示例

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值