kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
Removed no longer needed properties
rodzic
aa9f1accc9
commit
658cc6f231
|
@ -39,7 +39,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
# TODO: make a real class of calibration
|
||||
class Calibration:
|
||||
_CAL_NAMES = ("short", "open", "load", "through", "isolation",)
|
||||
CAL_NAMES = ("short", "open", "load", "through", "isolation",)
|
||||
|
||||
def __init__(self):
|
||||
|
||||
|
@ -88,47 +88,16 @@ class Calibration:
|
|||
self.source = "Manual"
|
||||
|
||||
def _reset_cals(self):
|
||||
for name in Calibration._CAL_NAMES:
|
||||
for name in Calibration.CAL_NAMES:
|
||||
self.cals[name] = []
|
||||
|
||||
@property
|
||||
def s11short(self) -> List[Datapoint]:
|
||||
return self.cals["short"]
|
||||
@s11short.setter
|
||||
def s11short(self, values: List[Datapoint]):
|
||||
self.cals["short"] = values
|
||||
@property
|
||||
def s11open(self) -> List[Datapoint]:
|
||||
return self.cals["open"]
|
||||
@s11open.setter
|
||||
def s11open(self, values: List[Datapoint]):
|
||||
self.cals["open"] = values
|
||||
@property
|
||||
def s11load(self) -> List[Datapoint]:
|
||||
return self.cals["load"]
|
||||
@s11load.setter
|
||||
def s11load(self, values: List[Datapoint]):
|
||||
self.cals["load"] = values
|
||||
@property
|
||||
def s21through(self) -> List[Datapoint]:
|
||||
return self.cals["through"]
|
||||
@s21through.setter
|
||||
def s21through(self, values: List[Datapoint]):
|
||||
self.cals["through"] = values
|
||||
@property
|
||||
def s21isolation(self) -> List[Datapoint]:
|
||||
return self.cals["isolation"]
|
||||
@s21isolation.setter
|
||||
def s21isolation(self, values: List[Datapoint]):
|
||||
self.cals["isolation"] = values
|
||||
|
||||
def isValid1Port(self):
|
||||
lengths = [len(self.cals[x])
|
||||
for x in Calibration._CAL_NAMES[:3]]
|
||||
for x in Calibration.CAL_NAMES[:3]]
|
||||
return min(lengths) > 0 and min(lengths) == max(lengths)
|
||||
|
||||
def isValid2Port(self):
|
||||
lengths = [len(self.cals[x]) for x in Calibration._CAL_NAMES]
|
||||
lengths = [len(self.cals[x]) for x in Calibration.CAL_NAMES]
|
||||
return min(lengths) > 0 and min(lengths) == max(lengths)
|
||||
|
||||
def calc_corrections(self):
|
||||
|
@ -358,7 +327,7 @@ class Calibration:
|
|||
else:
|
||||
nr_cals = 3
|
||||
|
||||
for name in Calibration._CAL_NAMES[:nr_cals]:
|
||||
for name in Calibration.CAL_NAMES[:nr_cals]:
|
||||
self.cals[name].append(
|
||||
Datapoint(int(cal["freq"]),
|
||||
float(cal[f"{name}r"]),
|
||||
|
|
|
@ -63,7 +63,7 @@ class CalibrationWindow(QtWidgets.QWidget):
|
|||
calibration_control_layout = QtWidgets.QFormLayout(calibration_control_group)
|
||||
cal_btn = {}
|
||||
self.cal_label = {}
|
||||
for label_name in Calibration._CAL_NAMES:
|
||||
for label_name in Calibration.CAL_NAMES:
|
||||
self.cal_label[label_name] = QtWidgets.QLabel("Uncalibrated")
|
||||
cal_btn[label_name] = QtWidgets.QPushButton(
|
||||
label_name.capitalize())
|
||||
|
@ -522,7 +522,8 @@ class CalibrationWindow(QtWidgets.QWidget):
|
|||
try:
|
||||
self.app.calibration.calc_corrections()
|
||||
self.calibration_status_label.setText(
|
||||
f"Application calibration ({len(self.app.calibration.s11short)} points)")
|
||||
_format_cal_label(self.app.calibration.cals["short"],
|
||||
"Application calibration"))
|
||||
if self.use_ideal_values.isChecked():
|
||||
self.calibration_source_label.setText(self.app.calibration.source)
|
||||
else:
|
||||
|
@ -558,16 +559,10 @@ class CalibrationWindow(QtWidgets.QWidget):
|
|||
self.app.calibration.load(filename)
|
||||
if not self.app.calibration.isValid1Port():
|
||||
return
|
||||
cals = (
|
||||
("short", self.app.calibration.s11short),
|
||||
("open", self.app.calibration.s11open),
|
||||
("load", self.app.calibration.s11load),
|
||||
("through", self.app.calibration.s21through),
|
||||
("isolation", self.app.calibration.s21isolation),
|
||||
)
|
||||
for i, cal in enumerate(cals):
|
||||
self.cal_label[cal[0]].setText(
|
||||
_format_cal_label(cal[1], "Loaded"))
|
||||
for i, name in enumerate(
|
||||
("short", "open", "load", "through", "isolation")):
|
||||
self.cal_label[name].setText(
|
||||
_format_cal_label(self.app.calibration.cals[name], "Loaded"))
|
||||
if i == 2 and not self.app.calibration.isValid2Port():
|
||||
break
|
||||
self.calculate()
|
||||
|
|
Ładowanie…
Reference in New Issue