Esempio n. 1
0
    def setUp(self):
        self.n_ports = 2
        self.wg = WG
        wg= self.wg

        self.X = wg.random(n_ports =2, name = 'X')
        self.Y = wg.random(n_ports =2, name = 'Y')
        self.If = wg.random(n_ports=1, name='If')
        self.Ir = wg.random(n_ports=1, name='Ir')

        self.gamma_f = wg.random(n_ports =1, name='gamma_f')
        self.gamma_r = wg.random(n_ports =1, name='gamma_r')

        actuals = [
            wg.thru(),
            rf.two_port_reflect(wg.load(-.98-.1j),wg.load(-.98-.1j)),
            rf.two_port_reflect(wg.load(.99+0.05j),wg.load(.99+0.05j)),
            wg.line(100,'um'),
            wg.line(200,'um'),
            wg.line(900,'um'),
            ]

        self.actuals=actuals

        measured = [self.measure(k) for k in actuals]

        self.cal = NISTMultilineTRL(
            measured = measured,
            isolation = measured[1],
            Grefls = [-1, 1],
            l = [0, 100e-6, 200e-6, 900e-6],
            er_est = 1,
            switch_terms = (self.gamma_f, self.gamma_r),
            gamma_root_choice = 'real'
            )
Esempio n. 2
0
    def setUp(self):
        self.n_ports = 2
        self.wg = WG
        wg = self.wg

        #Port 0: VNA port 0
        #Port 1: DUT port 0
        #Port 2: DUT port 1
        #Port 3: VNA port 1
        self.Z = wg.random(n_ports = 4, name = 'Z')

        o = wg.open(nports=1, name='open')
        s = wg.short(nports=1, name='short')
        m = wg.match(nports=1, name='load')
        om = rf.two_port_reflect(o, m)
        mo = rf.two_port_reflect(m, o)
        oo = rf.two_port_reflect(o, o)
        ss = rf.two_port_reflect(s, s)
        thru = wg.thru(name='thru')

        ideals = [
            thru,
            om,
            mo,
            oo,
            ss
            ]

        measured = [self.measure(k) for k in ideals]

        self.cal = rf.SixteenTerm(
            measured = measured,
            ideals = ideals,
            )
Esempio n. 3
0
 def setUp(self):
     self.wg = WG
     wg = self.wg
     self.X = wg.random(n_ports =2, name = 'X')
     self.Y = wg.random(n_ports =2, name='Y')  
     
     
     #thru
     self.T = wg.thru()
     self.T_m = self.embed(self.T)
     
     #line
     self.L = wg.line(80,'deg')
     self.L_approx = self.wg.line(90,'deg')
     self.L_m = self.embed(self.L)
     
     # reflect
     self.r = [ wg.delay_load(p,k,'deg') \
                 for k in [-10,10,88,92] \
                 for p in [-.9,-1]]
     
     
     self.R = [rf.two_port_reflect(k,k) for k in self.r]
     
     short= wg.short()
     open = wg.open()
     self.r_estimate = [short, short,short, short, open ,open, open ,open]
     self.R_m = [self.embed(k) for k in self.R]
Esempio n. 4
0
    def setUp(self):
        self.n_ports = 2
        self.wg = WG
        wg= self.wg

        self.X = wg.random(n_ports =2, name = 'X')
        self.Y = wg.random(n_ports =2, name='Y')
        self.If = wg.random(n_ports=1, name='If')
        self.Ir = wg.random(n_ports=1, name='Ir')
        self.gamma_f = wg.random(n_ports =1, name='gamma_f')
        self.gamma_r = wg.random(n_ports =1, name='gamma_r')
        # make error networks have s21,s12 >> s11,s22 so that TRL
        # can guess at line length
        self.X.s[:,0,0] *=1e-1
        self.Y.s[:,0,0] *=1e-1
        self.X.s[:,1,1] *=1e-1 
        self.Y.s[:,1,1] *=1e-1 
        
        ideals =  None
        
        r = wg.delay_short(20,'deg')

        self.actuals=[wg.thru( name='thru'),
                      rf.two_port_reflect(r,r),\
                      wg.attenuator(-3,True, 45,'deg')]

        measured = [self.measure(k) for k in self.actuals]
        
        self.cal = rf.TRL(
            ideals = None,
            measured = measured,
            isolation = measured[1],
            switch_terms = (self.gamma_f, self.gamma_r)
            )
Esempio n. 5
0
    def setUp(self):
        self.n_ports = 2
        self.wg = WG
        wg = self.wg

        #Port 0: VNA port 0
        #Port 1: DUT port 0
        #Port 2: DUT port 1
        #Port 3: VNA port 1
        self.Z = wg.random(n_ports = 4, name = 'Z')
        self.gamma_f = wg.random(n_ports =1, name='gamma_f')
        self.gamma_r = wg.random(n_ports =1, name='gamma_r')

        r = wg.short(nports=1, name='short')
        m = wg.match(nports=1, name='load')
        mm = rf.two_port_reflect(m, m)
        rm = rf.two_port_reflect(r, m)
        mr = rf.two_port_reflect(m, r)
        rr = rf.two_port_reflect(r, r)

        thru_length = uniform(0,10)
        thru = wg.line(thru_length,'deg',name='line')

        self.thru = thru

        ideals = [
            thru,
            mm,
            rr,
            rm,
            mr
            ]

        measured = [self.measure(k) for k in ideals]

        self.cal = rf.LMR16(
            measured = measured,
            ideals = [r],
            ideal_is_reflect = True,
             #Automatic sign detection doesn't work if the
             #error terms aren't symmetric enough
            sign = -1,
            switch_terms=(self.gamma_f, self.gamma_r)
            )
Esempio n. 6
0
def trlCalibrate(name):
    measured = [measuredFiles['thru'],
                skrf.two_port_reflect(measuredFiles['short'],measuredFiles['short']),
                measuredFiles[name] ]

    ideals = [  makeStandard('thruIdeal',numpy.array([[0,1],[1,0]])),
                makeStandard('shortIdeal',numpy.array([[-1.]]),mirror=True),
                standardFiles[name] ]
                
    trlCalibration = skrf.Calibration(measured,ideals)
    trlCalibration.run()
    return trlCalibration
Esempio n. 7
0
def makeStandard(standardName,coefficient,mirror=False):
    assert coefficient.ndim == 2
    standard = skrf.Network()
    standard.f = frequencyList
    
    repeatableCoefficient = numpy.array([coefficient])
    standard.s = repeatableCoefficient.repeat(len(standard.f),0)
    
    if mirror:
        return skrf.two_port_reflect(standard,standard)
    else:
        return standard
Esempio n. 8
0
 def setUp(self):
     self.wg = WG
     wg = self.wg
     self.X = wg.random(n_ports =2, name = 'X')
     self.Y = wg.random(n_ports =2, name='Y')  
     
     
     #thru
     self.T = wg.thru()
     self.T_m = self.embed(self.T)
     
     #line
     self.L = wg.line(80,'deg')
     self.L_approx = self.wg.line(90,'deg')
     self.L_m = self.embed(self.L)
     
     # reflect
     r = wg.load(-.8-.1j)
     self.R = two_port_reflect(r,r)
     self.R_approx = wg.short()
     self.R_m = self.embed(self.R)
Esempio n. 9
0
 def setUp(self):
     self.n_ports = 2
     self.wg = WG
     wg= self.wg
     
     
     self.X = wg.random(n_ports =2, name = 'X')
     self.Y = wg.random(n_ports =2, name='Y')
     self.If = wg.random(n_ports=1, name='If')
     self.Ir = wg.random(n_ports=1, name='Ir')
     self.gamma_f = wg.random(n_ports =1, name='gamma_f')
     self.gamma_r = wg.random(n_ports =1, name='gamma_r')
     # make error networks have s21,s12 >> s11,s22 so that TRL
     # can guess at line length
     self.X.s[:,0,0] *=1e-1
     self.Y.s[:,0,0] *=1e-1
     self.X.s[:,1,1] *=1e-1 
     self.Y.s[:,1,1] *=1e-1 
     
     actuals = [
         wg.thru( name='thru'),
         rf.two_port_reflect(wg.load(-.9-.1j),wg.load(-.9-.1j)),
         wg.attenuator(-3,True, 45,'deg')
         #wg.line(45,'deg',name='line'),
         ]
     self.actuals=actuals
     ideals = [
         wg.thru( name='thru'),
         wg.short(nports=2, name='short'),
         wg.line(90,'deg',name='line'),
         ]
         
     measured = [self.measure(k) for k in actuals]
     
     self.cal = rf.TRL(
         ideals = ideals,
         measured = measured,
         isolation = measured[1],
         switch_terms = (self.gamma_f, self.gamma_r)
         )
Esempio n. 10
0
 def evaluate(self):
     if type(self.reflect_2port) is skrf.Network:
         self.ready = True
         self.label_port1.setText("port1 - measured")
         self.label_port2.setText("port2 - measured")
     else:
         if type(self.s11) is skrf.Network and type(self.s22) is skrf.Network:
             self.reflect_2port = skrf.two_port_reflect(self.s11, self.s22)
             # self.reflect_2port = skrf.four_oneports_2_twoport(self.s11, self.s11, self.s22, self.s22)
             # self.reflect_2port.s[:, 0, 1] = 0
             # self.reflect_2port.s[:, 1, 0] = 0
             self.ready = True
             self.label_port1.setText("port1 - measured")
             self.label_port2.setText("port2 - measured")
         else:
             self.ready = False
             if type(self.s11) is skrf.Network:
                 self.label_port1.setText("port1 - measured")
             else:
                 self.label_port1.setText("port1 - not measured")
             if type(self.s22) is skrf.Network:
                 self.label_port2.setText("port2 - measured")
             else:
                 self.label_port2.setText("port2 - not measured")
Esempio n. 11
0
THRU_S21 = np.load(meas_folder / 'THRU_S21.ntwk', allow_pickle=True)
THRU_S12 = np.load(meas_folder / 'THRU_S12.ntwk', allow_pickle=True)

REFLECT_S11 = np.load(meas_folder / 'REFLECT_S11.ntwk', allow_pickle=True)
REFLECT_S22 = np.load(meas_folder / 'REFLECT_S22.ntwk', allow_pickle=True)
REFLECT_S21 = np.load(meas_folder / 'REFLECT_S21.ntwk', allow_pickle=True)
REFLECT_S12 = np.load(meas_folder / 'REFLECT_S12.ntwk', allow_pickle=True)

LINE_S11 = np.load(meas_folder / 'LINE_S11.ntwk', allow_pickle=True)
LINE_S22 = np.load(meas_folder / 'LINE_S22.ntwk', allow_pickle=True)
LINE_S21 = np.load(meas_folder / 'LINE_S21.ntwk', allow_pickle=True)
LINE_S12 = np.load(meas_folder / 'LINE_S12.ntwk', allow_pickle=True)

SWITCH_TERMS = np.load(meas_folder / 'SWITCH_TERMS.ntwk', allow_pickle=True)

THRU = rf.two_port_reflect(THRU_S11, THRU_S22)
n_freq = len(THRU.f)
pad_zeros = np.zeros((n_freq, 2, 2))

THRU.s[:, 0, 1] = THRU_S12.s[:, 0, 0]
THRU.s[:, 1, 0] = THRU_S21.s[:, 0, 0]
THRU.z0 = (50 + 0j) * np.ones((n_freq, 4))

REFLECT = rf.two_port_reflect(REFLECT_S11, REFLECT_S22)
REFLECT.s[:, 0, 1] = REFLECT_S12.s[:, 0, 0]
REFLECT.s[:, 1, 0] = REFLECT_S21.s[:, 0, 0]
REFLECT.z0 = (50 + 0j) * np.ones((n_freq, 4))

LINE = rf.two_port_reflect(LINE_S11, LINE_S22)
LINE.s[:, 0, 1] = LINE_S12.s[:, 0, 0]
LINE.s[:, 1, 0] = LINE_S21.s[:, 0, 0]
Esempio n. 12
0
ss = skrf.Network('short_short.s2p')
through = skrf.Network('through.s2p')

freqs = through.f

frequency = through.frequency

o_i = skrf.Network('../cal_kit/open.s1p')
s_i = skrf.Network('../cal_kit/short.s1p')
l_i = skrf.Network('../cal_kit/load.s1p')

o_i = o_i.interpolate(frequency)
s_i = s_i.interpolate(frequency)
l_i = l_i.interpolate(frequency)

ll_i = skrf.two_port_reflect(l_i, l_i)
ss_i = skrf.two_port_reflect(s_i, s_i)
oo_i = skrf.two_port_reflect(o_i, o_i)

through_delay = 51.1e-12
d = 2 * np.pi * through_delay
through_s = [[[0, np.exp(-1j * d * f)], [np.exp(-1j * d * f), 0]]
             for f in freqs]
through_i = skrf.Network(s=through_s, f=freqs, f_unit='Hz')

cal = skrf.TwelveTerm(\
        measured = [oo, ss, ll, through],
        ideals =[oo_i, ss_i, ll_i, through_i],
        n_thrus = 1,
        isolation=ll
        )
