Added Wavelength to marker fields

pull/282/head
Holger Müller 2020-07-25 20:35:16 +02:00
rodzic 684a01beb4
commit e6d3ea0c12
5 zmienionych plików z 14 dodań i 0 usunięć

Wyświetl plik

@ -36,6 +36,7 @@ FMT_REACT = SITools.Format(max_nr_digits=5, space_str=" ", allow_strip=True)
FMT_COMPLEX = SITools.Format(max_nr_digits=3, allow_strip=True,
printable_min=0, unprintable_under="- ")
FMT_COMPLEX_NEG = SITools.Format(max_nr_digits=3, allow_strip=True)
FMT_WAVELENGTH = SITools.Format(max_nr_digits=4, space_str=" ")
FMT_PARSE = SITools.Format(parse_sloppy_unit=True, parse_sloppy_kilo=True,
parse_clamp_min=0)
@ -114,6 +115,9 @@ def format_complex_imp(z: complex, allow_negative: bool = False) -> str:
im = SITools.Value(abs(z.imag), fmt=FMT_COMPLEX)
return f"{re}{'-' if z.imag < 0 else '+'}j{im} \N{OHM SIGN}"
def format_wavelength(length: Number) -> str:
return str(SITools.Value(length, "m", FMT_WAVELENGTH))
def parse_frequency(freq: str) -> int:
try:

Wyświetl plik

@ -31,6 +31,7 @@ from NanoVNASaver.Formatting import (
format_q_factor,
format_resistance,
format_vswr,
format_wavelength,
)
from .Widget import Marker
@ -87,6 +88,8 @@ class DeltaMarker(Marker):
self.label['actualfreq'].setText(
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['impedance'].setText(format_complex_imp(imp, True))

Wyświetl plik

@ -30,6 +30,7 @@ class Label(NamedTuple):
TYPES = (
Label("actualfreq", "Frequency", "Actual frequency", True),
Label("lambda", "Wavelength", "Wavelength", False),
Label("impedance", "Impedance", "Impedance", True),
Label("admittance", "Admittance", "Admittance", False),
Label("serr", "Series R", "Series R", False),

Wyświetl plik

@ -35,6 +35,7 @@ from NanoVNASaver.Formatting import (
format_q_factor,
format_resistance,
format_vswr,
format_wavelength,
parse_frequency,
)
from NanoVNASaver.Inputs import MarkerFrequencyInputWidget as FrequencyInput
@ -317,6 +318,7 @@ class Marker(QtCore.QObject, Value):
x_p_str = ind_p_str
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['impedance'].setText(format_complex_imp(imp))
self.label['parc'].setText(cap_p_str)

Wyświetl plik

@ -55,6 +55,10 @@ class Datapoint(NamedTuple):
return 1
return (1 + mag) / (1 - mag)
@property
def wavelength(self) -> float:
return 299792458 / self.freq
def impedance(self, ref_impedance: float = 50) -> complex:
return gamma_to_impedance(self.z, ref_impedance)