Skip to content

Instantly share code, notes, and snippets.

@edy555
Created March 30, 2013 07:43
Show Gist options
  • Select an option

  • Save edy555/5275771 to your computer and use it in GitHub Desktop.

Select an option

Save edy555/5275771 to your computer and use it in GitHub Desktop.
VNA用の校正を適用するスクリプト
#!/usr/bin/env python
from pylab import *
import skrf as rf
import sys
from optparse import OptionParser
parser = OptionParser(usage="%prog: [options]")
parser.add_option("-v", "--verbose",
action="store_true", dest="verbose", default=False,
help="make lots of messages [default]")
parser.add_option("-c", metavar="CAL", dest="cal", type="string", default="measured",
help="calibration [default: 'measured']")
parser.add_option("-p", action="store_true", dest="plot", default=False,
help="plot smith chart")
(options, args) = parser.parse_args()
my_ideals = rf.load_all_touchstones('ideals')
my_measured = rf.load_all_touchstones(options.cal)
cal = rf.Calibration(
ideals = [my_ideals[k] for k in ['short','open','load']],
measured = [my_measured[k] for k in ['short','open','load']],
type = 'one port')
cal.run()
file = args[0] or 'measured.s1p'
dut = rf.Network(file)
dut_caled = cal.apply_cal(dut)
dut_caled.write_touchstone('calibrated')
if options.plot:
dut_caled.plot_s_smith()
show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment