示例#1
0
 def test_freqz_3(self):
     # Testcase for return real form
     fil = FIRDesign.fir1(self.order, self.cut)
     w1, h1 = FilterSpec.freqz(fil, outform='abs')
     w2, h2 = signal.freqz(fil[0], fil[1], worN=512, fs=2*np.pi)
     h2 = np.abs(h2)
     self.assertTrue(np.all(w1 == w2) and np.all(h1 == h2))
示例#2
0
 def test_phasez_1(self):
     # Testcase for return radian form
     fil = FIRDesign.fir1(self.order, self.cut)
     w, h = signal.freqz(fil[0], fil[1], worN=512, fs=2 * np.pi)
     phase = sp.unwrap(sp.angle(h))
     ww, pp = FilterSpec.phasez(fil)
     self.assertTrue(np.all(w == ww) and np.all(pp == phase))
示例#3
0
 def test_grpdelay_1(self):
     # Test case for FIR filter
     fil = FIRDesign.fir1(self.order, self.cut)
     w, gd = signal.group_delay(fil, w=512, fs=2 * np.pi)
     gd = np.round(gd)
     ww, gdgd = FilterSpec.grpdelay(fil)
     self.assertTrue(np.all(w == ww) and np.all(gd == gdgd))
示例#4
0
 def test_impz_4(self):
     # Test case for IIR filter with n
     fil = IIRDesign.butter(6, self.fc / (self.fs / 2))
     dl = signal.dlti(fil[0], fil[1], dt=1 / self.fs)
     i_d = signal.dimpulse(dl, n=self.n)
     T = i_d[0]
     yout = i_d[1][0]
     tt, y = FilterSpec.impz(fil, n=self.n, fs=self.fs)
     self.assertTrue(np.all(tt == T) and np.all(y == yout))
示例#5
0
 def test_impz_2(self):
     # Test case for FIR filter with n
     fil = FIRDesign.fir1(self.order, self.cut)
     T = np.arange(0, self.n, 1)
     x = np.zeros(len(T))
     x[0] = 1
     yout = signal.lfilter(fil[0], fil[1], x)
     tt, y = FilterSpec.impz(fil, n=self.n)
     self.assertTrue(np.all(tt == T) and np.all(y == yout))
示例#6
0
 def test_freqz_5(self):
     # Test case for exception
     with self.assertRaises(ValueError):
         fil = FIRDesign.fir1(self.order, self.cut)
         FilterSpec.freqz(fil, outform='x')
示例#7
0
 def test_freqz_4(self):
     # Testcase for IIR filter
     fil = IIRDesign.butter(6, self.fc/(self.fs/2))
     w1, h1 = FilterSpec.freqz(fil)
     w2, h2 = signal.freqz(fil[0], fil[1], worN=512, fs=2*np.pi)
     self.assertTrue(np.all(w1 == w2) and np.all(h1 == h2))
示例#8
0
 def test_freqz_1(self):
     # Testcase for return complex form
     fil = FIRDesign.fir1(self.order, self.cut)
     w1, h1 = FilterSpec.freqz(fil)
     w2, h2 = signal.freqz(fil[0], fil[1], worN=512, fs=2*np.pi)
     self.assertTrue(np.all(w1 == w2) and np.all(h1 == h2))
示例#9
0
 def test_isminphase_2(self):
     # Test case
     fil = IIRDesign.butter(self.n, self.fc)
     self.assertTrue(FilterSpec.isminphase(fil) == False)
示例#10
0
 def test_isminphase_1(self):
     # Test case
     fil = FIRDesign.fir1(self.order, self.cut)
     self.assertTrue(FilterSpec.isminphase(fil) == False)
示例#11
0
 def test_grpdelay_2(self):
     # Test case for IIR filter
     fil = IIRDesign.butter(6, self.fc / (self.fs / 2))
     w, gd = FilterSpec.grpdelay(fil)
     ww, gdgd = signal.group_delay(fil, w=512, fs=2 * np.pi)
     self.assertTrue(np.all(w == ww) and np.all(gd == gdgd))
示例#12
0
 def test_isstable_2(self):
     # Test case for IIR filter
     fil = IIRDesign.butter(self.n, self.fc)
     self.assertTrue(FilterSpec.isstable(fil) == True)
示例#13
0
 def test_isstable_1(self):
     # Test case for FIR filter
     fil = FIRDesign.fir1(self.order, self.cut)
     self.assertTrue(FilterSpec.isstable(fil) == True)
示例#14
0
 def test_impz_1(self):
     # Test case for FIR filter without n
     fil = FIRDesign.fir1(self.order, self.cut)
     _, yout = FilterSpec.impz(fil)
     self.assertTrue(np.all(yout == fil[0]))