#!/usr/bin/env python # coding: utf-8 #

ScalogramCWT

#
# ## Import # In[4]: import numpy as np import matplotlib.pyplot as plt import spkit print('spkit-version ', spkit.__version__) import spkit as sp from spkit.cwt import ScalogramCWT from spkit.cwt import compare_cwt_example # ## Data # In[7]: x,fs = sp.load_data.eegSample_1ch() t = np.arange(len(x))/fs print('shape ',x.shape, t.shape) plt.figure(figsize=(15,3)) plt.plot(t,x) plt.xlabel('time') plt.ylabel('amplitude') plt.show() # ## Predefined example script # In[8]: compare_cwt_example(x,t,fs=fs) # ## Gauss wavelet # ### Default parameter setting # In[26]: XW,S = ScalogramCWT(x,t,fs=fs,wType='Gauss',PlotPSD=True) # In[27]: XW.shape, S.shape # In[28]: plt.figure(figsize=(15,3)) plt.imshow(np.abs(XW),aspect='auto',origin='lower',cmap='jet',interpolation='sinc') plt.show() # In[36]: plt.figure(figsize=(15,3)) plt.imshow(np.log10(np.abs(XW)+0.2),aspect='auto',origin='lower',cmap='jet',interpolation='sinc') plt.show() # ### with custom setting # In[20]: f0 = np.linspace(0.1,10,100) Q = np.linspace(0.1,5,100) XW,S = ScalogramCWT(x,t,fs=fs,wType='Gauss',PlotPSD=True,f0=f0,Q=Q) # ### Show wavelets in time and frequency domain # In[21]: f0 = np.linspace(0.1,10,100) Q = np.linspace(0.1,5,100) XW,S = ScalogramCWT(x,t,fs=fs,wType='Gauss',PlotPSD=True,PlotW=True,f0=f0,Q=Q) # ## Other wavelets # In[25]: print('Morlet wavelet') XW,S = ScalogramCWT(x,t,fs=fs,wType='Morlet',PlotPSD=True,) print('Gabor wavelet') XW,S = ScalogramCWT(x,t,fs=fs,wType='Gabor',PlotPSD=True,) print('Poisson wavelet') XW,S = ScalogramCWT(x,t,fs=fs,wType='Poisson',PlotPSD=True,) print('Complex Maxican wavelet') XW,S = ScalogramCWT(x,t,fs=fs,wType='cMaxican',PlotPSD=True,) print('Complex Shannon wavelet') XW,S = ScalogramCWT(x,t,fs=fs,wType='cShannon',PlotPSD=True,) # ## Documentation # In[22]: help(ScalogramCWT) # In[ ]: