コード例 #1
0
    def testFcn(self):
        x = np.linspace(0, 100, 1000)

        y = (np.random.rand(len(x)) - 0.5).cumsum()

        curve = make.curve(x, y, "ab", "b")
        range = make.range(0, 5)

        disp2 = make.computations(
            range,
            "TL",
            [
                (curve, "min=%.5f", lambda x, y: y.min()),
                (curve, "max=%.5f", lambda x, y: y.max()),
                (curve, "avg=%.5f", lambda x, y: y.mean()),
            ],
        )
        legend = make.legend("TR")
        items = [curve, range, disp2, legend]

        win = CurveDialog(edit=False, toolbar=True, parent=self)
        plot = win.get_plot()
        for item in items:
            plot.add_item(item)
        win.show()
コード例 #2
0
ファイル: computations.py プロジェクト: gyenney/Tools
def test():
    """Test"""
    # -- Create QApplication
    import guidata

    _app = guidata.qapplication()
    # --
    from numpy import linspace, sin, trapz

    x = linspace(-10, 10, 1000)
    y = sin(sin(sin(x)))

    curve = make.curve(x, y, "ab", "b")
    range = make.range(-2, 2)
    disp0 = make.range_info_label(range, "BR", "x = %.1f ± %.1f cm", title="Range infos")

    disp1 = make.computation(range, "BL", "trapz=%g", curve, lambda x, y: trapz(y, x))

    disp2 = make.computations(
        range,
        "TL",
        [
            (curve, "min=%.5f", lambda x, y: y.min()),
            (curve, "max=%.5f", lambda x, y: y.max()),
            (curve, "avg=%.5f", lambda x, y: y.mean()),
        ],
    )
    legend = make.legend("TR")
    plot(curve, range, disp0, disp1, disp2, legend)
コード例 #3
0
ファイル: computations.py プロジェクト: PierreRaybaut/guiqwt
def test():
    """Test"""
    # -- Create QApplication
    import guidata

    _app = guidata.qapplication()
    # --
    from numpy import linspace, sin, trapz

    x = linspace(-10, 10, 1000)
    y = sin(sin(sin(x)))

    curve = make.curve(x, y, "ab", "b")
    range = make.range(-2, 2)
    disp0 = make.range_info_label(range,
                                  "BR",
                                  "x = %.1f ± %.1f cm",
                                  title="Range infos")

    disp1 = make.computation(range, "BL", "trapz=%g", curve,
                             lambda x, y: trapz(y, x))

    disp2 = make.computations(
        range,
        "TL",
        [
            (curve, "min=%.5f", lambda x, y: y.min()),
            (curve, "max=%.5f", lambda x, y: y.max()),
            (curve, "avg=%.5f", lambda x, y: y.mean()),
        ],
    )
    legend = make.legend("TR")
    plot(curve, range, disp0, disp1, disp2, legend)
コード例 #4
0
    def testFcn(self):
        x = np.linspace(0, 100, 1000)

        y = (np.random.rand(len(x)) - 0.5).cumsum()

        curve = make.curve(x, y, "ab", "b")
        range = make.range(0, 5)

        disp2 = make.computations(range, "TL",
                                  [(curve, "min=%.5f", lambda x, y: y.min()),
                                   (curve, "max=%.5f", lambda x, y: y.max()),
                                   (curve, "avg=%.5f", lambda x, y: y.mean())])
        legend = make.legend("TR")
        items = [curve, range, disp2, legend]

        win = CurveDialog(edit=False, toolbar=True, parent=self)
        plot = win.get_plot()
        for item in items:
            plot.add_item(item)
        win.show()
コード例 #5
0
    def plot(self, pdDataFrame):
        ''' plot some random stuff '''
        x1 = pdDataFrame.index
        y1 = pdDataFrame['Close']
        x = np.linspace(0, 100, 1000)

        y = (np.random.rand(len(x)) - 0.5).cumsum()

        curve = make.curve(x1, y1, "ab", "b")
        range = make.range(0, 5)

        disp2 = make.computations(range, "TL",
                                  [(curve, "min=%.5f", lambda x, y: y.min()),
                                   (curve, "max=%.5f", lambda x, y: y.max()),
                                   (curve, "avg=%.5f", lambda x, y: y.mean())])
        legend = make.legend("TR")
        #        items = [ curve, range, disp2, legend]
        items = [curve]

        self.plotw = self.gWindow.get_plot()
        for item in items:
            self.plotw.add_item(item)
コード例 #6
0
ファイル: response.py プロジェクト: horsje/tril
    def __init__(self, *args):
        super(ResponseDlg, self).__init__(*args)

        self.setupUi(self)

        self.plotWidget.plot.set_axis_limits('left', 0, 2)
        self.plotWidget.plot.set_axis_limits('bottom', 1, 400)
        self.plotWidget.plot.set_axis_title('bottom', 'freq [Hz]')
        self.plotWidget.plot.set_axis_scale('bottom', 'log')
        self.plotWidget.register_all_curve_tools()

        self.resultTrace = make.curve([], [], 'Spectrum', color='b')
        self.plotWidget.plot.add_item(self.resultTrace)
        self.upper_limit = make.curve([], [], 'UL', color='r')
        self.plotWidget.plot.add_item(self.upper_limit)
        self.lower_limit = make.curve([], [], 'LL', color='r')
        self.plotWidget.plot.add_item(self.lower_limit)

        self.rng = make.range(0, 0)
        self.math = make.computations(self.rng, "TR",
                             [(self.resultTrace, "total=%.2f", lambda x, y: (y**2).sum()**.5)])
        self.plotWidget.plot.add_item(self.rng)
        self.plotWidget.plot.add_item(self.math)
        self.hide_total_range()