def test_conversions(self):
     #Converting to other format and back to S-parameters should return the original network
     for test_z0 in (50, 10, 90+10j, 4-100j):
         for test_ntwk in (self.ntwk1, self.ntwk2, self.ntwk3):
             ntwk = rf.Network(s=test_ntwk.s, f=test_ntwk.f, z0=test_z0)
             npy.testing.assert_allclose(rf.a2s(rf.s2a(ntwk.s, test_z0), test_z0), ntwk.s)
             npy.testing.assert_allclose(rf.z2s(rf.s2z(ntwk.s, test_z0), test_z0), ntwk.s)
             npy.testing.assert_allclose(rf.y2s(rf.s2y(ntwk.s, test_z0), test_z0), ntwk.s)
             npy.testing.assert_allclose(rf.h2s(rf.s2h(ntwk.s, test_z0), test_z0), ntwk.s)
             npy.testing.assert_allclose(rf.t2s(rf.s2t(ntwk.s)), ntwk.s)
     npy.testing.assert_allclose(rf.t2s(rf.s2t(self.Fix.s)), self.Fix.s)        
Beispiel #2
0
 def test_conversions(self):
     #Converting to other format and back to S-parameters should return the original network
     s_random = npy.random.uniform(-10, 10, (self.freq.npoints, 2, 2)) + 1j * npy.random.uniform(-10, 10, (self.freq.npoints, 2, 2))
     ntwk_random = rf.Network(s=s_random, frequency=self.freq)
     for test_z0 in (50, 10, 90+10j, 4-100j):
         for test_ntwk in (self.ntwk1, self.ntwk2, self.ntwk3, ntwk_random):
             ntwk = rf.Network(s=test_ntwk.s, f=test_ntwk.f, z0=test_z0)
             npy.testing.assert_allclose(rf.a2s(rf.s2a(ntwk.s, test_z0), test_z0), ntwk.s)
             npy.testing.assert_allclose(rf.z2s(rf.s2z(ntwk.s, test_z0), test_z0), ntwk.s)
             npy.testing.assert_allclose(rf.y2s(rf.s2y(ntwk.s, test_z0), test_z0), ntwk.s)
             npy.testing.assert_allclose(rf.h2s(rf.s2h(ntwk.s, test_z0), test_z0), ntwk.s)
             npy.testing.assert_allclose(rf.t2s(rf.s2t(ntwk.s)), ntwk.s)
     npy.testing.assert_allclose(rf.t2s(rf.s2t(self.Fix.s)), self.Fix.s)
Beispiel #3
0
    def test_conversions(self):
        #Converting to other format and back to S-parameters should return the original network
        tinyfloat = 1e-11
        for test_z0 in (50, 10, 90 + 10j, 4 - 100j):
            for test_ntwk in (self.ntwk1, self.ntwk2, self.ntwk3):
                ntwk = rf.Network(s=test_ntwk.s, f=test_ntwk.f, z0=test_z0)

                self.assertTrue(
                    (abs(rf.a2s(rf.s2a(ntwk.s, test_z0), test_z0) - ntwk.s) <
                     tinyfloat).all())
                self.assertTrue(
                    (abs(rf.z2s(rf.s2z(ntwk.s, test_z0), test_z0) - ntwk.s) <
                     tinyfloat).all())
                self.assertTrue(
                    (abs(rf.y2s(rf.s2y(ntwk.s, test_z0), test_z0) - ntwk.s) <
                     tinyfloat).all())
                self.assertTrue(
                    (abs(rf.h2s(rf.s2h(ntwk.s, test_z0), test_z0) - ntwk.s) <
                     tinyfloat).all())
                self.assertTrue(
                    (abs(rf.t2s(rf.s2t(ntwk.s)) - ntwk.s) < tinyfloat).all())
        self.assertTrue(
            (abs(rf.t2s(rf.s2t(self.Fix.s)) - self.Fix.s) < tinyfloat).all())