| 1 |
|
| 2 |
import optparse |
| 3 |
|
| 4 |
import pylab as plb |
| 5 |
|
| 6 |
try: |
| 7 |
import skrf as rf |
| 8 |
except (ImportError): |
| 9 |
print('IMPORT ERROR: skrf is not installed correctly. Check you path.') |
| 10 |
|
| 11 |
|
| 12 |
def main(): |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
parser = optparse.OptionParser(\ |
| 17 |
usage='plot_touchstone.py [options] file.s2p [file1.s2p]',\ |
| 18 |
description='Plots contents of a touchstone file.') |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
parser.add_option('-m',default=None, metavar='M',type=int,\ |
| 24 |
help='first index of s-parameter to plot' ) |
| 25 |
parser.add_option('-n',default=None, metavar='N',type=int,\ |
| 26 |
help='second index of s-parameter to plot' ) |
| 27 |
(options, args) = parser.parse_args() |
| 28 |
|
| 29 |
if options.m is not None: |
| 30 |
options.m -=1 |
| 31 |
if options.n is not None: |
| 32 |
options.n -=1 |
| 33 |
|
| 34 |
plb.figure(figsize=(8,6)) |
| 35 |
ax_1 = plb.subplot(221) |
| 36 |
ax_2 = plb.subplot(222) |
| 37 |
ax_3 = plb.subplot(223) |
| 38 |
ax_4 = plb.subplot(224) |
| 39 |
|
| 40 |
for touchstone_filename in args: |
| 41 |
print(touchstone_filename) |
| 42 |
ntwk = rf.Network(touchstone_filename) |
| 43 |
ntwk.plot_s_db(ax = ax_1, m=options.m,n=options.n) |
| 44 |
ntwk.plot_s_deg(ax = ax_2, m=options.m,n=options.n) |
| 45 |
ntwk.plot_s_smith(ax = ax_3,m=options.m,n=options.n ) |
| 46 |
|
| 47 |
|
| 48 |
plb.show() |
| 49 |
return (1) |
| 50 |
|
| 51 |
if __name__ == "__main__": |
| 52 |
main() |