How to use the plottr.data.datadict.datadict_to_meshgrid function in plottr

To help you get started, we’ve selected a few plottr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github data-plottr / plottr / test / gui / simple_2d_plot.py View on Github external
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)
            )
github data-plottr / plottr / test / gui / dimension_assignment.py View on Github external
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
github data-plottr / plottr / test / pytest / test_data_dict.py View on Github external
assert DataDictBase.same_structure(dd, dd2)
    assert num.arrays_equal(dd2.data_vals('a'), aa)
    assert num.arrays_equal(dd2.data_vals('z'), zz)

    # test the case where inner/outer
    aa, bb = np.meshgrid(a, b, indexing='xy')
    zz = aa * bb

    dd = DataDict(
        a=dict(values=aa.reshape(-1)),
        b=dict(values=bb.reshape(-1)),
        z=dict(values=zz.reshape(-1), axes=['a', 'b']),
        __info__='some info',
    )

    dd2 = datadict_to_meshgrid(dd, target_shape=(5, 11),
                               inner_axis_order=['b', 'a'])
    assert DataDictBase.same_structure(dd, dd2)
    assert num.arrays_equal(dd2.data_vals('a'), np.transpose(aa, (1, 0)))
    assert num.arrays_equal(dd2.data_vals('z'), np.transpose(zz, (1, 0)))

    dd2 = datadict_to_meshgrid(dd, target_shape=None)
    assert DataDictBase.same_structure(dd, dd2)
    assert num.arrays_equal(dd2.data_vals('a'), np.transpose(aa, (1, 0)))
    assert num.arrays_equal(dd2.data_vals('z'), np.transpose(zz, (1, 0)))
github data-plottr / plottr / test / gui / dimension_assignment.py View on Github external
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_()
github data-plottr / plottr / test / gui / simple_2d_plot.py View on Github external
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()
github data-plottr / plottr / test / gui / grid_options.py View on Github external
def test_gridOptionWidget():
    def cb(val):
        print(val)

    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({
        'order': ['x', 'y', 'z'],
        'shape': (5,5,5),
    })

    return dialog
github data-plottr / plottr / plottr / node / grid.py View on Github external
data = super().process(**kw)
        if data is None:
            return None
        data = data['dataOut'].copy()
        self.axesList.emit(data.axes())

        dout = None
        method, opts = self._grid

        if isinstance(data, DataDict):
            if method is GridOption.noGrid:
                dout = data.expand()
            elif method is GridOption.guessShape:
                dout = dd.datadict_to_meshgrid(data)
            elif method is GridOption.specifyShape:
                dout = dd.datadict_to_meshgrid(data, target_shape=opts['shape'])

        elif isinstance(data, MeshgridDataDict):
            if method is GridOption.noGrid:
                dout = dd.meshgrid_to_datadict(data)
            elif method is GridOption.guessShape:
                dout = data
            elif method is GridOption.specifyShape:
                self.logger().warning(
                    f"Data is already on grid. Ignore shape.")
                dout = data

        else:
            self.logger().error(
                f"Unknown data type {type(data)}.")
            return None
github data-plottr / plottr / plottr / node / grid.py View on Github external
return None

        data = super().process(**kw)
        if data is None:
            return None
        data = data['dataOut'].copy()
        self.axesList.emit(data.axes())

        dout = None
        method, opts = self._grid

        if isinstance(data, DataDict):
            if method is GridOption.noGrid:
                dout = data.expand()
            elif method is GridOption.guessShape:
                dout = dd.datadict_to_meshgrid(data)
            elif method is GridOption.specifyShape:
                dout = dd.datadict_to_meshgrid(data, target_shape=opts['shape'])

        elif isinstance(data, MeshgridDataDict):
            if method is GridOption.noGrid:
                dout = dd.meshgrid_to_datadict(data)
            elif method is GridOption.guessShape:
                dout = data
            elif method is GridOption.specifyShape:
                self.logger().warning(
                    f"Data is already on grid. Ignore shape.")
                dout = data

        else:
            self.logger().error(
                f"Unknown data type {type(data)}.")