低通值butterworth scipy的问题

时间:2013-09-25 18:19:26

标签: python scipy signal-processing

我用scipy编写了一个低通巴特沃斯滤波器。我有数据,例如像-2,-1,0,1,2,但过滤器将其更改为0,-1,2,1,2。有什么想法来解决它吗?

    def lowPassButterworthDigital(self, signal1 =None, signal2 = None):
        '''
        Digital low-pass Butterworth filter
        '''
        #design filter
        signals = [signal1, signal2]
        for i in range(len(signals)):
            b,a = signal.butter(2, 0.1, "low", False, "ba")

            if i == 0:
               signal1 = signal.lfilter(b, a, signal1)
           else:
               signal2 = signal.lfilter(b, a, signal2)
        return signal1, signal2

1 个答案:

答案 0 :(得分:0)

我成功解决了这个问题。我将lfilter更改为filtfilt

def lowPassButterworthDigital(self, signal1 =None, signal2 = None):
    '''
    Digital low-pass Butterworth filter
    '''
    #design filter
    signals = [signal1, signal2]
    print signal1
    print signal2
    for i in range(len(signals)):
        b,a = signal.butter(2, 0.1, "low", False, "ba")

        if i == 0:
            signal11 = signal.filtfilt(b, a, signal1)
            print signal11
        else:
            signal2 = signal.filtfilt(b, a, signal2)
            print signal2


    return signal11, signal2