- Fix division by zero if the frequency is 0, or the reading is completely resistive.

pull/24/head
Rune Broberg 2019-09-26 12:54:20 +02:00
rodzic 6c999c0eac
commit 59ede57d4a
1 zmienionych plików z 4 dodań i 0 usunięć

Wyświetl plik

@ -796,11 +796,15 @@ class NanoVNASaver(QtWidgets.QWidget):
@staticmethod
def capacitanceEquivalent(im50, freq) -> str:
if im50 == 0 or freq == 0:
return "- pF"
capacitance = 10**12/(freq * 2 * math.pi * im50)
return str(round(-capacitance, 3)) + " pF"
@staticmethod
def inductanceEquivalent(im50, freq) -> str:
if freq == 0:
return "- nH"
inductance = im50 / (freq * 2 * math.pi)
return str(round(inductance * 1000000000, 3)) + " nH"