vna-to-tdr.py 711 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python3
  2. import sys
  3. import skrf
  4. import matplotlib.pyplot as plt
  5. skrf.stylely()
  6. if len(sys.argv) != 2:
  7. print("Usage: %s network.s2p" % sys.argv[0], file=sys.stderr)
  8. exit(1)
  9. network = skrf.Network(sys.argv[1])
  10. network_dc = network.extrapolate_to_dc(kind='linear')
  11. plt.figure()
  12. mag = plt.subplot(2, 1, 1)
  13. #mag = plt.subplot(1, 2, 1)
  14. plt.title("Vector Network Analysis")
  15. network_dc.s11.plot_s_db(color='b', label='')
  16. phase = mag.twinx()
  17. network_dc.s11.plot_s_deg(color='r', label='')
  18. plt.subplot(2, 1, 2)
  19. #plt.subplot(1, 2, 2)
  20. plt.title("Time Domain Reflectometry")
  21. network_dc.s11.plot_z_time_step(window='hamming', label="impedance")
  22. plt.xlim((-0.5, 1.5))
  23. plt.tight_layout()
  24. plt.show()