Guest User

Untitled

a guest
Oct 1st, 2020
96
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. import scipy.signal as sig
  4.  
  5. from pywt._extensions._pywt import DiscreteContinuousWavelet
  6. from pywt._functions import integrate_wavelet
  7.  
  8. #%%##########################################################################
  9. scales = np.power(2 ** (1 / 32), np.arange(1, 256 + 1))
  10.  
  11. wavelet = DiscreteContinuousWavelet('morl')
  12. int_psi, x = integrate_wavelet(wavelet, precision=10)
  13.  
  14. linrange = max(x) - min(x)
  15. step = linrange / len(x)  # == x[1] - x[0]
  16. #%%##########################################################################
  17. mae = []
  18. for scale in scales:
  19.     j = np.arange(scale * linrange + 1) / (scale * step)
  20.     j = j.astype(int)  # floor
  21.     if j[-1] >= int_psi.size:
  22.         j = np.extract(j < int_psi.size, j)
  23.     int_psi_scale = int_psi[j][::-1].real
  24.  
  25.     Ns = len(int_psi_scale)
  26.     w = np.real(sig.morlet2(Ns, Ns / 16) * np.sqrt(Ns / 16) * np.pi**(.25))
  27.     w_int = np.cumsum(w)[::-1] / scale
  28.  
  29.     mae.append(np.mean(np.abs(w_int - int_psi_scale)))
  30. #%%##########################################################################
  31. plt.plot(np.log2(scales), mae)
  32. plt.title("MAE vs log2(scale)", fontsize=16, fontweight='bold')
  33. plt.show()
  34.  
  35. plt.plot(np.log2(scales), np.log10(mae) * 20)
  36. plt.title("MAE [dB] vs log2(scale)", fontsize=16, fontweight='bold')
  37. plt.show()
  38.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×