Esempio n. 1
0
def subtractAverage():
    x = np.arange(11) - 5.
    y = np.linspace(0, 10, 51)
    xx, yy = np.meshgrid(x, y, indexing='ij')
    zz = np.sin(yy) + xx
    data = MeshgridDataDict(x=dict(values=xx),
                            y=dict(values=yy),
                            z=dict(values=zz, axes=['x', 'y']))
    data.validate()

    x = np.arange(11) - 5.
    y = np.linspace(0, 10, 51)
    xx, yy = np.meshgrid(x, y, indexing='ij')
    zz = np.sin(yy) + xx
    data2 = MeshgridDataDict(reps=dict(values=xx),
                             y=dict(values=yy),
                             z=dict(values=zz, axes=['reps', 'y']))
    data2.validate()

    # make app and gui, fc
    app = QtGui.QApplication([])
    win, fc = makeFlowchartWithAutoPlotWindow([('sub', SubtractAverage)])
    win.show()

    # feed in data
    fc.setInput(dataIn=data)
    fc.setInput(dataIn=data2)

    return app.exec_()
Esempio n. 2
0
def main():
    app = QtGui.QApplication([])

    # flowchart and window
    nodes = makeNodeList()
    win, fc = makeFlowchartWithPlotWindow(nodes)
    win.show()

    # feed in data
    data = makeData()
    fc.setInput(dataIn=data)

    return app.exec_()
Esempio n. 3
0
def dataSelectionWidget(readonly=False):
    def selectionCb(selection):
        print(selection)

    app = QtGui.QApplication([])
    widget = DataSelectionWidget(readonly=readonly)
    widget.dataSelectionMade.connect(selectionCb)

    # set up the UI, feed data in
    data = testdata.three_incompatible_3d_sets(5, 5, 5)
    dialog = widgetDialog(widget)
    widget.setData(data)
    widget.clear()
    widget.setData(data)
    return app.exec_()
def xySelection(interactive=False):
    if not interactive:
        app = QtGui.QApplication([])

    fc = linearFlowchart(('xysel', XYSelector))
    selector = fc.nodes()['xysel']
    dialog = widgetDialog(selector.ui, 'xysel')

    data = datadict_to_meshgrid(testdata.three_compatible_3d_sets(4, 4, 4))
    fc.setInput(dataIn=data)

    if not interactive:
        app.exec_()
    else:
        return dialog, fc
def dimReduction(interactive=False):
    if not interactive:
        app = QtGui.QApplication([])

    fc = linearFlowchart(('reducer', DimensionReducer))
    reducer = fc.nodes()['reducer']
    dialog = widgetDialog(reducer.ui, 'reducer')

    data = datadict_to_meshgrid(testdata.three_compatible_3d_sets(2, 2, 2))
    fc.setInput(dataIn=data)

    if not interactive:
        app.exec_()
    else:
        return dialog, fc
def xySelectionWidget():
    def selectionCb(selection):
        print(selection)

    app = QtGui.QApplication([])
    widget = XYSelectionWidget()
    widget.rolesChanged.connect(selectionCb)

    # set up the UI, feed data in
    data = datadict_to_meshgrid(testdata.three_compatible_3d_sets(5, 5, 5))
    dialog = widgetDialog(widget)
    widget.setData(data)
    widget.clear()
    widget.setData(data)
    return app.exec_()
