Python 中的同步压缩、小波变换和时频分析
Synchrosqueezing is a powerful reassignment method that focuses time-frequency representations, and allows extraction of instantaneous amplitudes and frequencies. Friendly overview.
1: feel free to open Issue showing otherwise
pip install ssqueezepy. Or, for latest version (most likely stable):
pip install git+https://github.com/OverLordGoldDragon/ssqueezepy
Multi-threaded execution is enabled by default (disable via os.environ['SSQ_PARALLEL'] = '0'). GPU requires CuPy >= 8.0.0
and PyTorch >= 1.8.0 installed (enable via os.environ['SSQ_GPU'] = '1'). pyfftw optionally supported for maximum CPU FFT speed.
See Performance guide.
Code. Transforms use padding, float32 precision (float64 supported), and output shape
(300, len(x)), averaged over 10 runs. pyfftw not used, which'd speed 1-thread & parallel further. Benched on author's i7-7700HQ, GTX 1070.
len(x)-transform |
1-thread CPU | parallel | gpu | pywavelets | scipy | librosa |
|---|---|---|---|---|---|---|
| 10k-cwt | 0.126 | 0.0462 | 0.00393 | 3.58 | 0.523 | - |
| 10k-stft | 0.108 | 0.0385 | 0.00534 | - | 0.118 | 0.0909 |
| 10k-ssq_cwt | 0.372 | 0.148 | 0.00941 | - | - | - |
| 10k-ssq_stft | 0.282 | 0.147 | 0.0278 | - | - | - |
| 160k-cwt | 2.99 | 1.25 | 0.0367 | 12.7 | 10.7 | - |
| 160k-stft | 1.66 | 0.418 | 0.0643 | - | 1.93 | 1.38 |
| 160k-ssq_cwt | 8.38 | 3.16 | 0.0856 | - | - | - |
| 160k-ssq_stft | 4.65 | 2.48 | 0.159 | - | - | - |
See here.
ssqueezepy is equipped with a visualization toolkit, useful for exploring wavelet behavior across scales and configurations. (Also see explanations and code)
In a nutshell, synchrosqueezing exploits redundancy of a time-frequency representation to sparsely localize oscillations, by imposing a prior. That is, we assume x is well-captured by AM-FM components, e.g. based on our knowledge of the underlying process. We surpass Heisenberg's limitations, but only for a subset of all possible signals. It's also akin to an attention mechanism.
Convolve with localized, analytic kernels
compute phase transform, then combine oscillations with a shared rate
…
Also see ridge extraction README.
ssq_cwt and ssq_stft used together to solve an ML problem without MLFeel free to share yours here.
DSP fundamentals: I recommend starting with 3b1b's Fourier Transform, then proceeding with DSP Guide chapters 7-11. The Discrete Fourier Transform lays the foundation of signal processing with real data. Deeper on DFT coefficients here, also 3b1b.
ridge_extraction.py; examples/: extracting_ridges.py, ridge_extraction/README.md)Open an Issue, and follow the Issues Template. Mainly code-related questions go to Stack Overflow (SO). Applications, theory questions, etc go elsewhere, e.g. DSP.SE. I may or may not respond, but others may (or may not) help. I don't follow SO.
Do not send e-mail, LinkedIn messages, etc - they will be ignored.
Short form:
John Muradeli, ssqueezepy, 2020. GitHub repository, https://github.com/OverLordGoldDragon/ssqueezepy/. DOI: 10.5281/zenodo.5080508
BibTeX:
@article{OverLordGoldDragon2020ssqueezepy,
title={ssqueezepy},
author={John Muradeli},
journal={GitHub. Note: https://github.com/OverLordGoldDragon/ssqueezepy/},
year={2020},
doi={10.5281/zenodo.5080508},
}
ssqueezepy was originally ported from MATLAB's Synchrosqueezing Toolbox, authored by E. Brevdo and G. Thakur [1]. Synchrosqueezed Wavelet Transform was introduced by I. Daubechies and S. Maes [2], which was followed-up in [3], and adapted to STFT in [4]. Many implementation details draw from [5]. Ridge extraction based on [6].
ssqueezepy is MIT licensed, as found in the LICENSE file. Some source functions may be under other authorship/licenses; see NOTICE.txt.
暂无开放 Issues,或尚未同步最近议题。