spkit.cwt.GaborWave

spkit.cwt.GaborWave(t, f=1, f0=1, a=0.1, t0=0)

Gabor Wavelet

The Gabor Wavelet function (technically same as Gaussian)

\[ \begin{align}\begin{aligned}\psi(t) &= e^{-(t-t_0)^2/a^2}e^{-jf_0(t-t_0)}\\\psi(f) &= e^{-((f-f_0)a)^2}e^{-jt_0(f-f_0)}\end{aligned}\end{align} \]

where

  • a = Oscilation Rate

  • f0 = center Frequenct

Parameters:
t: 1d array,
  • time span array corresponding to signal for analysis,

  • must be centered at 0

f: 1d array,
  • frquency array for wavelet analysis

f0: array, default=1
  • array of center frquencies for wavelets,

  • np.linspace(0.1,10,100) [scale value]

a: float or array, default=0.1
  • array of oscillasion rate for each wavelet, e.g. 0.5 or np.linspace(0.1,5,100)

  • if array, should be of same size as f0

t0: float, default=0,
  • time shift of wavelet, or phase shift in frquency, Not suggeestive to change

Returns:
wttime-domain wavelet(s)
wffrequency-domain wavelet(s)

See also

ScalogramCWT

Notes

It is efficient and easy to use ScalogramCWT with wType==’Gabor’

code::

XW,S = ScalogramCWT(x,t,fs=fs,wType=’Gabor’,PlotPSD=True)

References

Examples

#sp.cwt.GaborWave
import numpy as np
import matplotlib.pyplot as plt
import spkit as sp
fs = 100                              #sampling frequency
t = np.linspace(-5,5,fs*10+1)         #time
#f = np.linspace(-10,10,2*len(t)-1)    #frequency range
f = np.linspace(-fs//2,fs//2,2*len(t))   #frequency range
f0 = np.linspace(1,40,10)[:,None]
a1  = 0.5
a2  = 2
wt1,wf1 = sp.cwt.GaborWave(t,f,f0=f0,a=a1,t0=0)
wt2,wf2 = sp.cwt.GaborWave(t,f,f0=f0,a=a2,t0=0)
plt.figure(figsize=(10,5))
plt.subplot(221)
plt.plot(t,wt1.T.real,label='real')
plt.plot(t,wt1.T.imag,'-',label='image')
plt.xlim(t[0],t[-1])
plt.ylabel(f'a={a1}')
plt.subplot(222)
plt.plot(f,abs(wf1.T))
plt.xlim(f[0],f[-1])
plt.subplot(223)
plt.plot(t,wt2.T.real,label='real')
plt.plot(t,wt2.T.imag,'-',label='image')
plt.xlim(t[0],t[-1])
plt.xlabel('time')
plt.ylabel(f'a={a2}')
plt.subplot(224)
plt.plot(f,abs(wf2.T))
plt.xlim(f[0],f[-1])
plt.xlabel('Frequency')
plt.suptitle('Gabor Wavelet')
plt.tight_layout()
plt.show()
../../_images/spkit-cwt-GaborWave-1.png