Add test for touchstone RI -> db/deg conversion
@@ -71,6 +71,8 @@ class TouchstoneTestCase(unittest.TestCase):
# 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:
@@ -92,6 +94,22 @@ class TouchstoneTestCase(unittest.TestCase):
'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)
@@ -99,6 +117,13 @@ class TouchstoneTestCase(unittest.TestCase):
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])) )
+
def test_HFSS_touchstone_files(self):
"""
