Exemple #1
0
class Schnitt(Canvas):
    def __init__(self, gui, titel, beschriftung):
        """
        :type gui: Module.Gui.Gui
        :type titel: str
        :type beschriftung: Module.Sonstige.Achsenbeschriftung
        """
        Canvas.__init__(self, gui, titel)
        vertikal = QtGui.QVBoxLayout()
        self.centralWidget().setLayout(vertikal)
        horizontal = QtGui.QHBoxLayout()
        vertikal.addLayout(horizontal)
        label = QtGui.QLabel(canvas_zeile[lang])
        sp = QtGui.QSizePolicy()
        sp.setHorizontalPolicy(sp.Maximum)
        label.setSizePolicy(sp)
        horizontal.addWidget(label)
        self.zeile = QtGui.QSpinBox()
        self.zeile.setMinimum(1)
        self.zeile.setMaximum(1)
        horizontal.addWidget(self.zeile)
        self.zeile.valueChanged.connect(self.aktualisiere)

        self.plotter = Plotter(self, beschriftung)
        vertikal.addWidget(self.plotter)

    @staticmethod
    def str_status(x, y):
        """
        :type x: int
        :type y: int
        """
        return str(int(x) + 1) + " | " + str(y)

    def set_werte(self, neu):
        """
        :type neu: Module.Ergebnis.FitWerte
        """
        self.zeile.setMaximum(self.gui.fit.par.pixel)
        Canvas.set_werte(self, neu)

    def aktualisiere(self):
        if self._werte is not None:
            self.plotter.axes.plot(
                range(self.gui.fit.par.pixel),
                self._werte.normal[self.zeile.value() + 1],
                antialiased=True
            )
            self.plotter.draw()
    def __init__(self, gui, titel, beschriftung):
        """
        :type gui: Module.Gui.Gui
        :type titel: str
        :type beschriftung: Module.Sonstige.Achsenbeschriftung
        """
        Canvas.__init__(self, gui, titel)
        vertikal = QtGui.QVBoxLayout()
        self.centralWidget().setLayout(vertikal)
        horizontal = QtGui.QHBoxLayout()
        vertikal.addLayout(horizontal)
        sp = QtGui.QSizePolicy()
        sp.setHorizontalPolicy(sp.Maximum)
        text = [canvas_zeile[lang], canvas_spalte[lang]]
        self.koord = [QtGui.QSpinBox(), QtGui.QSpinBox()]
        for k in range(2):
            label = QtGui.QLabel(text[k])
            label.setSizePolicy(sp)
            horizontal.addWidget(label)
            self.koord[k].setMinimum(1)
            self.koord[k].setMaximum(1)
            horizontal.addWidget(self.koord[k])
            self.koord[k].valueChanged.connect(self.aktualisiere)

        self.plotter = Plotter(self, beschriftung)
        vertikal.addWidget(self.plotter)
Exemple #3
0
    def __init__(self, gui, resonanzkurve, titel, beschriftung):
        """
        :type gui: Module.Gui.Gui
        :type resonanzkurve: Module.Resonanzkurve.Resonanzkurve
        :type titel: str
        :type beschriftung: Module.Sonstige.Achsenbeschriftung
        """
        Canvas.__init__(self, gui, titel)
        self.resonanzkurve = resonanzkurve
        vertikal = QtGui.QVBoxLayout()
        self.centralWidget().setLayout(vertikal)
        horizontal = QtGui.QHBoxLayout()
        vertikal.addLayout(horizontal)

        label = QtGui.QLabel(raster_bereich[lang])
        horizontal.addWidget(label)

        self.box_min = QtGui.QDoubleSpinBox()
        self.box_min.setMinimum(-sys.float_info.max)
        genauigkeit(self.box_min)
        horizontal.addWidget(self.box_min)

        self.box_max = QtGui.QDoubleSpinBox()
        self.box_max.setMaximum(sys.float_info.max)
        genauigkeit(self.box_max)
        horizontal.addWidget(self.box_max)

        self.box_fehler = QtGui.QCheckBox(raster_fehler[lang])
        horizontal.addWidget(self.box_fehler)

        self.box_prozentual = QtGui.QCheckBox(raster_prozent[lang])
        self.box_prozentual.setEnabled(False)
        horizontal.addWidget(self.box_prozentual)
        horizontal.addItem(QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum))

        self.box_min.valueChanged.connect(self.aktualisiere)
        self.box_max.valueChanged.connect(self.aktualisiere)
        self.box_fehler.clicked.connect(self.akt_fehler)
        self.box_prozentual.clicked.connect(self.aktualisiere)

        self.plotter = Plotter(self, beschriftung)
        vertikal.addWidget(self.plotter)
        self.plotter.mpl_connect("button_press_event", self.maus_press)
    def __init__(self, gui, titel, beschriftung):
        """
        :type gui: Module.Gui.Gui
        :type titel: str
        :type beschriftung: Module.Sonstige.Achsenbeschriftung
        """
        Canvas.__init__(self, gui, titel)
        vertikal = QtGui.QVBoxLayout()
        self.centralWidget().setLayout(vertikal)

        self.plotter = Plotter(self, beschriftung)
        vertikal.addWidget(self.plotter)

        horizontal = QtGui.QHBoxLayout()
        vertikal.addLayout(horizontal)
        sp = QtGui.QSizePolicy()
        sp.setHorizontalPolicy(sp.Maximum)

        def neue_cbox(text):
            """
            :param text: Beschriftung vor der Auswahlbox
            :type text: str
            """
            cbox = QtGui.QComboBox()
            label = QtGui.QLabel(text)
            label.setSizePolicy(sp)
            horizontal.addWidget(label)
            horizontal.addWidget(cbox)
            cbox.currentIndexChanged.connect(self.aktualisiere)
            return cbox

        self.box_omega = neue_cbox(wahl_omega[lang])
        self.box_ac = neue_cbox(wahl_ac[lang])
        self.box_dc = neue_cbox(wahl_dc[lang])

        self.box_omega.value = lambda: int(self.box_omega.currentText())
        self.box_ac.value = lambda: float(self.box_ac.currentText())
        self.box_dc.value = lambda: float(self.box_dc.currentText())

        self.gesperrt = False
