This little example demonstrates how to use scikit-rf for a basic TRL calibration.

Basic Use


First we import skrf, the TRL class, and setup matplotlib plotting.

import skrf as rf
from skrf.calibration import TRL

%matplotlib inline
from skrf.plotting import stylely
/home/docs/checkouts/ UserWarning: Style includes a parameter, 'interactive', that is not related to style.  Ignoring
  "to style.  Ignoring".format(key))

Load the data

Load the calibration standard’s measurements and the switch terms from touchstone files. ( If you dont know what switch terms are, see this section below. )

T = rf.Network('trl_data/thru.s2p')
R = rf.Network('trl_data/reflect.s2p')
L = rf.Network('trl_data/line.s2p')

switch_terms = (rf.Network('trl_data/forward switch term.s1p'),
                rf.Network('trl_data/reverse switch term.s1p'))

measured = [T,R,L]

Create a TRL calibration Object

trl = TRL(measured = measured,
          switch_terms = switch_terms)

Correct a DUT with it.

dut_raw = rf.Network('trl_data/mismatched line.s2p')
dut_corrected = trl.apply_cal(dut_raw)
/home/docs/checkouts/ FutureWarning: `rcond` parameter will change to the default of machine precision times ``max(M, N)`` where M and N are the input matrix dimensions.
To use the future default and silence this warning we advise to pass `rcond=None`, to keep using the old, explicitly pass `rcond=-1`.
  error_vector_at_f, residuals_at_f = npy.linalg.lstsq(Q,M)[0:2]

Switch Terms

What are they?

Described in [1] by Roger Marks, switch-terms account for the fact that the 8-term (aka error-box ) model is overly simplified. The two error networks change slightly depending on which port is being excited. This is due to the internal switch within the VNA. The change in reflection coefficient at the VNA’s internal switch is known as a switch term, it can be directed measured and removed.

  • [1] R.B. Marks, “Formulations of the Basic Vector Network Analyzer Error Model including Switch-Terms,” in ARFTG Conference Digest-Fall, 50th, 1997, vol. 32, pp. 115-126

How do I get them ?

To measure the switch terms manually, you can define custom traces as ratio’s of receivers and save the data to touchstone files. Assume ports are labeled 1 and 2, and incident waves are a’s and reflected waves are b’s. Then, the

  • forward switch term == a2/b2 with source port 1
  • reverse switch term == a1/b1 with source port 2

Can I get them with skrf?

Yes. There is a PNA driver in the module. It has code to pull the switch terms.

Can get them Onboard a PNA?

Yes. See the image below for an example of setting this up on a PNA.

from IPython.display import Image