Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

center_frequency yields negative frequency for extreme scale #41

Open
scottfleming opened this issue Aug 11, 2021 · 1 comment
Open
Labels
bug Something isn't working

Comments

@scottfleming
Copy link

The following example returns wc = -3.1354 but according to the specs it should be nonnegative, unless I'm misunderstanding something.

from ssqueezepy import wavelets, Wavelet
wavelet = Wavelet(("morlet", {"mu":14.0}))
_ = wavelets.center_frequency(
    wavelet,  
    scale=np.array([1.0]),  
    kind='peak',
    N=1024,
    viz=1
)
@OverLordGoldDragon OverLordGoldDragon added the bug Something isn't working label Aug 12, 2021
@OverLordGoldDragon
Copy link
Owner

OverLordGoldDragon commented Aug 12, 2021

Thanks for the report.

Current imlpementations of center_frequency, time_resolution, and freq_resolution are discretized approximations of underlying continuous-time parameters. This is a flawed approach (I didn't know better at the time), and I may improve it eventually to base on discrete logic.

The problem here specifically is that the wavelet isn't "well-behaved" at this scale - meaning, its lowest frequency goes either to left of FFT bin 1, or its highest frequency to right of Nyquist. The most generous well-behaved range can be found as:

from ssqueezepy import Wavelet
from ssqueezepy.utils import cwt_scalebounds

wavelet = Wavelet(("morlet", {"mu":14.0}))
cwt_scalebounds(wavelet, N=1024, preset='maximal')
# (4.081687670534748, 4545.465174704532)

Granted it still shouldn't return a negative, so it's an unhandled edge case.

@OverLordGoldDragon OverLordGoldDragon changed the title Bug: wavelets.center_frequency yields negative frequency with large mu and small scale center_frequency yields negative frequency for extreme scale Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants