kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
2-port 1-path calibration
rodzic
50b21d3e4d
commit
4081880852
|
@ -56,11 +56,13 @@ class CalibrationWindow(QtWidgets.QWidget):
|
|||
self.cal_load_label = QtWidgets.QLabel("Uncalibrated")
|
||||
|
||||
btn_cal_through = QtWidgets.QPushButton("Through")
|
||||
btn_cal_through.setDisabled(True)
|
||||
btn_cal_through.clicked.connect(self.saveThrough)
|
||||
#btn_cal_through.setDisabled(True)
|
||||
self.cal_through_label = QtWidgets.QLabel("Uncalibrated")
|
||||
|
||||
btn_cal_isolation = QtWidgets.QPushButton("Isolation")
|
||||
btn_cal_isolation.setDisabled(True)
|
||||
btn_cal_isolation.clicked.connect(self.saveIsolation)
|
||||
#btn_cal_isolation.setDisabled(True)
|
||||
self.cal_isolation_label = QtWidgets.QLabel("Uncalibrated")
|
||||
|
||||
calibration_control_layout.addRow(btn_cal_short, self.cal_short_label)
|
||||
|
@ -93,6 +95,14 @@ class CalibrationWindow(QtWidgets.QWidget):
|
|||
self.app.calibration.s11load = self.app.data
|
||||
self.cal_load_label.setText("Calibrated")
|
||||
|
||||
def saveIsolation(self):
|
||||
self.app.calibration.s21isolation = self.app.data21
|
||||
self.cal_isolation_label.setText("Calibrated")
|
||||
|
||||
def saveThrough(self):
|
||||
self.app.calibration.s21through = self.app.data21
|
||||
self.cal_through_label.setText("Calibrated")
|
||||
|
||||
def reset(self):
|
||||
self.app.calibration = Calibration()
|
||||
self.cal_short_label.setText("Uncalibrated")
|
||||
|
@ -113,9 +123,14 @@ class Calibration:
|
|||
|
||||
frequencies = []
|
||||
|
||||
e00 = []
|
||||
e11 = []
|
||||
deltaE = []
|
||||
# 1-port
|
||||
e00 = [] # Directivity
|
||||
e11 = [] # Port match
|
||||
deltaE = [] # Tracking
|
||||
|
||||
# 2-port
|
||||
e30 = [] # Port match
|
||||
e10e32 = [] # Transmission
|
||||
|
||||
shortIdeal = np.complex(-1, 0)
|
||||
openIdeal = np.complex(1, 0)
|
||||
|
@ -136,6 +151,8 @@ class Calibration:
|
|||
self.e00 = [np.complex] * len(self.s11short)
|
||||
self.e11 = [np.complex] * len(self.s11short)
|
||||
self.deltaE = [np.complex] * len(self.s11short)
|
||||
self.e30 = [np.complex] * len(self.s11short)
|
||||
self.e10e32 = [np.complex] * len(self.s11short)
|
||||
for i in range(len(self.s11short)):
|
||||
self.frequencies[i] = self.s11short[i].freq
|
||||
|
||||
|
@ -152,6 +169,11 @@ class Calibration:
|
|||
self.e11[i] = ((g2-g3)*gm1-g1*(gm2-gm3)+g3*gm2-g2*gm3) / denominator
|
||||
self.deltaE[i] = - ((g1*(gm2-gm3)-g2*gm2+g3*gm3)*gm1+(g2*gm3-g3*gm3)*gm2) / denominator
|
||||
|
||||
if self.isValid2Port():
|
||||
self.e30[i] = np.complex(self.s21isolation[i].re, self.s21isolation[i].im)
|
||||
s21m = np.complex(self.s21through[i].re, self.s21through[i].im)
|
||||
self.e10e32[i] = (s21m - self.e30[i]) * (1 - (self.e11[i]*self.e11[i]))
|
||||
|
||||
self.isCalculated = True
|
||||
return self.isCalculated
|
||||
|
||||
|
@ -166,3 +188,14 @@ class Calibration:
|
|||
|
||||
s11 = (s11m - self.e00[index]) / ((s11m * self.e11[index]) - self.deltaE[index])
|
||||
return s11.real, s11.imag
|
||||
|
||||
def correct21(self, re, im, freq):
|
||||
s21m = np.complex(re, im)
|
||||
distance = 10**10
|
||||
index = 0
|
||||
for i in range(len(self.s21through)):
|
||||
if abs(self.s21through[i].freq - freq) < distance:
|
||||
index = i
|
||||
distance = abs(self.s21through[i].freq - freq)
|
||||
s21 = (s21m - self.e30[index]) / self.e10e32[index]
|
||||
return s21.real, s21.imag
|
||||
|
|
|
@ -106,13 +106,15 @@ class SweepWorker(QtCore.QRunnable):
|
|||
re = float(reStr)
|
||||
im = float(imStr)
|
||||
reStr, imStr = values12[i].split(" ")
|
||||
re12 = float(reStr)
|
||||
im12 = float(imStr)
|
||||
re21 = float(reStr)
|
||||
im21 = float(imStr)
|
||||
freq = int(frequencies[i])
|
||||
if self.app.calibration.isCalculated: # We only have 1-port calibration for now
|
||||
re, im = self.app.calibration.correct11(re, im, freq)
|
||||
if self.app.calibration.isValid2Port():
|
||||
re21, im21 = self.app.calibration.correct21(re21, im21, freq)
|
||||
data += [Datapoint(freq, re, im)]
|
||||
data12 += [Datapoint(freq, re12, im12)]
|
||||
data12 += [Datapoint(freq, re21, im21)]
|
||||
self.data11 = data
|
||||
self.data12 = data12
|
||||
self.app.saveData(data, data12)
|
||||
|
|
Ładowanie…
Reference in New Issue