You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a previous issue, a commenter pointed out that the scale_to_freq function returns repetitive frequencies. From what I understand, you have successfully reduced the number of repetitive frequencies, but not removed them entirely. In my application, the first 5 frequencies (the lowest scales) are all repeats, and for the last few frequencies (the highest scales) they are all repeated many times.
For applications that need one value of power for each frequency, which scale is the "correct" scale for the stated frequency? The power values returned for frequencies which are repeated are not the same. Is there any further advice you can give for reducing the issue of repeated frequencies?
code to reproduce
import numpy as np
from ssqueezepy import cwt
from ssqueezepy.experimental import scale_to_freq
Thanks for the report. Reproduced (scale_to_freq problem), fixed in #114.
Now it's 11%. scales='log-piecewise' is already a significant reduction (relative to 'log'), but its handling isn't flawless. It's a fundamental continuous-discrete limitation with CWT. There is a workaround, though not pure-CWT based, and not part of ssqueezepy.
But also, the repetition's in the peak center frequency (what scale_to_freq returns). Other measures won't always agree. Visually inspecting, only a few wavelets are duplicate-ish:
visuals code
fromssqueezepy.visualsimportplotfreqs, repeats= [], []
forfinfreqs_cwt:
iffinfreqsandf!=2048: # avoid 2048 to avoid large gap in plotrepeats.append(f)
else:
freqs.append(f)
plot(wavelet._Psih[-66:, :50].T, color='tab:blue',
vlines=(repeats, {'color': 'tab:red', 'linewidth': 1}))
Patch note: I expect that most affected were the lowest frequencies, and most frequencies were minorly affected. One could measure as |1 - f_new/f_old| vs freq index, with both f_new and f_old computed using the new function, but f_old using scale_to_freq(, padtype=None).
Concerning MATLAB and the rest, I consider it out of scope. But if you can show inaccuracy in scale_to_freq, I'll take it as a bug report.
In a previous issue, a commenter pointed out that the scale_to_freq function returns repetitive frequencies. From what I understand, you have successfully reduced the number of repetitive frequencies, but not removed them entirely. In my application, the first 5 frequencies (the lowest scales) are all repeats, and for the last few frequencies (the highest scales) they are all repeated many times.
For applications that need one value of power for each frequency, which scale is the "correct" scale for the stated frequency? The power values returned for frequencies which are repeated are not the same. Is there any further advice you can give for reducing the issue of repeated frequencies?
code to reproduce
import numpy as np
from ssqueezepy import cwt
from ssqueezepy.experimental import scale_to_freq
duration = 100 # seconds
sampling_rate = 2 # Hz
time = np.arange(0, duration, 1/sampling_rate)
rri_signal = 1 + 0.1 * np.sin(2 * np.pi * 0.1 * time)
wavelet_type = 'morlet'
Wx, scales = cwt(rri_signal, fs=sampling_rate, wavelet=wavelet_type, padtype=None)
freqs = scale_to_freq(scales, wavelet_type, len(rri_signal), sampling_rate, padtype=None)
print(freqs)
Originally posted by @OverLordGoldDragon in #113
The text was updated successfully, but these errors were encountered: