def test_synthesizeChebyshevNTF_1(self):
     """Test function for synthesizeChebyshevNTF() 1/3"""
     z, p, k = ds.synthesizeChebyshevNTF()
     zref = [1., .9991 + 0.0425j, .9991 - 0.0425j]
     pref = [.6609, .7686 + .2858j, .7686 - .2858j]
     kref = 1.
     self.assertTrue(np.allclose(cplxpair(z), cplxpair(zref), atol=1e-4, rtol=1e-4))
     self.assertTrue(np.allclose(cplxpair(p), cplxpair(pref), atol=1e-4, rtol=1e-4))
     self.assertTrue(np.allclose(k, kref, atol=1e-4, rtol=1e-4))
Exemplo n.º 2
0
 def test_synthesizeNTF0_5(self):
     """Test function for synthesizeNTF0() 5/8"""
     z, p, k = synthesizeNTF0(order=3, osr=64, opt=2, H_inf=1.5, f0=0.0)
     zref = [1.0000 + 0.0000j, 0.9993 + 0.0380j, 0.9993 - 0.0380j]
     pref = [0.7652 - 0.2795j, 0.7652 + 0.2795j, 0.6692 + 0.0000j]
     kref = 1.
     self.assertTrue(np.allclose(cplxpair(z), cplxpair(zref), atol=1e-4,
                                 rtol=1e-4))
     self.assertTrue(np.allclose(cplxpair(p), cplxpair(pref), atol=1e-4,
                                 rtol=1e-4))
     self.assertTrue(np.allclose(k, kref, atol=1e-4, rtol=1e-4))
Exemplo n.º 3
0
 def test_synthesizeNTF0_1(self):
     """Test function for synthesizeNTF0() 1/8"""
     z, p, k = synthesizeNTF0(order=3, osr=64, opt=0, H_inf=1.5, f0=0.0)
     zref = [1., 1., 1.]
     pref = [.6694, .7654 + .2793j, .7654 - .2793j]
     kref = 1.
     self.assertTrue(np.allclose(cplxpair(z), cplxpair(zref), atol=1e-4,
                                 rtol=1e-4))
     self.assertTrue(np.allclose(cplxpair(p), cplxpair(pref), atol=1e-4,
                                 rtol=1e-4))
     self.assertTrue(np.allclose(k, kref, atol=1e-4, rtol=1e-4))
 def test_synthesizeChebyshevNTF_2(self):
     """Test function for synthesizeChebyshevNTF() 2/3"""
     with catch_warnings(record=True) as w:
         z, p, k = ds.synthesizeChebyshevNTF(order=4, OSR=32, opt=1, H_inf=1.5, f0=.33)
         self.assertTrue(len(w) > 0)
     zref = [-.4513 + .8924j, -.4513 - .8924j, -.5122 + 0.8589j, -.5122 - 0.8589j]
     pref = [-.2249 + .7665j, -.2249 - .7665j, -.5506 + .6314j, -.5506 - .6314j]
     kref = 1.
     self.assertTrue(np.allclose(cplxpair(z), cplxpair(zref), atol=1e-4, rtol=1e-4))
     self.assertTrue(np.allclose(cplxpair(p), cplxpair(pref), atol=1e-4, rtol=1e-4))
     self.assertTrue(np.allclose(k, kref, atol=1e-4, rtol=1e-4))
Exemplo n.º 5
0
 def test_synthesizeChebyshevNTF_1(self):
     """Test function for synthesizeChebyshevNTF() 1/3"""
     z, p, k = ds.synthesizeChebyshevNTF()
     zref = [1., .9991 + 0.0425j, .9991 - 0.0425j]
     pref = [.6609, .7686 + .2858j, .7686 - .2858j]
     kref = 1.
     self.assertTrue(
         np.allclose(cplxpair(z), cplxpair(zref), atol=1e-4, rtol=1e-4))
     self.assertTrue(
         np.allclose(cplxpair(p), cplxpair(pref), atol=1e-4, rtol=1e-4))
     self.assertTrue(np.allclose(k, kref, atol=1e-4, rtol=1e-4))
Exemplo n.º 6
0
 def test_synthesizeNTF0_6(self):
     """Test function for synthesizeNTF0() 6/8"""
     z, p, k = synthesizeNTF0(order=4, osr=32, opt=2, H_inf=1.3, f0=.33)
     zref = [-0.4818 + 0.8763j, -0.4818 - 0.8763j, -0.4818 + 0.8763j,
             -0.4818 - 0.8763j]
     pref = [-0.5125 - 0.7018j, -0.5125 + 0.7018j, -0.3233 - 0.8240j,
             -0.3233 + 0.8240j]
     kref = 1.
     self.assertTrue(np.allclose(cplxpair(z), cplxpair(zref), atol=1e-4,
                                 rtol=1e-4))
     self.assertTrue(np.allclose(cplxpair(p), cplxpair(pref), atol=1e-4,
                                 rtol=1e-4))
     self.assertTrue(np.allclose(k, kref, atol=1e-4, rtol=1e-4))
Exemplo n.º 7
0
 def test_synthesizeNTF0_4(self):
     """Test function for synthesizeNTF0() 4/8"""
     # bandpass test
     z, p, k = synthesizeNTF0(order=4, osr=32, opt=1, H_inf=1.3, f0=.33)
     zref = [-0.4567 + 0.8896j, -0.4567 - 0.8896j, -0.5064 + 0.8623j,
             -0.5064 - 0.8623j]
     pref = [-0.5125 - 0.7014j, -0.5125 + 0.7014j, -0.3230 - 0.8239j,
             -0.3230 + 0.8239j]
     kref = 1.
     self.assertTrue(np.allclose(cplxpair(z), cplxpair(zref), atol=1e-4,
                                 rtol=1e-4))
     self.assertTrue(np.allclose(cplxpair(p), cplxpair(pref), atol=1e-4,
                                 rtol=1e-4))
     self.assertTrue(np.allclose(k, kref, atol=1e-4, rtol=1e-4))
Exemplo n.º 8
0
 def test_synthesizeNTF0_8(self):
     """Test function for synthesizeNTF0() 8/8"""
     opt = 1
     z, p, k = synthesizeNTF0(order=4, osr=32, opt=opt, H_inf=1.3, f0=0.2)
     pref = [0.3742 - 0.7875j, 0.3742 + 0.7875j, 0.1616 - 0.8666j,
             0.1616 + 0.8666j]
     zref = [0.3358 - 0.9419j, 0.3358 + 0.9419j, 0.2819 - 0.9594j,
             0.2819 + 0.9594j]
     kref = 1.
     self.assertTrue(np.allclose(cplxpair(z), cplxpair(zref), atol=1e-4,
                                 rtol=1e-3))
     self.assertTrue(np.allclose(cplxpair(p), cplxpair(pref), atol=1e-4,
                                 rtol=1e-3))
     self.assertTrue(np.allclose(k, kref, atol=1e-4, rtol=1e-4))
Exemplo n.º 9
0
    def setUp(self):
        ABCD = [[1.0, 0.0, 0.0, 0.044408783846879, -0.044408783846879],
                [
                    0.999036450096481, 0.997109907515262, -0.005777399147297,
                    0.0, 0.499759089304780
                ],
                [
                    0.499759089304780, 0.999036450096481, 0.997109907515262,
                    0.0, -0.260002096136488
                ], [0.0, 0.0, 1.0, 0.0, 0.0]]
        ABCD = np.array(ABCD)
        ntf, stf = ds.calculateTF(ABCD)
        ntf_zeros, ntf_poles, _ = ntf
        stf_zeros, stf_poles, _ = stf
        mntf_poles = np.array(
            (1.498975311463384, 1.102565142679772, 0.132677264750882))
        mntf_zeros = np.array((0.997109907515262 + 0.075972576202904j,
                               0.997109907515262 - 0.075972576202904j,
                               1.000000000000000 + 0.000000000000000j))
        mstf_zeros = np.array((-0.999999999999996, ))
        mstf_poles = np.array(
            (1.498975311463384, 1.102565142679772, 0.132677264750882))

        # for some reason, sometimes the zeros are in different order.
        self.ntf_zeros, self.mntf_zeros = (cplxpair(ntf_zeros),
                                           cplxpair(mntf_zeros))
        self.stf_zeros, self.mstf_zeros = (cplxpair(stf_zeros),
                                           cplxpair(mstf_zeros))
        self.ntf_poles, self.mntf_poles = (cplxpair(ntf_poles),
                                           cplxpair(mntf_poles))
        self.stf_poles, self.mstf_poles = (cplxpair(stf_poles),
                                           cplxpair(mstf_poles))
    def setUp(self):
        ABCD = [[1.0, 0.0, 0.0, 0.044408783846879, -0.044408783846879],
                [0.999036450096481, 0.997109907515262, -0.005777399147297,
                 0.0, 0.499759089304780],
                [0.499759089304780, 0.999036450096481, 0.997109907515262,
                 0.0, -0.260002096136488],
                [0.0, 0.0, 1.0,  0.0, 0.0]]
        ABCD = np.array(ABCD)
        ntf, stf = ds.calculateTF(ABCD)
        ntf_zeros, ntf_poles, _ = ntf
        stf_zeros, stf_poles, _ = stf
        mntf_poles = np.array((1.498975311463384, 1.102565142679772,
                               0.132677264750882))
        mntf_zeros = np.array((0.997109907515262 + 0.075972576202904j,
                               0.997109907515262 - 0.075972576202904j,
                               1.000000000000000 + 0.000000000000000j))
        mstf_zeros = np.array((-0.999999999999996,))
        mstf_poles = np.array((1.498975311463384, 1.102565142679772,
                               0.132677264750882))

        # for some reason, sometimes the zeros are in different order.
        self.ntf_zeros, self.mntf_zeros = (cplxpair(ntf_zeros),
                                           cplxpair(mntf_zeros))
        self.stf_zeros, self.mstf_zeros = (cplxpair(stf_zeros),
                                           cplxpair(mstf_zeros))
        self.ntf_poles, self.mntf_poles = (cplxpair(ntf_poles),
                                           cplxpair(mntf_poles))
        self.stf_poles, self.mstf_poles = (cplxpair(stf_poles),
                                           cplxpair(mstf_poles))
Exemplo n.º 11
0
 def test_synthesizeNTF0_7(self):
     """Test function for synthesizeNTF0() 7/8"""
     # zeros passed explicitly
     opt = [1.0000 + 0.0000j, 0.9986 + 0.06j, 0.9986 - 0.06j,
             0.9960 + 0.0892j, 0.9960 - 0.0892j]
     z, p, k = synthesizeNTF0(order=5, osr=32, opt=opt, H_inf=1.3, f0=0.0)
     zref = [1.0000 + 0.0000j, 0.9986 + 0.06j, 0.9986 - 0.06j,
             0.9960 + 0.0892j, 0.9960 - 0.0892j]
     pref = [0.8718 - 0.0840j, 0.8718 + 0.0840j, 0.9390 - 0.1475j,
             0.9390 + 0.1475j, 0.8491 + 0.0000j]
     kref = 1.
     self.assertTrue(np.allclose(cplxpair(z), cplxpair(zref), atol=1e-4,
                                 rtol=1e-3))
     self.assertTrue(np.allclose(cplxpair(p), cplxpair(pref), atol=1e-4,
                                 rtol=1e-3))
     self.assertTrue(np.allclose(k, kref, atol=1e-4, rtol=1e-4))
Exemplo n.º 12
0
 def test_synthesizeChebyshevNTF_2(self):
     """Test function for synthesizeChebyshevNTF() 2/3"""
     with catch_warnings(record=True) as w:
         z, p, k = ds.synthesizeChebyshevNTF(order=4,
                                             OSR=32,
                                             opt=1,
                                             H_inf=1.5,
                                             f0=.33)
         self.assertTrue(len(w) > 0)
     zref = [
         -.4513 + .8924j, -.4513 - .8924j, -.5122 + 0.8589j,
         -.5122 - 0.8589j
     ]
     pref = [
         -.2249 + .7665j, -.2249 - .7665j, -.5506 + .6314j, -.5506 - .6314j
     ]
     kref = 1.
     self.assertTrue(
         np.allclose(cplxpair(z), cplxpair(zref), atol=1e-4, rtol=1e-4))
     self.assertTrue(
         np.allclose(cplxpair(p), cplxpair(pref), atol=1e-4, rtol=1e-4))
     self.assertTrue(np.allclose(k, kref, atol=1e-4, rtol=1e-4))