kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
Minor niggles
rodzic
899886e8d8
commit
28e95a25bc
|
@ -56,7 +56,7 @@ def format_resistance(val: float) -> str:
|
|||
return str(SITools.Value(val, "\N{OHM SIGN}", FMT_REACT))
|
||||
|
||||
|
||||
def format_capacity(val: float, allow_negative: bool=True) -> str:
|
||||
def format_capacitance(val: float, allow_negative: bool=True) -> str:
|
||||
if not allow_negative and val < 0:
|
||||
return "- pF"
|
||||
return str(SITools.Value(val, "F", FMT_REACT))
|
||||
|
@ -400,11 +400,11 @@ class Marker(QtCore.QObject):
|
|||
s21 = s21data[self.location]
|
||||
|
||||
imp = s11.impedance()
|
||||
cap_str = format_capacity(RFTools.impedance_to_capacity(imp, s11.freq))
|
||||
cap_str = format_capacitance(RFTools.impedance_to_capacitance(imp, s11.freq))
|
||||
ind_str = format_inductance(RFTools.impedance_to_inductance(imp, s11.freq))
|
||||
|
||||
imp_p = RFTools.serial_to_parallel(imp)
|
||||
cap_p_str = format_capacity(RFTools.impedance_to_capacity(imp_p, s11.freq))
|
||||
cap_p_str = format_capacitance(RFTools.impedance_to_capacitance(imp_p, s11.freq))
|
||||
ind_p_str = format_inductance(RFTools.impedance_to_inductance(imp_p, s11.freq))
|
||||
|
||||
if imp.imag < 0:
|
||||
|
|
|
@ -40,8 +40,8 @@ def serial_to_parallel(z: complex) -> complex:
|
|||
z_sq_sum / z.imag)
|
||||
|
||||
|
||||
def impedance_to_capacity(z: complex, freq: float) -> float:
|
||||
"""Calculate capacitve equivalent for reactance"""
|
||||
def impedance_to_capacitance(z: complex, freq: float) -> float:
|
||||
"""Calculate capacitive equivalent for reactance"""
|
||||
if freq == 0:
|
||||
return -math.inf
|
||||
if z.imag == 0:
|
||||
|
@ -122,7 +122,7 @@ class Datapoint(NamedTuple):
|
|||
return abs(imp.imag / imp.real)
|
||||
|
||||
def capacitiveEquivalent(self, ref_impedance: float = 50) -> float:
|
||||
return impedance_to_capacity(
|
||||
return impedance_to_capacitance(
|
||||
self.impedance(ref_impedance), self.freq)
|
||||
|
||||
def inductiveEquivalent(self, ref_impedance: float = 50) -> float:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Copyright (C) 2019. Rune B. Broberg
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published bynanovna
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
|
|
|
@ -21,7 +21,7 @@ from NanoVNASaver.RFTools import Datapoint, \
|
|||
norm_to_impedance, impedance_to_norm, \
|
||||
reflection_coefficient, gamma_to_impedance, clamp_value, \
|
||||
parallel_to_serial, serial_to_parallel, \
|
||||
impedance_to_capacity, impedance_to_inductance
|
||||
impedance_to_capacitance, impedance_to_inductance
|
||||
import math
|
||||
|
||||
|
||||
|
@ -83,10 +83,10 @@ class TestRFTools(unittest.TestCase):
|
|||
complex(52, 260))
|
||||
|
||||
def test_impedance_to_capacity(self):
|
||||
self.assertEqual(impedance_to_capacity(0, 0), -math.inf)
|
||||
self.assertEqual(impedance_to_capacity(0, 10), math.inf)
|
||||
self.assertEqual(impedance_to_capacitance(0, 0), -math.inf)
|
||||
self.assertEqual(impedance_to_capacitance(0, 10), math.inf)
|
||||
self.assertAlmostEqual(
|
||||
impedance_to_capacity(complex(50, 159.1549), 100000),
|
||||
impedance_to_capacitance(complex(50, 159.1549), 100000),
|
||||
1e-8)
|
||||
|
||||
def test_impedance_to_inductance(self):
|
||||
|
|
Ładowanie…
Reference in New Issue