class Resonanzkurve(Canvas):
    def __init__(self, gui, titel, beschriftung):
        """
        :type gui: Module.Gui.Gui
        :type titel: str
        :type beschriftung: Module.Sonstige.Achsenbeschriftung
        """
        Canvas.__init__(self, gui, titel)
        vertikal = QtGui.QVBoxLayout()
        self.centralWidget().setLayout(vertikal)

        self.plotter = Plotter(self, beschriftung)
        vertikal.addWidget(self.plotter)

        horizontal = QtGui.QHBoxLayout()
        vertikal.addLayout(horizontal)
        sp = QtGui.QSizePolicy()
        sp.setHorizontalPolicy(sp.Maximum)

        def neue_cbox(text):
            """
            :param text: Beschriftung vor der Auswahlbox
            :type text: str
            """
            cbox = QtGui.QComboBox()
            label = QtGui.QLabel(text)
            label.setSizePolicy(sp)
            horizontal.addWidget(label)
            horizontal.addWidget(cbox)
            cbox.currentIndexChanged.connect(self.aktualisiere)
            return cbox

        self.box_omega = neue_cbox(wahl_omega[lang])
        self.box_ac = neue_cbox(wahl_ac[lang])
        self.box_dc = neue_cbox(wahl_dc[lang])

        self.box_omega.value = lambda: int(self.box_omega.currentText())
        self.box_ac.value = lambda: float(self.box_ac.currentText())
        self.box_dc.value = lambda: float(self.box_dc.currentText())

        self.gesperrt = False

    @staticmethod
    def str_status(x, y):
        """
        :type x: float
        :type y: float
        """
        return str(x) + " | " + str(y)

    def set_werte(self, neu):
        """
        :type neu: Spektroskopie.Messwerte.Messwerte
        """
        self.gesperrt = True
        self.box_omega.clear()
        self.box_omega.addItems(neu.str_omegas())
        self.box_ac.clear()
        self.box_ac.addItems(neu.str_acs(self.box_omega.value()))
        self.box_dc.clear()
        self.box_dc.addItems(neu.str_dcs(self.box_omega.value(), self.box_ac.value()))
        self._werte = neu  # Kein super-Aufruf, weil _werte hier streng genommen einen anderen Typ hat
        self.gesperrt = False
        self.aktualisiere()

    def aktualisiere(self):
        if self._werte is not None and not self.gesperrt:
            ac = self._werte.omega(self.box_omega.value()).ac(self.box_ac.value())
            dc = ac.dc.index(self.box_dc.value())
            self.plotter.axes.plot(
                self._werte.frequenzen,
                ac.amp_freq[dc],
                antialiased=True
            )
            self.plotter.draw()