Esempio n. 13
0
    def setUp(self):
        self.n_ports = 2
        self.wg = WG
        wg = self.wg

        #Port 0: VNA port 0
        #Port 1: DUT port 0
        #Port 2: DUT port 1
        #Port 3: VNA port 1
        self.Z = wg.random(n_ports=4, name='Z')
        self.gamma_f = wg.random(n_ports=1, name='gamma_f')
        self.gamma_r = wg.random(n_ports=1, name='gamma_r')

        o = wg.open(nports=1, name='open')
        s = wg.short(nports=1, name='short')
        m = wg.match(nports=1, name='load')
        om = rf.two_port_reflect(o, m)
        mo = rf.two_port_reflect(m, o)
        oo = rf.two_port_reflect(o, o)
        ss = rf.two_port_reflect(s, s)
        thru = wg.thru(name='thru')

        ideals = [thru, om, mo, oo, ss]

        measured = [self.measure(k) for k in ideals]

        self.cal16 = rf.SixteenTerm(measured=measured,
                                    ideals=ideals,
                                    switch_terms=(self.gamma_f, self.gamma_r))

        r = wg.load(.95 + .1j, nports=1)
        m = wg.match(nports=1)
        mm = rf.two_port_reflect(m, m)
        rm = rf.two_port_reflect(r, m)
        mr = rf.two_port_reflect(m, r)
        rr = rf.two_port_reflect(r, r)

        ideals = [thru, mm, rr, rm, mr]

        measured = [self.measure(k) for k in ideals]

        self.cal_lmr16 = rf.LMR16(
            measured=measured,
            ideals=[thru],
            ideal_is_reflect=False,
            #Automatic sign detection doesn't work if the
            #error terms aren't symmetric enough
            sign=1,
            switch_terms=(self.gamma_f, self.gamma_r))

        #Same error network, but without leakage terms

        #Primary leakage
        self.Z.s[:, 3, 0] = 0  # forward isolation
        self.Z.s[:, 0, 3] = 0  # reverse isolation
        self.Z.s[:, 2, 1] = 0  # forward port isolation
        self.Z.s[:, 1, 2] = 0  # reverse port isolation

        #Cross leakage
        self.Z.s[:, 3, 1] = 0  # forward port 2 isolation
        self.Z.s[:, 1, 3] = 0  # reverse port 2 isolation
        self.Z.s[:, 2, 0] = 0  # forward port 1 isolation
        self.Z.s[:, 0, 2] = 0  # reverse port 1 isolation

        measured = [self.measure(k) for k in ideals]

        self.cal8 = rf.EightTerm(
            measured=measured,
            ideals=ideals,
            switch_terms=(self.gamma_f, self.gamma_r),
        )
Esempio n. 14
0
 def delay_shorts(d1, d2):
     ds1 = wg.delay_short(d1, 'deg')
     ds2 = wg.delay_short(d2, 'deg')
     return rf.two_port_reflect(ds1, ds2)
Esempio n. 15
0
    thru_ideal
    #rf.two_port_reflect(thru_ideal, thru_ideal),
    #rf.two_port_reflect(load_ideal, load_ideal),
    #rf.two_port_reflect(reflect_ideal, reflect_ideal),
    #rf.two_port_reflect(reflect_ideal, load_ideal),
    #rf.two_port_reflect(load_ideal, reflect_ideal),
]

# a list of Network types, holding 'measured' responses
reflect_measure = rf.Network(D_reflect_m)
load_measure = rf.Network(D_load_m)
thru_measure = rf.Network(D_thru_m)

my_measured = [
    thru_measure,
    rf.two_port_reflect(load_measure, load_measure),
    rf.two_port_reflect(reflect_measure, reflect_measure),
    rf.two_port_reflect(reflect_measure, load_measure),
    rf.two_port_reflect(load_measure, reflect_measure),
]

## create a SOLT instance
cal = LMR16(
    ideals=my_ideals,
    measured=my_measured,
    ideal_is_reflect=False,
)

# run calibration algorithm
cal.run()
Esempio n. 16
0
for measurementName in ['open','load','short']:
    measured.append(measuredFiles[measurementName])

ideals = [makeStandard('openIdeal',numpy.array([[+1.]])),
            makeStandard('loadIdeal',numpy.array([[0.]])),
            makeStandard('shortIdeal',numpy.array([[-1.]]))]

solCalibration = skrf.Calibration(measured,ideals)
solCalibration.run()

## SOLT calibration
twoPortMeasurements = []
for measurementName in ['open','load','short','thru']:
    measurement = measuredFiles[measurementName]
    if measurement.number_of_ports == 1:
        twoPortMeasurements.append(skrf.two_port_reflect(measurement,measurement))
    elif measurement.number_of_ports == 2:
        twoPortMeasurements.append(measurement)
    else:
        print 'Error'

