kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
Fix division on zero in Open calibration standard C0 value = 0
Implement Load C calibration usepull/450/head
rodzic
43fd3b7d88
commit
d03982af73
|
@ -235,38 +235,36 @@ class Calibration:
|
|||
g = Calibration.IDEAL_SHORT
|
||||
if not self.useIdealShort:
|
||||
logger.debug("Using short calibration set values.")
|
||||
Zsp = complex(0, 1) * 2 * math.pi * freq * (
|
||||
Zsp = complex(0, 2 * math.pi * freq * (
|
||||
self.shortL0 + self.shortL1 * freq +
|
||||
self.shortL2 * freq**2 + self.shortL3 * freq**3)
|
||||
self.shortL2 * freq**2 + self.shortL3 * freq**3))
|
||||
# Referencing https://arxiv.org/pdf/1606.02446.pdf (18) - (21)
|
||||
g = (Zsp / 50 - 1) / (Zsp / 50 + 1) * cmath.exp(
|
||||
complex(0, 1) * 2 * math.pi * 2 * freq *
|
||||
self.shortLength * -1)
|
||||
complex(0, 2 * math.pi * 2 * freq * self.shortLength * -1))
|
||||
return g
|
||||
|
||||
def gamma_open(self, freq: int) -> complex:
|
||||
g = Calibration.IDEAL_OPEN
|
||||
if not self.useIdealOpen:
|
||||
logger.debug("Using open calibration set values.")
|
||||
divisor = (2 * math.pi * freq * (
|
||||
Zop = complex(0, 2 * math.pi * freq * (
|
||||
self.openC0 + self.openC1 * freq +
|
||||
self.openC2 * freq**2 + self.openC3 * freq**3))
|
||||
if divisor != 0:
|
||||
Zop = complex(0, -1) / divisor
|
||||
g = ((Zop / 50 - 1) / (Zop / 50 + 1)) * cmath.exp(
|
||||
complex(0, 1) * 2 * math.pi *
|
||||
2 * freq * self.openLength * -1)
|
||||
g = ((1 - 50 * Zop) / (1 + 50 * Zop)) * cmath.exp(
|
||||
complex(0, 2 * math.pi * 2 * freq * self.openLength * -1))
|
||||
return g
|
||||
|
||||
def gamma_load(self, freq: int) -> complex:
|
||||
g = Calibration.IDEAL_LOAD
|
||||
if not self.useIdealLoad:
|
||||
logger.debug("Using load calibration set values.")
|
||||
Zl = self.loadR + (complex(0, 1) * 2 *
|
||||
math.pi * freq * self.loadL)
|
||||
Zl = complex(self.loadR, 0)
|
||||
if self.loadC > 0:
|
||||
Zl = self.loadR / complex(1, 2 * self.loadR * math.pi * freq * self.loadC)
|
||||
if self.loadL > 0:
|
||||
Zl = Zl + complex(0, 2 * math.pi * freq * self.loadL)
|
||||
g = (Zl / 50 - 1) / (Zl / 50 + 1) * cmath.exp(
|
||||
complex(0, 1) * 2 * math.pi *
|
||||
2 * freq * self.loadLength * -1)
|
||||
complex(0, 2 * math.pi * 2 * freq * self.loadLength * -1))
|
||||
return g
|
||||
|
||||
def gamma_through(self, freq: int) -> complex:
|
||||
|
|
|
@ -185,14 +185,14 @@ class CalibrationWindow(QtWidgets.QWidget):
|
|||
self.load_resistance.setMinimumHeight(20)
|
||||
self.load_inductance = QtWidgets.QLineEdit("0")
|
||||
self.load_inductance.setMinimumHeight(20)
|
||||
# self.load_capacitance = QtWidgets.QLineEdit("0")
|
||||
# self.load_capacitance.setMinimumHeight(20)
|
||||
# self.load_capacitance.setDisabled(True) # Not yet implemented
|
||||
self.load_capacitance = QtWidgets.QLineEdit("0")
|
||||
self.load_capacitance.setMinimumHeight(20)
|
||||
#self.load_capacitance.setDisabled(True) # Not yet implemented
|
||||
self.load_length = QtWidgets.QLineEdit("0")
|
||||
self.load_length.setMinimumHeight(20)
|
||||
cal_load_form.addRow("Resistance (\N{OHM SIGN})", self.load_resistance)
|
||||
cal_load_form.addRow("Inductance (H(e-12))", self.load_inductance)
|
||||
# cal_load_form.addRow("Capacitance (F(e-12))", self.load_capacitance)
|
||||
cal_load_form.addRow("Capacitance (F(e-15))", self.load_capacitance)
|
||||
cal_load_form.addRow("Offset Delay (ps)", self.load_length)
|
||||
|
||||
self.cal_through_box = QtWidgets.QGroupBox("Through")
|
||||
|
@ -313,7 +313,7 @@ class CalibrationWindow(QtWidgets.QWidget):
|
|||
|
||||
self.app.settings.setValue("LoadR", self.load_resistance.text())
|
||||
self.app.settings.setValue("LoadL", self.load_inductance.text())
|
||||
# self.app.settings.setValue("LoadC", self.load_capacitance.text())
|
||||
self.app.settings.setValue("LoadC", self.load_capacitance.text())
|
||||
self.app.settings.setValue("LoadDelay", self.load_length.text())
|
||||
|
||||
self.app.settings.setValue("ThroughDelay", self.through_length.text())
|
||||
|
@ -348,7 +348,7 @@ class CalibrationWindow(QtWidgets.QWidget):
|
|||
|
||||
self.load_resistance.setText(str(self.app.settings.value("LoadR", 50)))
|
||||
self.load_inductance.setText(str(self.app.settings.value("LoadL", 0)))
|
||||
# self.load_capacitance.setText(str(self.app.settings.value("LoadC", 0)))
|
||||
self.load_capacitance.setText(str(self.app.settings.value("LoadC", 0)))
|
||||
self.load_length.setText(str(self.app.settings.value("LoadDelay", 0)))
|
||||
|
||||
self.through_length.setText(str(self.app.settings.value("ThroughDelay", 0)))
|
||||
|
@ -511,8 +511,6 @@ class CalibrationWindow(QtWidgets.QWidget):
|
|||
try:
|
||||
self.app.calibration.openC0 = self.getFloatValue(
|
||||
self.open_c0_input.text())/10**15
|
||||
if self.app.calibration.openC0 == 0:
|
||||
raise ValueError("C0 cannot be 0.")
|
||||
self.app.calibration.openC1 = self.getFloatValue(
|
||||
self.open_c1_input.text())/10**27
|
||||
self.app.calibration.openC2 = self.getFloatValue(
|
||||
|
@ -531,9 +529,9 @@ class CalibrationWindow(QtWidgets.QWidget):
|
|||
self.app.calibration.loadR = self.getFloatValue(
|
||||
self.load_resistance.text())
|
||||
self.app.calibration.loadL = self.getFloatValue(
|
||||
self.load_inductance.text())/10**12
|
||||
# self.app.calibration.loadC = self.getFloatValue(
|
||||
# self.load_capacitance.text()) / 10 ** 12
|
||||
self.load_inductance.text()) / 10**12
|
||||
self.app.calibration.loadC = self.getFloatValue(
|
||||
self.load_capacitance.text()) / 10 ** 15
|
||||
self.app.calibration.loadLength = self.getFloatValue(
|
||||
self.load_length.text())/10**12
|
||||
self.app.calibration.useIdealLoad = False
|
||||
|
|
Ładowanie…
Reference in New Issue