scipy连续小波变换

本文介绍了如何使用Scipy库中的连续小波变换(CWT)对数据进行处理。CWT通过对数据执行卷积来实现变换,并允许使用复数形式的小波函数。文中还提供了具体的Python代码示例,演示了如何应用CWT以及可视化结果。
部署运行你感兴趣的模型镜像

scipy连续小波变换

连续小波变换,使用小波函数对数据执行连续小波变换。CWT使用由宽度参数和长度参数表征的小波函数执行与数据的卷积。允许小波函数是复数形式。

接口:

scipy.signal.cwt(data, wavelet, widths, dtype=None, **kwargs)

“”"
Continuous wavelet transform.

Performs a continuous wavelet transform on data, using the wavelet function. A CWT performs a convolution with data using the wavelet function, which is characterized by a width parameter and length parameter. The wavelet function is allowed to be complex.


Parameters
data(N,) ndarray
data on which to perform the transform.


waveletfunction
Wavelet function, which should take 2 arguments. The first argument is the number of points that the returned vector will have (len(wavelet(length,width)) == length). The second is a width parameter, defining the size of the wavelet (e.g. standard deviation of a gaussian). See ricker, which satisfies these requirements.
(小波函数,它应该带2个参数。第一个参数是返回的向量将具有的点数(len(小波(长度,宽度))==length)。第二个是宽度参数,定义了小波的大小(例如高斯的标准差)。参见ricker,它满足了这些要求。)


widths(M,) sequence
Widths to use for transform.


dtype:data-type, optional
The desired data type of output. Defaults to float64 if the output of wavelet is real and complex128 if it is complex.
所需的输出数据类型。如果小波的输出为实值,则默认为float64,如果它是复数的,则复数128。


kwargs
Keyword arguments passed to wavelet function.


Returns
cwt: (M, N) ndarray
Will have shape of (len(widths), len(data)).

对于非对称复值小波,输入信号与小波数据的时反复共轭卷积[1].
“”"

代码

from scipy import signal
import matplotlib.pyplot as plt
import numpy as np

t = np.linspace(-1, 1, 200, endpoint=False)
sig = np.cos(2 * np.pi * 7 * t) + signal.gausspulse(t - 0.4, fc=2)
widths = np.arange(1, 31)
cwtmatr = signal.cwt(sig, signal.ricker, widths)
plt.imshow(cwtmatr, extent=[-1, 1, 31, 1], cmap=‘PRGn’, aspect=‘auto’,
vmax=abs(cwtmatr).max(), vmin=-abs(cwtmatr).max())
plt.show()

在这里插入图片描述

引用

[^1] : S. Mallat, “A Wavelet Tour of Signal Processing (3rd Edition)”, Academic Press, 2009.
et Tour of Signal Processing (3rd Edition)”, Academic Press, 2009.
[^2] : scipy.signal.cwt — SciPy v1.9.3 Manual

您可能感兴趣的与本文相关的镜像

Python3.9

Python3.9

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

KPer_Yang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值