gpt4 book ai didi

python - scipy.signal.spectrogram 和 scipy.signal.stft 有什么区别?

转载 作者:太空宇宙 更新时间:2023-11-03 15:34:28 24 4
gpt4 key购买 nike

函数
spicy.signal.spectrogram:https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.spectrogram.html

spicy.signal.stft:https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.stft.html
似乎做了一件很相似的事情。

这两个函数有什么区别?

最佳答案

Tl;dr:如果我用 SciPy 文档给出的输出编写它:Sxx = Zxx ** 2

解释:频谱图和短时傅里叶变换是两个不同的对象,但它们却非常接近。

The short-time Fourier transform (STFT), is a Fourier-related transform used to determine the sinusoidal frequency and phase content of local sections of a signal as it changes over time. In practice, the procedure for computing STFTs is to divide a longer time signal into shorter segments of equal length and then compute the Fourier transform separately on each shorter segment. This reveals the Fourier spectrum on each shorter segment. One then usually plots the changing spectra as a function of time. Wikipedia

另一方面,

A spectrogram is a visual representation of the spectrum of frequencies of a signal as it varies with time. Wikipedia

频谱图基本上会在小窗口中截断您的信号,并显示一系列颜色来表示这个或那个特定频率的强度。与 STFT 完全一样。事实上,它正在使用 STFT。

现在,对于差异,根据定义,频谱图是信号 s(t) 的短时傅立叶变换 (STFT) 的平方幅度:

频谱图(t, w) = |STFT(t, w)|^2

scipy.signal.stft 页面底部显示的示例显示:

>>> plt.pcolormesh(t, f, np.abs(Zxx), vmin=0, vmax=amp)

它正在运行,您可以看到色标。但它是线性的,因为 abs 操作。

实际上,要获得真正的频谱图,应该这样写:

>>> plt.pcolormesh(t, f, Zxx ** 2, vmin=0, vmax=amp)

关于python - scipy.signal.spectrogram 和 scipy.signal.stft 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55683936/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com