OverLordGoldDragon / ssqueezepy

Synchrosqueezing, wavelet transforms, and time-frequency analysis in Python
MIT License
599 stars 92 forks source link

ssqueezepy vs wsst of MatLab #97

Closed Ayubirad closed 11 months ago

Ayubirad commented 11 months ago

Dear @OverLordGoldDragon

I have defined the same signal in both MatLab and Python but the results differ! Please could you help me out to see where's the issue? MatLab results are much more clear!

Best regards, Mohammad

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

# Define the signal and sampling frequency
fs = 20 # Sampling frequency in Hz
t = np.arange(0, 10, 1/fs)
x = np.sin(2 * np.pi * t)

fig, axs = plt.subplots(figsize=(15,10))   
kw = dict(wavelet=Wavelet(('morlet'), N=1024), scales='log-piecewise', nv=32, fs=None, t=t,
            ssq_freqs=None, padtype='symmetric', squeezing='sum', maprange='energy',
            difftype='trig', difforder=None, gamma=None, vectorized=True,
            preserve_transform=None, astensor=True, order=0, nan_checks=None,
            patience=0, flipud=True, cache_wavelet=None,
            get_w=False, get_dWx=False)
Tx, Wx, ssq_freqs, scales = ssq_cwt(x, **kw)
imshow(Tx, abs=1, ridge=0, cmap='turbo', yticks=ssq_freqs, xticks=t, show=1, title="abs(SSQ_CWT)", 
       xlabel='Time (sec)', ylabel='Frequency [Hz]', ax=axs, fig=fig)

Figure 2023-08-25 191102 barchart