kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
Make vswr a datapoint property
rodzic
f6d614b247
commit
b52fa930a6
|
@ -1030,7 +1030,7 @@ class SimplePeakSearchAnalysis(Analysis):
|
||||||
suffix = ""
|
suffix = ""
|
||||||
data = []
|
data = []
|
||||||
for d in self.app.data:
|
for d in self.app.data:
|
||||||
data.append(d.as_vswr())
|
data.append(d.vswr)
|
||||||
elif self.rbtn_data_resistance.isChecked():
|
elif self.rbtn_data_resistance.isChecked():
|
||||||
suffix = " \N{OHM SIGN}"
|
suffix = " \N{OHM SIGN}"
|
||||||
data = []
|
data = []
|
||||||
|
@ -1134,7 +1134,7 @@ class PeakSearchAnalysis(Analysis):
|
||||||
if self.rbtn_data_vswr.isChecked():
|
if self.rbtn_data_vswr.isChecked():
|
||||||
data = []
|
data = []
|
||||||
for d in self.app.data:
|
for d in self.app.data:
|
||||||
data.append(d.as_vswr())
|
data.append(d.vswr)
|
||||||
elif self.rbtn_data_s21_gain.isChecked():
|
elif self.rbtn_data_s21_gain.isChecked():
|
||||||
data = []
|
data = []
|
||||||
for d in self.app.data21:
|
for d in self.app.data21:
|
||||||
|
@ -1225,7 +1225,7 @@ class VSWRAnalysis(Analysis):
|
||||||
max_dips_shown = 3
|
max_dips_shown = 3
|
||||||
data = []
|
data = []
|
||||||
for d in self.app.data:
|
for d in self.app.data:
|
||||||
data.append(d.as_vswr())
|
data.append(d.vswr)
|
||||||
# min_idx = np.argmin(data)
|
# min_idx = np.argmin(data)
|
||||||
#
|
#
|
||||||
# logger.debug("Minimum at %d", min_idx)
|
# logger.debug("Minimum at %d", min_idx)
|
||||||
|
|
|
@ -1054,7 +1054,7 @@ class VSWRChart(FrequencyChart):
|
||||||
minVSWR = 1
|
minVSWR = 1
|
||||||
maxVSWR = 3
|
maxVSWR = 3
|
||||||
for d in self.data:
|
for d in self.data:
|
||||||
vswr = d.as_vswr()
|
vswr = d.vswr
|
||||||
if vswr > maxVSWR:
|
if vswr > maxVSWR:
|
||||||
maxVSWR = vswr
|
maxVSWR = vswr
|
||||||
maxVSWR = min(self.maxDisplayValue, math.ceil(maxVSWR))
|
maxVSWR = min(self.maxDisplayValue, math.ceil(maxVSWR))
|
||||||
|
@ -1136,7 +1136,7 @@ class VSWRChart(FrequencyChart):
|
||||||
return self.topMargin + round((self.maxVSWR - vswr) / self.span * self.chartHeight)
|
return self.topMargin + round((self.maxVSWR - vswr) / self.span * self.chartHeight)
|
||||||
|
|
||||||
def getYPosition(self, d: Datapoint) -> int:
|
def getYPosition(self, d: Datapoint) -> int:
|
||||||
return self.getYPositionFromValue(d.as_vswr())
|
return self.getYPositionFromValue(d.vswr)
|
||||||
|
|
||||||
def valueAtPosition(self, y) -> List[float]:
|
def valueAtPosition(self, y) -> List[float]:
|
||||||
absy = y - self.topMargin
|
absy = y - self.topMargin
|
||||||
|
|
|
@ -307,7 +307,7 @@ class Marker(QtCore.QObject):
|
||||||
def updateLabels(self, s11data: List[Datapoint], s21data: List[Datapoint]):
|
def updateLabels(self, s11data: List[Datapoint], s21data: List[Datapoint]):
|
||||||
if self.location != -1:
|
if self.location != -1:
|
||||||
re50, im50 = RFTools.normalize50(s11data[self.location])
|
re50, im50 = RFTools.normalize50(s11data[self.location])
|
||||||
vswr = s11data[self.location].as_vswr()
|
vswr = s11data[self.location].vswr
|
||||||
if re50 > 0:
|
if re50 > 0:
|
||||||
rp = (re50 ** 2 + im50 ** 2) / re50
|
rp = (re50 ** 2 + im50 ** 2) / re50
|
||||||
rp = round(rp, 3 - max(0, math.floor(math.log10(abs(rp)))))
|
rp = round(rp, 3 - max(0, math.floor(math.log10(abs(rp)))))
|
||||||
|
|
|
@ -750,7 +750,7 @@ class NanoVNASaver(QtWidgets.QWidget):
|
||||||
min_vswr = 100
|
min_vswr = 100
|
||||||
min_vswr_freq = -1
|
min_vswr_freq = -1
|
||||||
for d in self.data:
|
for d in self.data:
|
||||||
vswr = d.as_vswr()
|
vswr = d.vswr
|
||||||
if min_vswr > vswr > 0:
|
if min_vswr > vswr > 0:
|
||||||
min_vswr = vswr
|
min_vswr = vswr
|
||||||
min_vswr_freq = d.freq
|
min_vswr_freq = d.freq
|
||||||
|
|
|
@ -51,8 +51,9 @@ class Datapoint(NamedTuple):
|
||||||
if mag > 0:
|
if mag > 0:
|
||||||
return 20 * math.log10(mag)
|
return 20 * math.log10(mag)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def as_vswr(self) -> float:
|
@property
|
||||||
|
def vswr(self) -> float:
|
||||||
mag = abs(self.z)
|
mag = abs(self.z)
|
||||||
if mag == 1:
|
if mag == 1:
|
||||||
return 1
|
return 1
|
||||||
|
|
Ładowanie…
Reference in New Issue