Esempio n. 1
0
    def updateLabels(self, s11: List[RFTools.Datapoint],
                     s21: List[RFTools.Datapoint]):
        if not s11:
            return
        if self.location == -1:  # initial position
            try:
                location = (self.index - 1) / (self._instances -
                                               1) * (len(s11) - 1)
                self.location = int(location)
            except ZeroDivisionError:
                self.location = 0
        try:
            _s11 = s11[self.location]
        except IndexError:
            self.location = 0
            return

        self.frequencyInput.setText(_s11.freq)
        self.store(self.location, s11, s21)

        imp = _s11.impedance()
        cap_str = format_capacitance(
            RFTools.impedance_to_capacitance(imp, _s11.freq))
        ind_str = format_inductance(
            RFTools.impedance_to_inductance(imp, _s11.freq))

        imp_p = RFTools.serial_to_parallel(imp)
        cap_p_str = format_capacitance(
            RFTools.impedance_to_capacitance(imp_p, _s11.freq))
        ind_p_str = format_inductance(
            RFTools.impedance_to_inductance(imp_p, _s11.freq))

        x_str = cap_str if imp.imag < 0 else ind_str
        x_p_str = cap_p_str if imp_p.imag < 0 else 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_adm(imp))
        self.label['impedance'].setText(format_complex_imp(imp))
        self.label['parc'].setText(cap_p_str)
        self.label['parl'].setText(ind_p_str)
        self.label['parlc'].setText(x_p_str)
        self.label['parr'].setText(format_resistance(imp_p.real))
        self.label['returnloss'].setText(
            format_gain(_s11.gain, self.returnloss_is_positive))
        self.label['s11groupdelay'].setText(
            format_group_delay(RFTools.groupDelay(s11, self.location)))
        self.label['s11mag'].setText(format_magnitude(abs(_s11.z)))
        self.label['s11phase'].setText(format_phase(_s11.phase))
        self.label['s11polar'].setText(
            f'{str(round(abs(_s11.z), 2))}∠{format_phase(_s11.phase)}')

        self.label['s11q'].setText(format_q_factor(_s11.qFactor()))
        self.label['s11z'].setText(format_resistance(abs(imp)))
        self.label['serc'].setText(cap_str)
        self.label['serl'].setText(ind_str)
        self.label['serlc'].setText(x_str)
        self.label['serr'].setText(format_resistance(imp.real))
        self.label['vswr'].setText(format_vswr(_s11.vswr))

        if len(s21) == len(s11):
            _s21 = s21[self.location]
            self.label['s21gain'].setText(format_gain(_s21.gain))
            self.label['s21groupdelay'].setText(
                format_group_delay(RFTools.groupDelay(s21, self.location) / 2))
            self.label['s21mag'].setText(format_magnitude(abs(_s21.z)))
            self.label['s21phase'].setText(format_phase(_s21.phase))
            self.label['s21polar'].setText(
                f'{str(round(abs(_s21.z), 2))}∠{format_phase(_s21.phase)}')

            self.label['s21magshunt'].setText(
                format_magnitude(abs(_s21.shuntImpedance())))
            self.label['s21magseries'].setText(
                format_magnitude(abs(_s21.seriesImpedance())))
            self.label['s21realimagshunt'].setText(
                format_complex_imp(_s21.shuntImpedance(), allow_negative=True))
            self.label['s21realimagseries'].setText(
                format_complex_imp(_s21.seriesImpedance(),
                                   allow_negative=True))
Esempio n. 2
0
    def updateLabels(self):  # pylint: disable=arguments-differ
        a = self.marker_a
        b = self.marker_b
        s11_a = a.s11[1]
        s11_b = b.s11[1]

        imp_a = s11_a.impedance()
        imp_b = s11_b.impedance()
        imp = imp_b - imp_a

        cap_str = format_capacitance(
            RFTools.impedance_to_capacitance(imp_b, s11_b.freq) -
            RFTools.impedance_to_capacitance(imp_a, s11_a.freq))
        ind_str = format_inductance(
            RFTools.impedance_to_inductance(imp_b, s11_b.freq) -
            RFTools.impedance_to_inductance(imp_a, s11_a.freq))

        imp_p_a = RFTools.serial_to_parallel(imp_a)
        imp_p_b = RFTools.serial_to_parallel(imp_b)
        imp_p = imp_p_b - imp_p_a

        cap_p_str = format_capacitance(
            RFTools.impedance_to_capacitance(imp_p_b, s11_b.freq) -
            RFTools.impedance_to_capacitance(imp_p_a, s11_a.freq))
        ind_p_str = format_inductance(
            RFTools.impedance_to_inductance(imp_p_b, s11_b.freq) -
            RFTools.impedance_to_inductance(imp_p_a, s11_a.freq))

        if imp.imag < 0:
            x_str = cap_str
        else:
            x_str = ind_str

        if imp_p.imag < 0:
            x_p_str = cap_p_str
        else:
            x_p_str = ind_p_str

        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_adm(imp_p, True))
        self.label['impedance'].setText(format_complex_imp(imp, True))

        self.label['parc'].setText(cap_p_str)
        self.label['parl'].setText(ind_p_str)
        self.label['parlc'].setText(x_p_str)

        self.label['parr'].setText(format_resistance(imp_p.real, True))
        self.label['returnloss'].setText(
            format_gain(s11_b.gain - s11_a.gain, self.returnloss_is_positive))
        self.label['s11groupdelay'].setText(
            format_group_delay(
                RFTools.groupDelay(b.s11, 1) - RFTools.groupDelay(a.s11, 1)))

        self.label['s11mag'].setText(
            format_magnitude(abs(s11_b.z) - abs(s11_a.z)))
        self.label['s11phase'].setText(format_phase(s11_b.phase - s11_a.phase))
        self.label['s11polar'].setText(
            f"{round(abs(s11_b.z) - abs(s11_a.z), 2)}∠"
            f"{format_phase(s11_b.phase - s11_a.phase)}")
        self.label['s11q'].setText(
            format_q_factor(s11_b.qFactor() - s11_a.qFactor(), True))
        self.label['s11z'].setText(format_resistance(abs(imp)))
        self.label['serc'].setText(cap_str)
        self.label['serl'].setText(ind_str)
        self.label['serlc'].setText(x_str)
        self.label['serr'].setText(format_resistance(imp.real, True))
        self.label['vswr'].setText(format_vswr(s11_b.vswr - s11_a.vswr))

        if len(a.s21) == len(a.s11):
            s21_a = a.s21[1]
            s21_b = b.s21[1]
            self.label['s21gain'].setText(format_gain(s21_b.gain - s21_a.gain))
            self.label['s21groupdelay'].setText(
                format_group_delay((RFTools.groupDelay(b.s21, 1) -
                                    RFTools.groupDelay(a.s21, 1)) / 2))
            self.label['s21mag'].setText(
                format_magnitude(abs(s21_b.z) - abs(s21_a.z)))
            self.label['s21phase'].setText(
                format_phase(s21_b.phase - s21_a.phase))
            self.label['s21polar'].setText(
                f"{round(abs(s21_b.z) - abs(s21_a.z) , 2)}∠"
                f"{format_phase(s21_b.phase - s21_a.phase)}")
Esempio n. 3
0
    def updateLabels(self, s11data: List[RFTools.Datapoint],
                     s21data: List[RFTools.Datapoint]):
        try:
            s11 = s11data[self.location]
        except IndexError:
            self.location = 0
            return

        self.store(self.location, s11data, s21data)

        imp = s11.impedance()
        cap_str = format_capacitance(
            RFTools.impedance_to_capacitance(imp, s11.freq))
        ind_str = format_inductance(
            RFTools.impedance_to_inductance(imp, s11.freq))

        imp_p = RFTools.serial_to_parallel(imp)
        cap_p_str = format_capacitance(
            RFTools.impedance_to_capacitance(imp_p, s11.freq))
        ind_p_str = format_inductance(
            RFTools.impedance_to_inductance(imp_p, s11.freq))

        if imp.imag < 0:
            x_str = cap_str
        else:
            x_str = ind_str

        if imp_p.imag < 0:
            x_p_str = cap_p_str
        else:
            x_p_str = ind_p_str

        self.label['actualfreq'].setText(format_frequency_space(s11.freq))
        self.label['admittance'].setText(format_complex_imp(imp_p))
        self.label['impedance'].setText(format_complex_imp(imp))
        self.label['parc'].setText(cap_p_str)
        self.label['parl'].setText(ind_p_str)
        self.label['parlc'].setText(x_p_str)
        self.label['parr'].setText(format_resistance(imp_p.real))
        self.label['returnloss'].setText(
            format_gain(s11.gain, self.returnloss_is_positive))
        self.label['s11groupdelay'].setText(
            format_group_delay(RFTools.groupDelay(s11data, self.location)))
        self.label['s11mag'].setText(format_magnitude(abs(s11.z)))
        self.label['s11phase'].setText(format_phase(s11.phase))
        self.label['s11polar'].setText(
            str(round(abs(s11.z), 2)) + "∠" + format_phase(s11.phase))
        self.label['s11q'].setText(format_q_factor(s11.qFactor()))
        self.label['s11z'].setText(format_resistance(abs(imp)))
        self.label['serc'].setText(cap_str)
        self.label['serl'].setText(ind_str)
        self.label['serlc'].setText(x_str)
        self.label['serr'].setText(format_resistance(imp.real))
        self.label['vswr'].setText(format_vswr(s11.vswr))

        if len(s21data) == len(s11data):
            s21 = s21data[self.location]
            self.label['s21gain'].setText(format_gain(s21.gain))
            self.label['s21groupdelay'].setText(
                format_group_delay(
                    RFTools.groupDelay(s21data, self.location) / 2))
            self.label['s21mag'].setText(format_magnitude(abs(s21.z)))
            self.label['s21phase'].setText(format_phase(s21.phase))
            self.label['s21polar'].setText(
                str(round(abs(s21.z), 2)) + "∠" + format_phase(s21.phase))