Example #1
0
def test_fftfilt_nd():
    np.random.seed(123)
    x = np.random.randn(2**16) + 1j * np.random.randn(2**16)
    b = np.random.randn(128)
    oned = fftfilt.fftfilt(b, x)
    nd = fftfilt.fftfilt_nd(b, x[:, None]).squeeze()
    assert np.allclose(oned, nd)

    x = x.reshape((2**12, 2**4))
    oned = np.zeros_like(x)
    for k in range(16):
        oned[:, k] = fftfilt.fftfilt(b, x[:, k])
    nd = fftfilt.fftfilt_nd(b, x)
    assert np.allclose(oned, nd)
Example #2
0
    def process(self,data,continuation=True, use_fft=True):
        data = data.reshape((data.shape[0]//self.downsample_factor,self.downsample_factor))
        if use_fft:
            result = fftfilt.fftfilt_nd(self.coefficients,data)
        else:
            result = np.empty_like(data)
            for k in range(self.downsample_factor):
                result[:,k] = scipy.signal.lfilter(self.coefficients[:,k],1,data[:,k])
                #result[:,k] = np.convolve(self.coefficients[:,k],data[:,k],mode='same')


        return result.sum(1)