In [1]:
%pylab inline
import sys,os
import numpy as np
import scipy.signal as ss
import scipy.misc as sm
sys.path.insert(0, os.path.join(sys.path[0], '..'))
import extlib as xl
In [2]:
help(xl.hilbert_kernel)
In [13]:
N = 40
Np = 2*N+1
kernel = xl.hilbert_kernel(N,0.9)
matplotlib.rcParams.update({'font.size': 18})
fig,axes = plt.subplots( 1,2, figsize=(16,6) )
axes[0].plot(np.linspace(-N,N,Np), np.real(kernel))
axes[0].set_xlabel('Sample')
axes[0].set_ylabel('Amplitude')
axes[0].set_title('Real Impulse Response')
axes[1].plot(np.linspace(-N,N,Np), np.imag(kernel))
axes[1].set_xlabel('Sample')
axes[1].set_ylabel('Amplitude')
axes[1].set_title('Imaginary Impulse Response')
fig.tight_layout()
In [14]:
Om, Hi = ss.freqz(np.imag(kernel),whole=True)
Om, Hr = ss.freqz(np.real(kernel),whole=True)
Hf = Hi/Hr
Om = (Om/np.pi-1)*-1
fig,axes = plt.subplots( 1,2, figsize=(16,6) )
axes[0].plot(Om, np.abs(Hf))
axes[0].set_xlabel('Normalised Frequency')
axes[0].set_ylabel('Amplitude')
axes[0].set_title('Amplitude Response')
axes[1].plot(Om, np.angle(Hf))
axes[1].set_xlabel('Normalised Frequency')
axes[1].set_ylabel('Radians')
axes[1].set_title('Phase Response')
fig.tight_layout()
In [ ]:
In [ ]: