PyWavelets / pywt

PyWavelets - Wavelet Transforms in Python
http://pywavelets.readthedocs.org
MIT License
1.97k stars 460 forks source link

It seems swt_max_level does not caculate correctly #655

Closed shoukewei closed 1 year ago

shoukewei commented 1 year ago

example

max_L = pywt.swt_max_level(16) print(max_L)

Output: 4

But max_L = pywt.swt_max_level(20) print(max_L)

Output: 2

length=120: max_L = 3 length=1000: max_L = 3

Thanks

grlee77 commented 1 year ago

This is a known limitation of the algorithm currently being used for the SWT. See more info in the notes here

shoukewei commented 1 year ago

Hi Gregory,

Thank you for your quick response. I am a University Professor teaching and also providing online courses of practical wavelet transforms using PyWavelets on world-famous e-learning platforms. I used matlab for many years for my research and published several papers on combination of ANN, Deep learning and Wavelets in Journals. I love Python, and PyWavelets is really a great tool, which made me totally shift from matlab to Python.

I understand it now. Then the problem seems more simple to solve. "for an n-level transform, the signal length must be a multiple of 2**n". Then n is the maximum level.

For example: 16 samples -> 2^4. Then 4 is the maximum level. 20 sample -> pad to 32 samples using np.pad or pywt.pad, i.e. 2^5, then 5 is maximum level,

Thus it is unnecessary to use pywt.swt_max_level (), or because pywt.swt_max_level ( ) = n*

I appreciate you guys very much.

Best regards Shouke

On Thu, Sep 15, 2022 at 5:06 AM Gregory Lee @.***> wrote:

This is a known limitation of the algorithm currently being used for the SWT. See more info in the notes here https://pywavelets.readthedocs.io/en/latest/ref/swt-stationary-wavelet-transform.html#maximum-decomposition-level-swt-max-level

— Reply to this email directly, view it on GitHub https://github.com/PyWavelets/pywt/issues/655#issuecomment-1248012402, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASFUUJ6XJH2FDTHDCTPYSWTV6MGMBANCNFSM6AAAAAAQNAIHFY . You are receiving this because you authored the thread.Message ID: @.***>

-- Shouke Wei, Ph.D., Professor Principal Scientist Deepsim Intelligence Technology Inc. Professor School of Computer and Controlling Engineering Yantai University Cell: +1 -235-458 1518 Phone: +1 604-764-9395 E-mail: @.*** Company Web: deepsim.co Online Courses: deepsim.institute