YZ Smith Chart in Python
1 #!/usr/bin/env python3.5
2
3 import matplotlib.pyplot as plt
4 import numpy as np
5
6 fig, ax = plt.subplots()
7
8 outer_circle = plt.Circle((0, 0), 1.0, facecolor='white', edgecolor='blue')
9
10 zl_i = np.linspace(-500.0, 500.0, 10000)
11 zl_r = np.linspace(0.0, 500.0, 10000)
12
13 for _zl_r in [0.1, 0.5, 1.0, 4.0]:
14 plt.plot(((_zl_r ** 2) + (zl_i ** 2) - 1) / \
15 ((_zl_r ** 2) + (zl_i ** 2) + (2 * _zl_r) + 1), \
16 (2 * zl_i) / ((_zl_r ** 2) + (zl_i ** 2) + (2 * _zl_r) + 1), \
17 color = 'blue')
18
19 for _zl_i in [0.1, 0.5, 1.0, 4.0, -0.1, -0.5, -1.0, -4.0]:
20 plt.plot(((zl_r ** 2) + (_zl_i ** 2) - 1) / \
21 ((zl_r ** 2) + (_zl_i ** 2) + (2 * zl_r) + 1), \
22 (2 * _zl_i) / ((zl_r ** 2) + (_zl_i ** 2) + (2 * zl_r) + 1), \
23 color = 'blue')
24
25 yl_i = np.linspace(-500.0, 500.0, 10000)
26 yl_r = np.linspace(0.0, 500.0, 10000)
27
28 for _yl_r in [0.1, 0.5, 1.0, 4.0]:
29 plt.plot((1 - (_yl_r ** 2.0) - (yl_i ** 2.0)) / \
30 (((1 + _yl_r) ** 2.0) + (yl_i ** 2.0)), \
31 (-2 * yl_i) / (((1 + _yl_r) ** 2.0) + (yl_i ** 2.0)), \
32 color = 'blue')
33
34 for _yl_i in [0.1, 0.5, 1.0, 4.0, -0.1, -0.5, -1.0, -4.0]:
35 plt.plot((1 - (yl_r ** 2.0) - (_yl_i ** 2.0)) / \
36 (((1 + yl_r) ** 2.0) + (_yl_i ** 2.0)), \
37 (-2 * _yl_i) / (((1 + yl_r) ** 2.0) + (_yl_i ** 2.0)), \
38 color = 'blue')
39
40 ax.add_patch(outer_circle)
41
42 plt.xlim([-1, 1])
43 plt.ylim([-1, 1])
44 plt.savefig("sc.png")
Comments
Post a Comment