ideals = [makeStandard('openIdeal',numpy.array([[+1.]]),mirror=True),
            makeStandard('loadIdeal',numpy.array([[0.]]),mirror=True),
            makeStandard('shortIdeal',numpy.array([[-1.]]),mirror=True),
            makeStandard('thruIdeal',numpy.array([[0,1],[1,0]]))]

soltCalibration = skrf.Calibration(twoPortMeasurements,ideals)
soltCalibration.run()

## TRL calibrations
def trlCalibrate(name):
Esempio n. 17
0
    def setUp(self):
        self.n_ports = 2
        self.wg = WG
        wg = self.wg

        #Port 0: VNA port 0
        #Port 1: DUT port 0
        #Port 2: DUT port 1
        #Port 3: VNA port 1
        self.Z = wg.random(n_ports = 4, name = 'Z')
        self.gamma_f = wg.random(n_ports =1, name='gamma_f')
        self.gamma_r = wg.random(n_ports =1, name='gamma_r')

        o = wg.open(nports=1, name='open')
        s = wg.short(nports=1, name='short')
        m = wg.match(nports=1, name='load')
        om = rf.two_port_reflect(o, m)
        mo = rf.two_port_reflect(m, o)
        oo = rf.two_port_reflect(o, o)
        ss = rf.two_port_reflect(s, s)
        thru = wg.thru(name='thru')

        ideals = [
            thru,
            om,
            mo,
            oo,
            ss
            ]

        measured = [self.measure(k) for k in ideals]

        self.cal16 = rf.SixteenTerm(
            measured = measured,
            ideals = ideals,
            switch_terms=(self.gamma_f, self.gamma_r)
            )

        r = wg.load(.95+.1j,nports=1)
        m = wg.match(nports=1)
        mm = rf.two_port_reflect(m, m)
        rm = rf.two_port_reflect(r, m)
        mr = rf.two_port_reflect(m, r)
        rr = rf.two_port_reflect(r, r)

        ideals = [
            thru,
            mm,
            rr,
            rm,
            mr
            ]

        measured = [self.measure(k) for k in ideals]

        self.cal_lmr16 = rf.LMR16(
            measured = measured,
            ideals = [thru],
            ideal_is_reflect = False,
             #Automatic sign detection doesn't work if the
             #error terms aren't symmetric enough
            sign = 1,
            switch_terms=(self.gamma_f, self.gamma_r)
            )

        #Same error network, but without leakage terms

        #Primary leakage
        self.Z.s[:,3,0] = 0 # forward isolation
        self.Z.s[:,0,3] = 0 # reverse isolation
        self.Z.s[:,2,1] = 0 # forward port isolation
        self.Z.s[:,1,2] = 0 # reverse port isolation

        #Cross leakage        
        self.Z.s[:,3,1] = 0 # forward port 2 isolation
        self.Z.s[:,1,3] = 0 # reverse port 2 isolation
        self.Z.s[:,2,0] = 0 # forward port 1 isolation
        self.Z.s[:,0,2] = 0 # reverse port 1 isolation

        measured = [self.measure(k) for k in ideals]

        self.cal8 = rf.EightTerm(
            measured = measured,
            ideals = ideals,
            switch_terms=(self.gamma_f, self.gamma_r),
            )
Esempio n. 18
0
 def delay_shorts(d1,d2):
     ds1 = wg.delay_short(d1,'deg')
     ds2 = wg.delay_short(d2,'deg')
     return rf.two_port_reflect(ds1,ds2)

#import 2 port data

DUT_Agilent_corrected =rf.Network('C:\\Users\\Zaber\\Documents\\data\\scikit_measurements\\Agilent Cal\\Calibrated_DUT.s2p')

#%%
vna.sweep

measurement_S11 = vna.get_measurement(mname = meas_S11)
measurement_S22 = vna.get_measurement(mname = meas_S22)
measurement_S21 = vna.get_measurement(mname = meas_S21)
measurement_S12 = vna.get_measurement(mname = meas_S12)


measurement = rf.two_port_reflect(measurement_S11, measurement_S22)
measurement.s[:,0,1] = measurement_S12.s[:,0,0]
measurement.s[:,1,0] = measurement_S21.s[:,0,0]

measurement_corrected = cal.apply_cal(measurement)


#%%
%matplotlib inline
fig, (ax1, ax2) =plt.subplots(2,1)
ax1.set_title('VNA versus Offline Calibration')

measurement_corrected.plot_s_re(ax = ax1, linestyle = '--')
measurement_corrected.plot_s_im(ax = ax2, linestyle = '--')

DUT_Agilent_corrected.plot_s_re(ax = ax1)