Skip to content

Commit

Permalink
- More handling of weird values
Browse files Browse the repository at this point in the history
- Draw lines heading out the bottom of charts in a reasonable manner
  • Loading branch information
mihtjel committed Oct 1, 2019
1 parent 0d46ab6 commit dab83fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions NanoVNASaver/Chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ def getPlotable(self, x, y, distantx, distanty):
if distanty < self.topMargin:
p3 = np.array([self.leftMargin, self.topMargin])
p4 = np.array([self.leftMargin + self.chartWidth, self.topMargin])
elif distanty > self.topMargin + self.chartHeight:
p3 = np.array([self.leftMargin, self.topMargin + self.chartHeight])
p4 = np.array([self.leftMargin + self.chartWidth, self.topMargin + self.chartHeight])
else:
return x, y
da = p2 - p1
Expand Down
16 changes: 8 additions & 8 deletions NanoVNASaver/Marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,22 @@ def updateLabels(self, s11data: List[Datapoint], s21data: List[Datapoint]):
if re50 > 0:
rp = (re50 ** 2 + im50 ** 2) / re50
rp = round(rp, 4 - max(0, math.floor(math.log10(abs(rp)))))
rpstr = str(rp) + " \N{OHM SIGN}"

re50 = round(re50, 4 - max(0, math.floor(math.log10(abs(re50)))))
else:
rp = 0
rpstr = "- \N{OHM SIGN}"
re50 = 0

if im50 > 0:
xp = (re50 ** 2 + im50 ** 2) / im50
xp = round(xp, 4 - max(0, math.floor(math.log10(abs(xp)))))
if xp < 0:
xpstr = NanoVNASaver.capacitanceEquivalent(xp, s11data[self.location].freq)
else:
xpstr = NanoVNASaver.inductanceEquivalent(xp, s11data[self.location].freq)
else:
xp = 0
xpstr = "- \N{OHM SIGN}"

if im50 != 0:
im50 = round(im50, 4 - max(0, math.floor(math.log10(abs(im50)))))
Expand All @@ -192,14 +197,9 @@ def updateLabels(self, s11data: List[Datapoint], s21data: List[Datapoint]):
im50str = " +j" + str(im50)
im50str += " \N{OHM SIGN}"

if xp < 0:
xpstr = NanoVNASaver.capacitanceEquivalent(xp, s11data[self.location].freq)
else:
xpstr = NanoVNASaver.inductanceEquivalent(xp, s11data[self.location].freq)

self.frequency_label.setText(NanoVNASaver.formatFrequency(s11data[self.location].freq))
self.impedance_label.setText(str(re50) + im50str)
self.parallel_r_label.setText(str(rp) + " \N{OHM SIGN}")
self.parallel_r_label.setText(rpstr)
self.parallel_x_label.setText(xpstr)
self.returnloss_label.setText(str(round(NanoVNASaver.gain(s11data[self.location]), 3)) + " dB")
capacitance = NanoVNASaver.capacitanceEquivalent(im50, s11data[self.location].freq)
Expand Down

0 comments on commit dab83fd

Please sign in to comment.