Esempio n. 7
0
def simple_2d_plot():
    app = QtGui.QApplication([])
    win = PlotWindow()
    plot = AutoPlot(parent=win)
    win.plot.setPlotWidget(plot)
    win.show()

    # plotting 1d traces
    if False:
        logger.info(f"1D trace")
        t0 = time.perf_counter()
        nsamples = 30
        for i in range(nsamples):
            data = datadict_to_meshgrid(
                testdata.get_1d_scalar_cos_data(201, 2)
            )
            win.plot.setData(data)
        t1 = time.perf_counter()
        fps = nsamples/(t1-t0)
        logger.info(f"Performance: {fps} FPS")

    # plotting images
    if True:
        logger.info(f"2D image")
        t0 = time.perf_counter()
        nsamples = 30
        for i in range(nsamples):
            data = datadict_to_meshgrid(
                testdata.get_2d_scalar_cos_data(201, 101, 1)
            )
            win.plot.setData(data)
        t1 = time.perf_counter()
        fps = nsamples/(t1-t0)
        logger.info(f"Performance: {fps} FPS")

    # plotting 2d scatter
    if False:
        logger.info(f"2D scatter")
        t0 = time.perf_counter()
        nsamples = 30
        for i in range(nsamples):
            data = testdata.get_2d_scalar_cos_data(21, 21, 1)
            win.plot.setData(data)
        t1 = time.perf_counter()
        fps = nsamples/(t1-t0)
        logger.info(f"Performance: {fps} FPS")

    return app.exec_()
Esempio n. 8
0
def loader_node(interactive=False):
    def cb(*vals):
        print(vals)

    if not interactive:
        app = QtGui.QApplication([])

    fc = linearFlowchart(('loader', dds.DDH5Loader))
    loader = fc.nodes()['loader']
    dialog = widgetDialog(loader.ui, 'loader')

    if not interactive:
        loader.newDataStructure.connect(cb)
        app.exec_()
    else:
        return dialog, fc
Esempio n. 9
0
def gridOptionWidget():
    def cb(val):
        print(val)

    app = QtGui.QApplication([])
    widget = GridOptionWidget()
    widget.optionSelected.connect(cb)

    # set up the UI, feed data in
    data = datadict_to_meshgrid(
        testdata.three_compatible_3d_sets(5, 5, 5)
    )
    dialog = widgetDialog(widget)
    widget.setAxes(data.axes())
    widget.setShape(data.shape())

    return app.exec_()
Esempio n. 10
0
def main(pathAndId):
    app = QtGui.QApplication([])

    # flowchart and window
    fc = linearFlowchart(
        ('Dataset loader', QCodesDSLoader),
        ('Data selection', DataSelector),
        ('Grid', DataGridder),
        ('Dimension assignment', XYSelector),
        ('Sine fit', sinefit),
        ('plot', PlotNode),
    )

    win = QCAutoPlotMainWindow(fc, pathAndId=pathAndId)
    win.show()

    return app.exec_()
Esempio n. 11
0
def gridder(interactive=False):
    def cb(val):
        print(val)

    if not interactive:
        app = QtGui.QApplication([])

    fc = linearFlowchart(('grid', DataGridder))
    gridder = fc.nodes()['grid']
    dialog = widgetDialog(gridder.ui, 'gridder')

    data = testdata.three_compatible_3d_sets(2, 2, 2)
    fc.setInput(dataIn=data)

    if not interactive:
        gridder.shapeDetermined.connect(cb)
        app.exec_()
    else:
        return dialog, fc
Esempio n. 12
0
def test_data_selector(interactive=True):
    if not interactive:
        app = QtGui.QApplication([])

    fc = linearFlowchart(('selector', DataSelector))
    selector = fc.nodes()['selector']
    dialog = widgetDialog(selector.ui, 'selector')

    data = testdata.three_incompatible_3d_sets(2, 2, 2)
    fc.setInput(dataIn=data)
    selector.selectedData = ['data']

    # for testing purposes, insert differently structured data
    data2 = testdata.two_compatible_noisy_2d_sets()
    fc.setInput(dataIn=data2)

    # ... and go back.
    fc.setInput(dataIn=data)
    selector.selectedData = ['data']

    if not interactive:
        app.exec_()
    else:
        return dialog, fc
Esempio n. 13
0
def run(func, **kw):
    app = QtGui.QApplication([])
    _ = func(**kw)
    return app.exec_()
Esempio n. 14
0
def main(f, g):
    app = QtGui.QApplication([])
    fc, win = autoplotDDH5(f, g)

    return app.exec_()