Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/calibration crash #565

Merged
merged 2 commits into from
Oct 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NanoVNASaver/Analysis/PeakSearchAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from PyQt5 import QtWidgets
import numpy as np
# pylint: disable=import-error, no-name-in-module
from scipy.signal import find_peaks, peak_prominences

from NanoVNASaver.Analysis.Base import QHLine
Expand Down
1 change: 1 addition & 0 deletions NanoVNASaver/AnalyticTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from typing import Callable, List, Tuple

import numpy as np
# pylint: disable=import-error, no-name-in-module
from scipy.signal import find_peaks

from NanoVNASaver.RFTools import Datapoint
Expand Down
1 change: 0 additions & 1 deletion NanoVNASaver/Charts/LogMag.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class TickVal:


def span2ticks(span: float, min_val: float) -> TickVal:
logger.debug("span2ticks(%s, %s)", span, min_val)
span = abs(span)
step = log_floor_125(span / 5)
count = math.floor(span / step)
Expand Down
3 changes: 0 additions & 3 deletions NanoVNASaver/Controls/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from .MarkerControl import MarkerControl
from .SweepControl import SweepControl
from .SerialControl import SerialControl
4 changes: 3 additions & 1 deletion NanoVNASaver/NanoVNASaver.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
DeviceSettingsWindow, DisplaySettingsWindow, SweepSettingsWindow,
TDRWindow, FilesWindow
)
from .Controls import MarkerControl, SweepControl, SerialControl
from .Controls.MarkerControl import MarkerControl
from .Controls.SweepControl import SweepControl
from .Controls.SerialControl import SerialControl
from .Formatting import format_frequency, format_vswr, format_gain
from .Hardware.Hardware import Interface
from .Hardware.VNA import VNA
Expand Down
45 changes: 23 additions & 22 deletions NanoVNASaver/Windows/CalibrationSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ def _format_cal_label(size: int, prefix: str = "Set") -> str:
return f"{prefix} ({size} points)"


def getFloatValue(text: str) -> float:
try:
return float(text)
except (TypeError, ValueError):
return 0.0


class CalibrationWindow(QtWidgets.QWidget):
nextStep = -1

Expand Down Expand Up @@ -519,38 +526,38 @@ def calculate(self):

# We are using custom calibration standards

cal_element.short_l0 = self.getFloatValue(
cal_element.short_l0 = getFloatValue(
self.short_l0_input.text()) / 1.0e12
cal_element.short_l1 = self.getFloatValue(
cal_element.short_l1 = getFloatValue(
self.short_l1_input.text()) / 1.0e24
cal_element.short_l2 = self.getFloatValue(
cal_element.short_l2 = getFloatValue(
self.short_l2_input.text()) / 1.0e33
cal_element.short_l3 = self.getFloatValue(
cal_element.short_l3 = getFloatValue(
self.short_l3_input.text()) / 1.0e42
cal_element.short_length = self.getFloatValue(
cal_element.short_length = getFloatValue(
self.short_length.text()) / 1.0e12

cal_element.open_c0 = self.getFloatValue(
cal_element.open_c0 = getFloatValue(
self.open_c0_input.text()) / 1.e15
cal_element.open_c1 = self.getFloatValue(
cal_element.open_c1 = getFloatValue(
self.open_c1_input.text()) / 1.e27
cal_element.open_c2 = self.getFloatValue(
cal_element.open_c2 = getFloatValue(
self.open_c2_input.text()) / 1.0e36
cal_element.open_c3 = self.getFloatValue(
cal_element.open_c3 = getFloatValue(
self.open_c3_input.text()) / 1.0e45
cal_element.openLength = self.getFloatValue(
cal_element.openLength = getFloatValue(
self.open_length.text()) / 1.0e12

cal_element.load_r = self.getFloatValue(
cal_element.load_r = getFloatValue(
self.load_resistance.text())
cal_element.load_l = self.getFloatValue(
cal_element.load_l = getFloatValue(
self.load_inductance.text()) / 1.0e12
cal_element.load_c = self.getFloatValue(
cal_element.load_c = getFloatValue(
self.load_capacitance.text()) / 1.0e15
cal_element.load_length = self.getFloatValue(
cal_element.load_length = getFloatValue(
self.load_length.text()) / 1.0e12

cal_element.through_length = self.getFloatValue(
cal_element.through_length = getFloatValue(
self.through_length.text()) / 1.0e12

logger.debug("Attempting calibration calculation.")
Expand Down Expand Up @@ -588,13 +595,6 @@ def calculate(self):
"Applying calibration failed.")
self.calibration_source_label.setText(self.app.calibration.source)

@staticmethod
def getFloatValue(text: str) -> float:
try:
return float(text)
except (TypeError, ValueError):
return 0.0

def loadCalibration(self):
filename, _ = QtWidgets.QFileDialog.getOpenFileName(
filter="Calibration Files (*.cal);;All files (*.*)")
Expand Down Expand Up @@ -869,6 +869,7 @@ def automaticCalibrationStep(self):
self.app.worker.signals.finished.disconnect(
self.automaticCalibrationStep)
return

self.calculate()
self.btn_automatic.setDisabled(False)
self.nextStep = -1
Expand Down
1 change: 1 addition & 0 deletions NanoVNASaver/Windows/TDR.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import math

import numpy as np
# pylint: disable=import-error, no-name-in-module
from scipy.signal import convolve
from scipy.constants import speed_of_light

Expand Down