# template file for Lab #6, Task #3 import numpy import matplotlib.pyplot as p import lab6 from lab6_1 import freq_res_usr from lab6_2 import zfreqs_to_usr # return appropriately scaled unit-sample response # for a low-pass filter with specified cutoff frequency def low_pass(cutoff_freq): pass # your code here # return appropriately scaled unit-sample response # for a high-pass filter with specified cutoff frequency def high_pass(cutoff_freq): pass # your code here if __name__ == '__main__': # A low pass filter, cut-off of 0.6pi lp_cutoff = 0.6 * numpy.pi usr_lp = low_pass(lp_cutoff) # Plot the response of the result omega_lp, mag_hejw_lp = freq_res_usr(usr_lp) lab6.plot_freq_response(omega_lp,mag_hejw_lp, 'low-pass filter @ $\Omega=%3.2g$' % lp_cutoff) # Determine the performance ratios for lowpass quality_lp = \ lab6.filter_quality((lp_cutoff+0.1*numpy.pi,numpy.pi), (0,lp_cutoff-0.1*numpy.pi), omega_lp,mag_hejw_lp) print 'quality ratio for low-pass filter=',quality_lp # A high pass filter, cut-off of 0.4pi hp_cutoff = 0.4 * numpy.pi usr_hp = high_pass(hp_cutoff) # Plot the response of the result omega_hp, mag_hejw_hp = freq_res_usr(usr_hp) lab6.plot_freq_response(omega_hp,mag_hejw_hp, 'high-pass filter @ $\Omega=%3.2g$' % hp_cutoff) quality_hp = \ lab6.filter_quality((0,hp_cutoff-0.1*numpy.pi), (hp_cutoff+0.1*numpy.pi,numpy.pi), omega_hp,mag_hejw_hp) print 'quality ratio for high-pass filter=',quality_hp p.show()