class Resonanzkurve(Canvas):
    def __init__(self, gui, titel, beschriftung):
        """
        :type gui: Module.Gui.Gui
        :type titel: str
        :type beschriftung: Module.Sonstige.Achsenbeschriftung
        """
        Canvas.__init__(self, gui, titel)
        vertikal = QtGui.QVBoxLayout()
        self.centralWidget().setLayout(vertikal)
        horizontal = QtGui.QHBoxLayout()
        vertikal.addLayout(horizontal)
        sp = QtGui.QSizePolicy()
        sp.setHorizontalPolicy(sp.Maximum)
        text = [canvas_zeile[lang], canvas_spalte[lang]]
        self.koord = [QtGui.QSpinBox(), QtGui.QSpinBox()]
        for k in range(2):
            label = QtGui.QLabel(text[k])
            label.setSizePolicy(sp)
            horizontal.addWidget(label)
            self.koord[k].setMinimum(1)
            self.koord[k].setMaximum(1)
            horizontal.addWidget(self.koord[k])
            self.koord[k].valueChanged.connect(self.aktualisiere)

        self.plotter = Plotter(self, beschriftung)
        vertikal.addWidget(self.plotter)

    @staticmethod
    def str_status(x, y):
        """
        :type x: float
        :type y: float
        """
        return str(x) + " | " + str(y)

    def set_werte(self, neu):
        """
        :type neu: numpy.multiarray.ndarray
        """
        for spin in self.koord:
            spin.setMaximum(self.gui.fit.par.pixel)
        self._werte = neu  # Kein super-Aufruf, weil _werte hier streng genommen einen anderen Typ hat
        self.aktualisiere()

    def aktualisiere(self):
        if self._werte is not None:
            x = self.koord[0].value()
            y = self.koord[1].value()
            # Nur x,y wird betrachtet, aber es sind in dieser Liste alle Messpunkte pro Ort hintereinander
            par = self.gui.fit.par
            x_von = (x + 1) * par.messpunkte
            x_bis = x_von + par.messpunkte
            frequenzen = np.arange(  # Frequenz auf der x-Achse
                start=par.fmin,
                stop=par.fmax,
                step=(par.fmax - par.fmin) / par.messpunkte
            )
            self.plotter.axes.plot(
                frequenzen,
                self._werte[y + 1][x_von:x_bis],
                antialiased=True
            )
            try:
                fit = self.gui.fit
                """ :type: Module.Raster.Fit.Fit """
                self.plotter.axes.plot(
                    frequenzen,
                    [resonance_lorentz(
                        frequenzen[n],
                        fit.erg.resfreq.normal[y, x],
                        fit.erg.amp.normal[y, x],
                        fit.erg.q.normal[y, x],
                        fit.offset[y, x]
                    ) for n in range(len(frequenzen))],
                    antialiased=True
                )
            except AttributeError:
                """ Fit noch nicht fertig """
            self.plotter.draw()
Exemple #7
0
class Raster(Canvas):
    def __init__(self, gui, resonanzkurve, titel, beschriftung):
        """
        :type gui: Module.Gui.Gui
        :type resonanzkurve: Module.Resonanzkurve.Resonanzkurve
        :type titel: str
        :type beschriftung: Module.Sonstige.Achsenbeschriftung
        """
        Canvas.__init__(self, gui, titel)
        self.resonanzkurve = resonanzkurve
        vertikal = QtGui.QVBoxLayout()
        self.centralWidget().setLayout(vertikal)
        horizontal = QtGui.QHBoxLayout()
        vertikal.addLayout(horizontal)

        label = QtGui.QLabel(raster_bereich[lang])
        horizontal.addWidget(label)

        self.box_min = QtGui.QDoubleSpinBox()
        self.box_min.setMinimum(-sys.float_info.max)
        genauigkeit(self.box_min)
        horizontal.addWidget(self.box_min)

        self.box_max = QtGui.QDoubleSpinBox()
        self.box_max.setMaximum(sys.float_info.max)
        genauigkeit(self.box_max)
        horizontal.addWidget(self.box_max)

        self.box_fehler = QtGui.QCheckBox(raster_fehler[lang])
        horizontal.addWidget(self.box_fehler)

        self.box_prozentual = QtGui.QCheckBox(raster_prozent[lang])
        self.box_prozentual.setEnabled(False)
        horizontal.addWidget(self.box_prozentual)
        horizontal.addItem(QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum))

        self.box_min.valueChanged.connect(self.aktualisiere)
        self.box_max.valueChanged.connect(self.aktualisiere)
        self.box_fehler.clicked.connect(self.akt_fehler)
        self.box_prozentual.clicked.connect(self.aktualisiere)

        self.plotter = Plotter(self, beschriftung)
        vertikal.addWidget(self.plotter)
        self.plotter.mpl_connect("button_press_event", self.maus_press)

    def resizeEvent(self, event):
        """
        :type event: QtGui.QResizeEvent
        """
        # TODO
        pass

    def maus_press(self, event):
        """
        :type event: matplotlib.backend_bases.MouseEvent
        """
        if event.inaxes:
            self.resonanzkurve.koord[0].setValue(int(event.xdata))
            self.resonanzkurve.koord[1].setValue(int(event.ydata))
            self.resonanzkurve.zeige()

    @staticmethod
    def str_status(x, y):
        """
        :type x: int
        :type y: int
        """
        return str(int(x) + 1) + " | " + str(int(y) + 1)

    def set_werte(self, neu):
        """
        :type neu: Module.Ergebnis.FitWerte
        """
        self.box_min.setValue(neu.normal_min)
        self.box_max.setValue(neu.normal_max)
        Canvas.set_werte(self, neu)

    def akt_fehler(self):
        self.box_prozentual.setEnabled(self.box_fehler.isChecked())
        self.aktualisiere()

    def aktualisiere(self):
        if self._werte is not None:
            if False:  # TODO
                plot = self.plotter.axes.imshow
            else:
                plot = self.plotter.axes.matshow

            if self.box_fehler.isChecked():
                if self.box_prozentual.isChecked():
                    grafik = plot(self._werte.fehler_prozent, vmin=0, vmax=100)
                else:
                    grafik = plot(self._werte.fehler, vmin=self._werte.fehler_min, vmax=self._werte.fehler_max)
            else:
                grafik = plot(self._werte.normal, vmin=self.box_min.value(), vmax=self.box_max.value(), cmap='hot')

            self.plotter.mit_skala(grafik)