scipy连续小波变换

发布于:2022-11-06 ⋅ 阅读:(428) ⋅ 点赞:(0)

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


网站公告

今日签到

点亮在社区的每一天
去签到