Esempio n. 1
0
 def test_filter_lp_hp(self):
     # test 1D time serie: subtracting lp filter removes DC
     ts1 = np.random.rand(500)
     out1 = ft.lp(ts1, 1, [.1, .2])
     self.assertTrue(np.mean(ts1 - out1) < 0.001)
     # test 2D case along the last dimension
     ts = mat.repmat(ts1, 11, 1)
     out = ft.lp(ts, 1, [.1, .2])
     self.assertTrue(np.allclose(out, out1))
     # test 2D case along the first dimension
     ts = mat.repmat(ts1[:, np.newaxis], 1, 11)
     out = ft.lp(ts, 1, [.1, .2], axis=0)
     self.assertTrue(np.allclose(np.transpose(out), out1))
     # test 1D time serie: subtracting lp filter removes DC
     out2 = ft.hp(ts1, 1, [.1, .2])
     self.assertTrue(np.allclose(out1, ts1 - out2))
Esempio n. 2
0
 def test_smooth_lp(self):
     np.random.seed(458)
     a = np.random.rand(500,)
     a_ = smooth.lp(a, [0.1, 0.15])
     res = ft.hp(np.pad(a_, 100, mode='edge'), 1, [0.1, 0.15])[100:-100]
     self.assertTrue((rms(a) / rms(res)) > 500)