Continue to scipy story. When I was looking at the official reference, I found a function for creating a filter, so I immediately experimented. This time, I made a low-pass filter by the remez method and the window function method.
filter.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import scipy as sp
import numpy as np
import matplotlib.pyplot as plt
from scipy import signal
if __name__ == '__main__':
    #Passband is 0 to 0 with 64 taps.25,Blocking area is 0.3〜0.5 filters
    taps = 64;
    edge = [ 0,  0.25 , 0.3, 0.5 ]
    gain = [ 1.0,  0.000 ]
    weight = [ 0.2, 1.0 ]
    remez_impres = sp.signal.remez( taps,  edge, gain )
    remez_freq, remez_fresponse = sp.signal.freqz( remez_impres )
    remez_amp = np.abs( remez_fresponse )
    wf_impres = sp.signal.firwin( taps, 2.0 * edge[1] );
    wf_freq, wf_fresponse = sp.signal.freqz( wf_impres )
    wf_amp = np.abs( wf_fresponse )
    plt.subplot(221)
    plt.semilogy( remez_freq / ( 2 * np.pi ),  remez_amp, 'b-' )
    plt.title( 'Frequency Response( Remez )' )
    plt.subplot(222)
    plt.plot( remez_impres, 'b-' )
    plt.title( 'Impres Response( Remez )' )
    plt.subplot(223)
    plt.semilogy( wf_freq / ( 2 * np.pi ),  wf_amp, 'b-' )
    plt.title( 'Frequency Response( Window )' )
    plt.subplot(224)
    plt.plot( wf_impres, 'b-' )
    plt.title( 'Impres Response( Window )' )
    plt.show()
The window function method was unexpectedly good. It's easy to set parameters, and I think this is better if you want to use it casually.

Recommended Posts