refactored phaseAngle methods

pull/96/head
Holger Mueller 2019-11-16 15:33:11 +01:00
rodzic 92d326bd1f
commit 9bb42ffc29
3 zmienionych plików z 8 dodań i 16 usunięć

Wyświetl plik

@ -852,11 +852,11 @@ class PhaseChart(FrequencyChart):
if self.unwrap:
rawData = []
for d in self.data:
rawData.append(RFTools.phaseAngleRadians(d))
rawData.append(d.phase)
rawReference = []
for d in self.reference:
rawReference.append(RFTools.phaseAngleRadians(d))
rawReference.append(d.phase)
self.unwrappedData = np.degrees(np.unwrap(rawData))
self.unwrappedReference = np.degrees(np.unwrap(rawReference))
@ -935,9 +935,9 @@ class PhaseChart(FrequencyChart):
elif d in self.reference:
angle = self.unwrappedReference[self.reference.index(d)]
else:
angle = RFTools.phaseAngle(d)
angle = math.degrees(d.phase)
else:
angle = RFTools.phaseAngle(d)
angle = math.degrees(d.phase)
return self.topMargin + round((self.maxAngle - angle) / self.span * self.chartHeight)
def valueAtPosition(self, y) -> List[float]:
@ -3549,11 +3549,11 @@ class GroupDelayChart(FrequencyChart):
def calculateGroupDelay(self):
rawData = []
for d in self.data:
rawData.append(RFTools.phaseAngleRadians(d))
rawData.append(d.phase)
rawReference = []
for d in self.reference:
rawReference.append(RFTools.phaseAngleRadians(d))
rawReference.append(d.phase)
if len(self.data) > 0:
self.unwrappedData = np.degrees(np.unwrap(rawData))

Wyświetl plik

@ -393,14 +393,14 @@ class Marker(QtCore.QObject):
q_str = str(round(q, 3))
self.quality_factor_label.setText(q_str)
self.s11_phase_label.setText(
str(round(RFTools.phaseAngle(s11data[self.location]), 2)) + "\N{DEGREE SIGN}")
str(round(math.degrees(s11data[self.location].phase), 2)) + "\N{DEGREE SIGN}")
fmt = SITools.Format(max_nr_digits=5, space_str=" ")
self.s11_group_delay_label.setText(str(SITools.Value(RFTools.groupDelay(s11data, self.location), "s", fmt)))
if len(s21data) == len(s11data):
self.gain_label.setText(str(round(RFTools.gain(s21data[self.location]), 3)) + " dB")
self.s21_phase_label.setText(
str(round(RFTools.phaseAngle(s21data[self.location]), 2)) + "\N{DEGREE SIGN}")
str(round(math.degrees(s21data[self.location].phase), 2)) + "\N{DEGREE SIGN}")
self.s21_group_delay_label.setText(str(SITools.Value(RFTools.groupDelay(s21data, self.location) / 2,
"s", fmt)))

Wyświetl plik

@ -136,14 +136,6 @@ class RFTools:
except (ValueError, IndexError):
return -1
@staticmethod
def phaseAngle(data: Datapoint) -> float:
return math.degrees(cmath.phase(data.z))
@staticmethod
def phaseAngleRadians(data: Datapoint) -> float:
return cmath.phase(data.z)
@staticmethod
def groupDelay(data: List[Datapoint], index: int) -> float:
idx0 = clamp_int(index - 1, 0, len(data) - 1)