util improvements
All checks were successful
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Build distribution 📦 (push) Successful in -41s
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to PyPI (push) Has been skipped

This commit is contained in:
Brendan Haines 2024-12-18 23:38:45 -07:00
parent eca933ccef
commit 67a1864837
2 changed files with 11 additions and 5 deletions

View File

@ -23,6 +23,7 @@ from PySide6.QtWidgets import (
QWidget, QWidget,
) )
from skrf import plotting as rf_plt from skrf import plotting as rf_plt
from util import db20, s2vswr
from vna import Charon from vna import Charon
DEFAULT_CONFIG = dict( DEFAULT_CONFIG = dict(
@ -76,7 +77,7 @@ class PlotWidget(QWidget):
self.ax.set_ylabel("Amplitude [dB]") self.ax.set_ylabel("Amplitude [dB]")
def update_logmag(self, data: xr.DataArray) -> None: def update_logmag(self, data: xr.DataArray) -> None:
self.update_rect(data, lambda s: 20 * np.log10(np.abs(s))) self.update_rect(data, db20)
def setup_phase(self) -> None: def setup_phase(self) -> None:
self.setup_rect() self.setup_rect()
@ -93,7 +94,7 @@ class PlotWidget(QWidget):
self.ax.set_ylabel("VSWR") self.ax.set_ylabel("VSWR")
def update_vswr(self, data: xr.DataArray) -> None: def update_vswr(self, data: xr.DataArray) -> None:
self.update_rect(data, lambda s: (1 + np.abs(s)) / (1 - np.abs(s))) self.update_rect(data, s2vswr)
def setup_smith(self) -> None: def setup_smith(self) -> None:
self.ax.grid(False) self.ax.grid(False)

View File

@ -1,6 +1,7 @@
import numpy as np import numpy as np
import skrf as rf import skrf as rf
import xarray as xr import xarray as xr
from numpy import typing as npt
HAM_BANDS = [ HAM_BANDS = [
[135.7e3, 137.8e3], [135.7e3, 137.8e3],
@ -37,12 +38,16 @@ HAM_BANDS = [
] ]
def db10(p): def db10(p: npt.ArrayLike[np.complex128]) -> npt.ArrayLike[float]:
return 10 * np.log10(np.abs(p)) return 10 * np.log10(np.abs(p))
def db20(p): def db20(v: npt.ArrayLike[np.complex128]) -> npt.ArrayLike[float]:
return 20 * np.log10(np.abs(p)) return 20 * np.log10(np.abs(v))
def s2vswr(s: npt.ArrayLike[np.complex128]) -> npt.ArrayLike[float]:
return (1 + np.abs(s)) / (1 - np.abs(s))
def minmax(x): def minmax(x):