Beispiel #1
0
class PowSweepWidget(QWidget):
    def __init__(self, parent=None, controller=None):
        super().__init__(parent=parent)
        self._controller = controller

        self._ui = uic.loadUi('powsweepwidget.ui', self)

        self._plot = PlotWidget(parent=None, toolbar=True)
        # self._ui.verticalLayout.addWidget(self._plot)
        self._ui.btnPowSweep.hide()

        self._init()

    def _init(self):
        self._plot.set_title('Прогон по мощности')
        self._plot.set_xlabel('F, GHz', labelpad=-2)
        self._plot.set_ylabel('Pow, dB', labelpad=-2)
        self._plot.set_xlim(4, 8)
        # self._plot.set_ylim(pars['ylim'][0], pars['ylim'][1])
        self._plot.grid(b=True, which='major', color='0.5', linestyle='-')
        self._plot.tight_layout()

    @pyqtSlot()
    def on_btnPowSweep_clicked(self):
        freqs, amps = self._controller.pow_sweep()
        self._plot.clear()
        self._init()

        self._plot.plot(freqs, amps)
Beispiel #2
0
class PhasePlotWidget(QWidget):
    def __init__(self, parent=None, domain=None):
        super().__init__(parent)

        self._domain = domain

        self._plot = PlotWidget(parent=None, toolbar=True)

        self._layout = QVBoxLayout()
        self._layout.addWidget(self._plot)

        self.setLayout(self._layout)

        self._title = ''
        self._stats = list()

        self._init()

    def _init(self):
        self._plot.set_title(self._title)
        self._plot.set_xlabel('Offset frequency, Hz')
        self._plot.set_ylabel('Phase noise, dBc/Hz')
        self._plot.set_xscale('log')
        # self._plot.set_xlim(pars['xlim'][0], pars['xlim'][1])
        # self._plot.set_ylim(pars['ylim'][0], pars['ylim'][1])
        self._plot.grid(b=True, which='major', color='0.5', linestyle='--')

    def clear(self):
        self._plot.clear()

    def plot(self):
        legend = [
            Line2D([0], [0], color='0.2', linestyle='-', label=lbl)
            for lbl in self._stats
        ]
        self._plot.clear()
        self._init()
        self._plot.legend(handles=legend)
        self._plot.plot(self._domain.xs, self._domain.ys)
        self._plot.plot(self._domain.xs, self._domain.smoothYs)

    def addMarkers(self, markers):
        for marker in markers:
            self._plot.axvline(marker,
                               0,
                               1,
                               linewidth=0.8,
                               color='0.3',
                               linestyle='-')

    def tightLayout(self):
        self._plot.tight_layout()