Ejemplo n.º 1
0
class MainWindow(QtGui.QMainWindow):
    def __init__(self, *args, **kwargs):
        QtGui.QMainWindow.__init__(self, *args, **kwargs)
        self._grw = InteractiveGRWidget()
        self.setCentralWidget(self._grw)

        viewport = [0.1, 0.88, 0.1, 0.88]
        x = arange(0, 2 * pi, 0.01)
        y = sin(x)

        self.curve = PlotCurve(x, y)
        axes = ScaledPlotAxes(viewport)
        axes.addCurves(self.curve)
        plot = Plot(viewport).addAxes(axes)
        plot.title = "QtGR Timer example"
        plot.subTitle = "Plotting Live-Data"
        plot.xlabel = "t"
        plot.ylabel = "sin(t)"
        plot.autoscale = PlotAxes.SCALE_X | PlotAxes.SCALE_Y
        self._grw.addPlot(plot)

        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.updateData)
        timer.start(40)

    def updateData(self):
        self.curve.x += 0.05
        self.curve.y = sin(self.curve.x)
        self.update()
Ejemplo n.º 2
0
class MainWindow(QtGui.QMainWindow):

    def __init__(self, *args, **kwargs):
        QtGui.QMainWindow.__init__(self, *args, **kwargs)
        self._grw = InteractiveGRWidget()
        self.setCentralWidget(self._grw)

        viewport = [0.1, 0.88, 0.1, 0.88]
        x = arange(0, 2 * pi, 0.01)
        y = sin(x)

        self.curve = PlotCurve(x, y)
        axes = ScaledPlotAxes(viewport)
        axes.addCurves(self.curve)
        plot = Plot(viewport).addAxes(axes)
        plot.title = "QtGR Timer example"
        plot.subTitle = "Plotting Live-Data"
        plot.xlabel = "t"
        plot.ylabel = "sin(t)"
        plot.autoscale = PlotAxes.SCALE_X | PlotAxes.SCALE_Y
        self._grw.addPlot(plot)

        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.updateData)
        timer.start(40)

    def updateData(self):
        self.curve.x += 0.05
        self.curve.y = sin(self.curve.x)
        self.update()
Ejemplo n.º 3
0
class MainWindow(QtGui.QMainWindow):

    def __init__(self, *args, **kwargs):
        QtGui.QMainWindow.__init__(self, *args, **kwargs)
        self._grw = InteractiveGRWidget()
        self.setCentralWidget(self._grw)

        viewport = [0.1, 0.88, 0.1, 0.88]

        self.curve = DependentPlotCurve([0], [0], linecolor=4)
        self.peakbars = PeakBars([], [], linecolor=2)
        self.curve.dependent = [self.peakbars]
        axes = ClampedPlotAxes(viewport, 50, 5, 1, 2)
        axes.setWindow(50, 25000, 0, 100)
        axes.addCurves(self.curve)
        plot = Plot(viewport).addAxes(axes)
        plot.title = "QtGR Power Spectrum"
        plot.subTitle = "Capturing Microphone"
        axes.scale = gr.OPTION_X_LOG
        self._grw.addPlot(plot)

        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.updateData)
        timer.start(40)

    def updateData(self):
        power, peakind = None, None
        try:
            power = get_spectrum()
            peakind = signal.find_peaks_cwt(power, numpy.array([5]))
        except IOError:
            return
        else:
            self.peakbars.visible = False
            self.curve.x = F[1:]
            self.curve.y = power[1:]
            self.peakbars.x, self.peakbars.y = [], []
            for p in peakind:
                if power[p] > 10:
                    self.peakbars.visible = True
                    xi, yi = parabolic(F[p], power, p)
                    self.peakbars.x.append(xi)
                    self.peakbars.y.append(yi)
            self.update()
Ejemplo n.º 4
0
    def __init__(self, *args, **kwargs):
        QtGui.QMainWindow.__init__(self, *args, **kwargs)
        self._grw = InteractiveGRWidget()
        self.setCentralWidget(self._grw)

        viewport = [0.1, 0.88, 0.1, 0.88]

        self.curve = DependentPlotCurve([0], [0], linecolor=4)
        self.peakbars = PeakBars([], [], linecolor=2)
        self.curve.dependent = [self.peakbars]
        axes = ClampedPlotAxes(viewport, 50, 5, 1, 2)
        axes.setWindow(50, 25000, 0, 100)
        axes.addCurves(self.curve)
        plot = Plot(viewport).addAxes(axes)
        plot.title = "QtGR Power Spectrum"
        plot.subTitle = "Capturing Microphone"
        axes.scale = gr.OPTION_X_LOG
        self._grw.addPlot(plot)

        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.updateData)
        timer.start(40)
