pywt icon indicating copy to clipboard operation
pywt copied to clipboard

selected scale too small

Open gslapnicar opened this issue 7 years ago • 0 comments

Hi. I've been reading through https://github.com/PyWavelets/pywt/issues/379 and there seems to be some correlation to mine, but i was not able to fix it still. When using small scales, i get:

ValueError: Selected scale of 0.038720532367775645 too small.

When running pywt.scale2frequency('morl', scale=0.0387, precision=10) i get 20.99483204134367, which seems ok for my signal sampled at 50Hz.

My original snippet is as follows:

import pywt Prepare wavelet scales morletFourierFactor = 4math.pi / (6+math.sqrt(2+6**2)) sc0 = 1 / (0.5FsmorletFourierFactor) ds = 0.03125 scMax = 1 / (0.50.5*morletFourierFactor) nSc = int(math.log2(scMax / sc0) / ds) scales = [sc0, ds, nSc]

Wavelet filtering sig = np.squeeze(zeroMeanUnitVarPPG) period = 1/Fs coefs, freqs = pywt.cwt(data=sig, scales=scales, wavelet='morl', sampling_period=period)

Any insight or help about how to resolve this with small scale would be greatly appreciated. Thanks in advance.

EDIT: the original matlab code for the scales computation is taken from another author and is as follows:

MorletFourierFactor = 4pi/(6+sqrt(2+6^2)); sc0 = 1/(0.5ippgSettings.samplingRateMorletFourierFactor); %take default smallest scale (corresponding to Nyquist frequency) ds = 0.03125; %32 scales per octave scMax = 1/(0.5ippgSettings.minFreqMorletFourierFactor); % we do not consider low freq components nSc = fix(log2(scMax/sc0)/ds); scales = {sc0, ds, nSc}; % we use default formula for scales: sc02.^((0:nSc-1)*ds)

gslapnicar avatar Dec 18 '18 10:12 gslapnicar