kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
commit
700781288b
|
@ -17,7 +17,7 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
VERSION = "0.3.10-pre07"
|
||||
VERSION = "0.3.10-pre08"
|
||||
VERSION_URL = (
|
||||
"https://raw.githubusercontent.com/"
|
||||
"NanoVNA-Saver/nanovna-saver/master/NanoVNASaver/About.py")
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -110,6 +110,18 @@ def format_phase(val: float) -> str:
|
|||
return f"{math.degrees(val):.2f}""\N{DEGREE SIGN}"
|
||||
|
||||
|
||||
def format_complex_adm(z: complex, allow_negative: bool = False) -> str:
|
||||
if z == 0:
|
||||
return "- S"
|
||||
adm = 1/z
|
||||
|
||||
fmt_re = FMT_COMPLEX
|
||||
if allow_negative:
|
||||
fmt_re = FMT_COMPLEX_NEG
|
||||
re = SITools.Value(adm.real, fmt=fmt_re)
|
||||
im = SITools.Value(abs(adm.imag), fmt=FMT_COMPLEX)
|
||||
return f"{re}{'-' if adm.imag < 0 else '+'}j{im} S"
|
||||
|
||||
def format_complex_imp(z: complex, allow_negative: bool = False) -> str:
|
||||
fmt_re = FMT_COMPLEX
|
||||
if allow_negative:
|
||||
|
|
|
@ -21,6 +21,7 @@ from PyQt5 import QtCore
|
|||
from NanoVNASaver import RFTools
|
||||
from NanoVNASaver.Formatting import (
|
||||
format_capacitance,
|
||||
format_complex_adm,
|
||||
format_complex_imp,
|
||||
format_frequency_space,
|
||||
format_gain,
|
||||
|
@ -90,7 +91,7 @@ class DeltaMarker(Marker):
|
|||
format_frequency_space(s11_b.freq - s11_a.freq))
|
||||
self.label['lambda'].setText(
|
||||
format_wavelength(s11_b.wavelength - s11_a.wavelength))
|
||||
self.label['admittance'].setText(format_complex_imp(imp_p, True))
|
||||
self.label['admittance'].setText(format_complex_adm(imp_p, True))
|
||||
self.label['impedance'].setText(format_complex_imp(imp, True))
|
||||
|
||||
self.label['parc'].setText(cap_p_str)
|
||||
|
|
|
@ -25,6 +25,7 @@ from PyQt5.QtCore import pyqtSignal
|
|||
from NanoVNASaver import RFTools
|
||||
from NanoVNASaver.Formatting import (
|
||||
format_capacitance,
|
||||
format_complex_adm,
|
||||
format_complex_imp,
|
||||
format_frequency_space,
|
||||
format_gain,
|
||||
|
@ -328,7 +329,7 @@ class Marker(QtCore.QObject, Value):
|
|||
|
||||
self.label['actualfreq'].setText(format_frequency_space(_s11.freq))
|
||||
self.label['lambda'].setText(format_wavelength(_s11.wavelength))
|
||||
self.label['admittance'].setText(format_complex_imp(imp_p))
|
||||
self.label['admittance'].setText(format_complex_adm(imp))
|
||||
self.label['impedance'].setText(format_complex_imp(imp))
|
||||
self.label['parc'].setText(cap_p_str)
|
||||
self.label['parl'].setText(ind_p_str)
|
||||
|
|
|
@ -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