Ejemplo n.º 5
0
def main(*args):
    app = QtGui.QApplication(*args)
    grw = InteractiveGRWidget()
    viewport = [0.1, 0.88, 0.1, 0.88]

    xd = [3, 3, 10, 18, 18, 10, 10, 5, 1, 15, 20, 5, 15, 10, 7, 13, 16]
    yd = [3, 18, 18, 3, 18, 10, 1, 5, 10, 5, 10, 15, 15, 15, 20, 20, 8]
    zd = [25, 25, 25, 25, 25, -5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 25]

    axes = ContourAxes(viewport)
    axes.addCurves(PlotContour(xd, yd, zd, nx=40, ny=40))
    axes.setGrid(False)
    plot = Plot(viewport).addAxes(axes)
    plot.title = "Plot contour lines using QtGR"

    grw.addPlot(plot)
    grw.resize(QtCore.QSize(500, 500))
    grw.show()
    win = axes.getWindow()
    grw.update()

    sys.exit(app.exec_())
Ejemplo n.º 6
0
def main(*args):
    app = QtWidgets.QApplication(*args)
    grw = InteractiveGRWidget()
    viewport = [0.1, 0.88, 0.1, 0.88]

    z = readfile(
        os.path.join(os.path.dirname(os.path.realpath(__file__)), "fecr.dat"))
    zd = np.asarray(z)
    xd = yd = np.arange(1, 201)

    axes = ContourAxes(viewport)
    axes.addCurves(PlotSurface(xd, yd, zd, option=gr.OPTION_CELL_ARRAY))
    axes.addCurves(PlotContour(xd, yd, zd))
    axes.setGrid(False)
    plot = Plot(viewport).addAxes(axes)
    plot.title = "Plot surface and contour lines using QtGR"

    grw.addPlot(plot)
    grw.resize(QtCore.QSize(500, 500))
    grw.show()
    win = axes.getWindow()
    grw.update()

    sys.exit(app.exec_())
Ejemplo n.º 7
0
def main(*args):
    app = QtGui.QApplication(*args)
    grw = InteractiveGRWidget()
    viewport = [0.1, 0.88, 0.1, 0.88]

    xd = [3, 3, 10, 18, 18, 10, 10, 5, 1, 15, 20, 5, 15, 10, 7, 13, 16]
    yd = [3, 18, 18, 3, 18, 10, 1, 5, 10, 5, 10, 15, 15, 15, 20, 20, 8]
    zd = [25, 25, 25, 25, 25, -5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 25]

    axes = ContourAxes(viewport)
    axes.addCurves(PlotContour(xd, yd, zd, nx=40, ny=40))
    axes.setGrid(False)
    plot = Plot(viewport).addAxes(axes)
    plot.title = "Plot contour lines using QtGR"

    grw.addPlot(plot)
    grw.resize(QtCore.QSize(500, 500))
    grw.show()
    win = axes.getWindow()
    grw.update()

    sys.exit(app.exec_())
Ejemplo n.º 8
0
def main(*args):
    app = QtGui.QApplication(*args)
    grw = InteractiveGRWidget()
    viewport = [0.1, 0.88, 0.1, 0.88]

    z = readfile(os.path.join(os.path.dirname(os.path.realpath(__file__)),
                              "fecr.dat"))
    zd = np.asarray(z)
    xd = yd = np.arange(1, 201)

    axes = ContourAxes(viewport)
    axes.addCurves(PlotSurface(xd, yd, zd, option=gr.OPTION_CELL_ARRAY))
    axes.addCurves(PlotContour(xd, yd, zd))
    axes.setGrid(False)
    plot = Plot(viewport).addAxes(axes)
    plot.title = "Plot surface and contour lines using QtGR"

    grw.addPlot(plot)
    grw.resize(QtCore.QSize(500, 500))
    grw.show()
    win = axes.getWindow()
    grw.update()

    sys.exit(app.exec_())