Skip to main content

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

Project description

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=.1, 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, scales_xo, _ = ssq_cwt(xo, 'morlet')
Wxo /= np.sqrt(scales_xo)  # L1 norm
viz(xo, Txo, Wxo)

Tx, _, Wx, scales_x, _ = ssq_cwt(x, 'morlet')
Wx /= np.sqrt(scales_x)  # L1 norm 
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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ssqueezepy-0.5.0.tar.gz (39.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ssqueezepy-0.5.0-py3-none-any.whl (47.7 kB view details)

Uploaded Python 3

File details

Details for the file ssqueezepy-0.5.0.tar.gz.

File metadata

  • Download URL: ssqueezepy-0.5.0.tar.gz
  • Upload date:
  • Size: 39.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for ssqueezepy-0.5.0.tar.gz
Algorithm Hash digest
SHA256 ccb84c294a7058a15cd7fc38b73dbb9c0a3524a3e4990ae2445ca4496052f72f
MD5 80e5279756aa213e48be17e87eeea18c
BLAKE2b-256 0c8736c96894aeab3dac3be2472ab05c3383e02f3a134a34c35f23cb2f8a90d8

See more details on using hashes here.

File details

Details for the file ssqueezepy-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: ssqueezepy-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 47.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for ssqueezepy-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cfae66991ec4438e47df4cb7df2fd8d2f7a887ee6a6d3f28f06d1cc50b2b203b
MD5 8fd91befb352f8b5785a0e01b8bf6c0c
BLAKE2b-256 4b35a5a2928a45423daad505b11b275c9bdbe05e95dc61af9f26007489bc3c85

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page