zwbjtu123 / ssqueezepy

Synchrosqueezing, wavelet transforms, and time-frequency analysis in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Synchrosqueezing in Python

Build Status Coverage Status PyPI version Codacy Badge License: MIT

Synchrosqueezing is a powerful reassignment method that focuses time-frequency representations, and allows extraction of instantaneous amplitudes and frequencies. Friendly overview.

Features

  • Forward & inverse CWT-based Synchrosqueezing
  • Forward & inverse Continuous Wavelet Transform (CWT)
  • Clean code with explanations and learning references
  • Wavelet visualizations

Coming soon

  • Forward & inverse Short-Time Fourier Transform (STFT)
  • STFT-based Synchrosqueezing
  • Generalized Morse Wavelets

Installation

pip install ssqueezepy. Or, for latest version (most likely stable):

pip install git+https://github.com/OverLordGoldDragon/ssqueezepy

Examples

1. Signal recovery under severe noise

image

2. Medical: EEG

Introspection

ssqueezepy is equipped with a visualization toolkit, useful for exploring wavelet behavior across scales and configurations. (Also see explanations and code)



Minimal example

import numpy as np
import matplotlib.pyplot as plt
from ssqueezepy import ssq_cwt

def viz(x, Tx, Wx):
    plt.plot(x);  plt.show()    
    plt.imshow(np.abs(Wx), aspect='auto', cmap='jet')
    plt.show()
    plt.imshow(np.flipud(np.abs(Tx)), aspect='auto', vmin=0, vmax=.2, cmap='jet')
    plt.show()   
    
#%%# Define signal ####################################    
N = 2048
t = np.linspace(0, 10, N, endpoint=False)
xo = np.cos(2 * np.pi * np.exp(t / 3))
x = xo + np.sqrt(4) * np.random.randn(N)

#%%# SSQ CWT + CWT ####################################
Txo, _, Wxo, *_ = ssq_cwt(xo, 'morlet')
viz(xo, Txo, Wxo)

Tx, _, Wx, *_ = ssq_cwt(x, 'morlet')
viz(x, Tx, Wx)

References

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]. Many implementation details draw from [4].

  1. G. Thakur, E. Brevdo, N.-S. Fučkar, and H.-T. Wu. "The Synchrosqueezing algorithm for time-varying spectral analysis: robustness properties and new paleoclimate applications", Signal Processing 93:1079-1094, 2013.
  2. I. Daubechies, S. Maes. "A Nonlinear squeezing of the CWT Based on Auditory Nerve Models".
  3. I. Daubechies, J. Lu, H.T. Wu. "Synchrosqueezed Wavelet Transforms: a Tool for Empirical Mode Decomposition", Applied and Computational Harmonic Analysis 30(2):243-261, 2011.
  4. Mallat, S. "Wavelet Tour of Signal Processing 3rd ed".

License

ssqueezepy is MIT licensed, as found in the LICENSE file. Some source functions may be under other authorship/licenses; see NOTICE.txt.

About

Synchrosqueezing, wavelet transforms, and time-frequency analysis in Python

License:MIT License


Languages

Language:Python 100.0%