Пример #1
0
    def test_get_sparameter_data(self):
        '''
        This tests the get_sparameter_data function.

        '''
        with open(os.path.join(self.test_dir, 'simple_touchstone.s2p')) as fid:
            touch = Touchstone(fid)

        expected_keys = [
            "frequency",
            "S11R",
            "S11I",
            "S12R",
            "S12I",
            "S21R",
            "S21I",
            "S22R",
            "S22I",
        ]

        unexpected_keys = [
            'S11DB',
            'S11M',
        ]

        # get dict data structure
        sp_ri = touch.get_sparameter_data(format="ri")

        # test data structure
        for ek in expected_keys:
            self.assertTrue(ek in sp_ri)

        for uk in unexpected_keys:
            self.assertFalse(uk in sp_ri)

        # test data contents
        expected_sp_ri = {
            'frequency': npy.array([1.0e+09, 1.1e+09]),
            'S11R': npy.array([1., 9.]),
            'S11I': npy.array([2., 10.]),
            'S21R': npy.array([3., 11.]),
            'S21I': npy.array([4., 12.]),
            'S12R': npy.array([5., 13.]),
            'S12I': npy.array([6., 14.]),
            'S22R': npy.array([7., 15.]),
            'S22I': npy.array([8., 16.]),
        }

        for k in sp_ri:
            self.assertTrue(k in expected_sp_ri)

            self.assertTrue(
                (expected_sp_ri[k] == sp_ri[k]).all(),
                msg='Field %s does not match. Expected "%s", got "%s"' %
                (k, str(expected_sp_ri[k]), str(sp_ri[k])))
Пример #2
0
    def test_get_sparameter_data(self):
        '''
        This tests the get_sparameter_data function.

        '''
        with open(os.path.join(self.test_dir, 'simple_touchstone.s2p')) as fid:
            touch = Touchstone(fid)

        spardict = touch.get_sparameter_data(format="ri")
        self.assertTrue("frequency" in spardict)
        self.assertTrue("S11R" in spardict)
        self.assertTrue("S11I" in spardict)
        self.assertTrue("S12R" in spardict)
        self.assertTrue("S12I" in spardict)
        self.assertTrue("S21R" in spardict)
        self.assertTrue("S21I" in spardict)
        self.assertTrue("S22R" in spardict)
        self.assertTrue("S22I" in spardict)
        self.assertTrue("S11DB" not in spardict)
        self.assertTrue("S11M" not in spardict)
Пример #3
0
    def test_get_sparameter_data(self):
        '''
        This tests the get_sparameter_data function.

        '''
        with open(os.path.join(self.test_dir, 'simple_touchstone.s2p')) as fid:
            touch = Touchstone(fid)

        spardict = touch.get_sparameter_data(format="ri")
        self.assertTrue("frequency" in spardict)
        self.assertTrue("S11R" in spardict)
        self.assertTrue("S11I" in spardict)
        self.assertTrue("S12R" in spardict)
        self.assertTrue("S12I" in spardict)
        self.assertTrue("S21R" in spardict)
        self.assertTrue("S21I" in spardict)
        self.assertTrue("S22R" in spardict)
        self.assertTrue("S22I" in spardict)
        self.assertTrue("S11DB" not in spardict)
        self.assertTrue("S11M" not in spardict)
Пример #4
0
    def test_get_sparameter_data(self):
        """
        This tests the get_sparameter_data function.

        """
        with open(os.path.join(self.test_dir, 'simple_touchstone.s2p')) as fid:
            touch = Touchstone(fid)

        expected_keys = ["frequency", "S11R", "S11I", "S12R", "S12I",
                "S21R", "S21I", "S22R", "S22I", ]

        unexpected_keys = ['S11DB', 'S11M', ]

        # get dict data structure
        sp_ri = touch.get_sparameter_data(format="ri")
        # Get dict data in db to check ri -> db/angle conversion
        sp_db = touch.get_sparameter_data(format="db")

        # test data structure
        for ek in expected_keys:
            self.assertTrue(ek in sp_ri)

        for uk in unexpected_keys:
            self.assertFalse(uk in sp_ri)

        # test data contents
        expected_sp_ri = {
            'frequency': npy.array([1.0e+09, 1.1e+09]),
            'S11R': npy.array([1., 9.]),
            'S11I': npy.array([ 2., 10.]),
            'S21R': npy.array([ 3., 11.]),
            'S21I': npy.array([ 4., 12.]),
            'S12R': npy.array([ 5., 13.]),
            'S12I': npy.array([ 6., 14.]),
            'S22R': npy.array([ 7., 15.]),
            'S22I': npy.array([ 8., 16.]),
        }

        S11 = npy.array([1., 9.]) + 1j*npy.array([ 2., 10.])
        S21 = npy.array([ 3., 11.]) + 1j*npy.array([ 4., 12.])
        S12 = npy.array([ 5., 13.]) + 1j*npy.array([ 6., 14.])
        S22 = npy.array([ 7., 15.]) + 1j*npy.array([ 8., 16.])
        expected_sp_db = {
            'frequency': npy.array([1.0e+09, 1.1e+09]),
            'S11DB': 20*npy.log10(npy.abs(S11)),
            'S11A': npy.angle(S11, deg=True),
            'S21DB': 20*npy.log10(npy.abs(S21)),
            'S21A': npy.angle(S21, deg=True),
            'S12DB': 20*npy.log10(npy.abs(S12)),
            'S12A': npy.angle(S12, deg=True),
            'S22DB': 20*npy.log10(npy.abs(S22)),
            'S22A': npy.angle(S22, deg=True),
        }

        for k in sp_ri:
            self.assertTrue(k in expected_sp_ri)

            self.assertTrue( (expected_sp_ri[k] == sp_ri[k]).all(),
                    msg='Field %s does not match. Expected "%s", got "%s"'%(
                        k, str(expected_sp_ri[k]), str(sp_ri[k]))  )

        for k in sp_db:
            self.assertTrue(k in expected_sp_db)

            self.assertTrue( (expected_sp_db[k] == sp_db[k]).all(),
                    msg='Field %s does not match. Expected "%s", got "%s"'%(
                        k, str(expected_sp_db[k]), str(sp_db[k]))  )