OverLordGoldDragon / ssqueezepy

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

Can I get 0.6.0 `ssq_cwt()` results using 0.6.1 `ssq_cwt`? #44

Closed srvanrell closed 2 years ago

srvanrell commented 2 years ago

I have used ssq_cwt() to get Tx on 0.6.0 version of ssqueezepy. I would like to use speed improvents of 0.6.1 and get the same Tx of 0.6.0 but using 0.6.1 version. Is it possible? How can it be done?

Thanks in advance

EDIT: I have reformulated the question

OverLordGoldDragon commented 2 years ago

Yes: 0.6.1 is identical to or more accurate than 0.6.0 for any feature.

srvanrell commented 2 years ago

Thus I'm more confused than before. I'm not getting the same result, see my minimal example below. Should I do it in another way?

import numpy as np
from ssqueezepy import ssq_cwt

x = np.random.random(120)
Tx, *_ = ssq_cwt(x, nv=16, fs=150)
print(x.shape, Tx.shape)

# on ssqueezepy==0.6.0
# (120,) (68, 120)

# on ssqueezepy==0.6.1
# (120,) (114, 120)
OverLordGoldDragon commented 2 years ago

Default configs have changed; shapes will match by passing scales array. 0.6.1 automates scales more accurately and efficiently - compare

x = ssqueezepy.TestSignals().echirp(N=4096, fmin=1)[0]
Tx, *_ = ssq_cwt(x, ('gmw', {'gamma': 1, 'beta': 1}))
ssqueezepy.visuals.imshow(Tx, abs=1)
srvanrell commented 2 years ago

Thank you for your prompt response! I saw so many changes on 0.6.1 that I got lost on what to do. Sadly, I cannot continue on this right now, I'll try it later on. thanks!

srvanrell commented 2 years ago

Hi @OverLordGoldDragon!

Sorry for getting back on this. Would you give me some advice? I have explored the source code and tried several ways of calling ssq_cwt() on version 0.6.1 but I cannot reproduce the Tx from calling ssq_cwt(x, nv=16, fs=150) on 0.6.0. How should I call ssq_cwt on the 0.6.1 version to get exactly the same result? At least I would like to get the same shape but couldn't do it.


## On 0.6.0
x = ssqueezepy.TestSignals().echirp(N=120, fmin=1)[0]
Tx, *_ = ssq_cwt(x, nv=16, fs=150)
print(x.shape, Tx.shape)
# (120,) (68, 120)

ssqueezepy.visuals.imshow(Tx, abs=1)  # Visually I see that I should use flipud on the new version

#----------------------------------------------------------------------
## On 0.6.1 I have tried:

x = ssqueezepy.TestSignals().echirp(N=120, fmin=1)[0]
Tx, *_ = ssq_cwt(x, ('gmw', {'gamma': 1, 'beta': 1}))
print(x.shape, Tx.shape)
# (120,) (114, 120)

x = ssqueezepy.TestSignals().echirp(N=120, fmin=1)[0]
Tx, *_ = ssq_cwt(x, ('gmw', {'gamma': 1, 'beta': 1}), nv=16, fs=150)
print(x.shape, Tx.shape)
# (120,) (145, 120)

x = ssqueezepy.TestSignals().echirp(N=120, fmin=1)[0]
Tx, *_ = ssq_cwt(x, ('gmw', {'gamma': 1, 'beta': 1}), nv=16, fs=150, flipud=False)
print(x.shape, Tx.shape)
# (120,) (145, 120)

Thanks!

OverLordGoldDragon commented 2 years ago

shapes will match by passing scales array. 0.6.1 automates scales [differently]

You haven't passed scales. If you wish to match Tx of 0.6.0, then np.save its scales, and pass it to 0.6.1. The numeric values may not match exactly per few other changes.

srvanrell commented 2 years ago

Oh, great! Thank you @OverLordGoldDragon !