def get_freq_response(a, b, show_fig=True, SampleFreq=(2 * pi), NumOfFreqs=500, whole=False):
    """
    This function takes an array of coefficients and finds the frequency
    response of the filter using scipy.signal.freqz.
    show_fig sets if the response should be plotted

    Parameters
    ----------
    b : array_like
        Coefficients multiplying the x values (inputs of the filter)

    a : array_like
        Coefficients multiplying the y values (outputs of the filter)
    show_fig : bool, optional
        Verbosity of function (i.e. whether to plot frequency and phase
        response or whether to just return the values.)
        Options (Default is 1):
        False - Do not plot anything, just return values
        True - Plot Frequency and Phase response and return values
    SampleFreq : float, optional
        Sample frequency (in Hz) to simulate (used to convert frequency range
        to normalised frequency range)
    NumOfFreqs : int, optional
        Number of frequencies to use to simulate the frequency and phase
        response of the filter. Default is 500.
    Whole : bool, optional
        Sets whether to plot the whole response (0 to sample freq)
        or just to plot 0 to Nyquist (SampleFreq/2): 
        False - (default) plot 0 to Nyquist (SampleFreq/2)
        True - plot the whole response (0 to sample freq)

    Returns
    -------
    freqList : ndarray
        Array containing the frequencies at which the gain is calculated
    GainArray : ndarray
        Array containing the gain in dB of the filter when simulated
        (20*log_10(A_out/A_in))
    PhaseDiffArray : ndarray
        Array containing the phase response of the filter - phase
        difference between the input signal and output signal at
        different frequencies
    """
    w, h = scipy.signal.freqz(b=b, a=a, worN=NumOfFreqs, whole=whole)
    freqList = w / (pi) * SampleFreq / 2.0
    himag = _np.array([hi.imag for hi in h])
    GainArray = 20 * _np.log10(_np.abs(h))
    PhaseDiffArray = _np.unwrap(_np.arctan2(_np.imag(h), _np.real(h)))

    fig1 = _plt.figure()
    ax1 = fig1.add_subplot(111)
    ax1.plot(freqList, GainArray, '-', label="Specified Filter")
    ax1.set_title("Frequency Response")
    if SampleFreq == 2 * pi:
        ax1.set_xlabel(("$\Omega$ - Normalized frequency "
                       "($\pi$=Nyquist Frequency)"))
    else:
        ax1.set_xlabel("frequency (Hz)")
    ax1.set_ylabel("Gain (dB)")
    ax1.set_xlim([0, SampleFreq / 2.0])
    if show_fig == True:
        _plt.show()
    fig2 = _plt.figure()
    ax2 = fig2.add_subplot(111)
    ax2.plot(freqList, PhaseDiffArray, '-', label="Specified Filter")
    ax2.set_title("Phase Response")
    if SampleFreq == 2 * pi:
        ax2.set_xlabel(("$\Omega$ - Normalized frequency "
                       "($\pi$=Nyquist Frequency)"))
    else:
        ax2.set_xlabel("frequency (Hz)")

    ax2.set_ylabel("Phase Difference")
    ax2.set_xlim([0, SampleFreq / 2.0])
    if show_fig == True:
        _plt.show()
    return freqList, GainArray, PhaseDiffArray, fig1, ax1, fig2, ax2
def get_freq_response ( a , b , show_fig = True , SampleFreq = ( 2 * pi ) , NumOfFreqs = 500 , whole = False ) : w , h = scipy . signal . freqz ( b = b , a = a , worN = NumOfFreqs , whole = whole ) freqList = w / ( pi ) * SampleFreq / 2.0 himag = _np . array ( [ hi . imag for hi in h ] ) GainArray = 20 * _np . log10 ( _np . abs ( h ) ) PhaseDiffArray = _np . unwrap ( _np . arctan2 ( _np . imag ( h ) , _np . real ( h ) ) ) fig1 = _plt . figure ( ) ax1 = fig1 . add_subplot ( 111 ) ax1 . plot ( freqList , GainArray , '-' , label = "Specified Filter" ) ax1 . set_title ( "Frequency Response" ) if SampleFreq == 2 * pi : ax1 . set_xlabel ( ( "$\Omega$ - Normalized frequency " "($\pi$=Nyquist Frequency)" ) ) else : ax1 . set_xlabel ( "frequency (Hz)" ) ax1 . set_ylabel ( "Gain (dB)" ) ax1 . set_xlim ( [ 0 , SampleFreq / 2.0 ] ) if show_fig == True : _plt . show ( ) fig2 = _plt . figure ( ) ax2 = fig2 . add_subplot ( 111 ) ax2 . plot ( freqList , PhaseDiffArray , '-' , label = "Specified Filter" ) ax2 . set_title ( "Phase Response" ) if SampleFreq == 2 * pi : ax2 . set_xlabel ( ( "$\Omega$ - Normalized frequency " "($\pi$=Nyquist Frequency)" ) ) else : ax2 . set_xlabel ( "frequency (Hz)" ) ax2 . set_ylabel ( "Phase Difference" ) ax2 . set_xlim ( [ 0 , SampleFreq / 2.0 ] ) if show_fig == True : _plt . show ( ) return freqList , GainArray , PhaseDiffArray , fig1 , ax1 , fig2 , ax2
This function takes an array of coefficients and finds the frequency
    response of the filter using scipy.signal.freqz.
    show_fig sets if the response should be plotted

    Parameters
    ----------
    b : array_like
        Coefficients multiplying the x values (inputs of the filter)

    a : array_like
        Coefficients multiplying the y values (outputs of the filter)
    show_fig : bool, optional
        Verbosity of function (i.e. whether to plot frequency and phase
        response or whether to just return the values.)
        Options (Default is 1):
        False - Do not plot anything, just return values
        True - Plot Frequency and Phase response and return values
    SampleFreq : float, optional
        Sample frequency (in Hz) to simulate (used to convert frequency range
        to normalised frequency range)
    NumOfFreqs : int, optional
        Number of frequencies to use to simulate the frequency and phase
        response of the filter. Default is 500.
    Whole : bool, optional
        Sets whether to plot the whole response (0 to sample freq)
        or just to plot 0 to Nyquist (SampleFreq/2): 
        False - (default) plot 0 to Nyquist (SampleFreq/2)
        True - plot the whole response (0 to sample freq)

    Returns
    -------
    freqList : ndarray
        Array containing the frequencies at which the gain is calculated
    GainArray : ndarray
        Array containing the gain in dB of the filter when simulated
        (20*log_10(A_out/A_in))
    PhaseDiffArray : ndarray
        Array containing the phase response of the filter - phase
        difference between the input signal and output signal at
        different frequencies