Skip to content

plot simple data array #17

Open
Open

Description

@peendebak

Right now I can measure a simple array and plot using either MatPlot or QtPlot. But when I start processing this data, there is no good option to plot the results with the same axis and labels.

An example:

import matplotlib.pyplot as plt
import copy
import numpy as np
import qcodes as qc

#%% Make toy model
from toymodel import AModel, MockGates, MockSource, MockMeter, AverageGetter, AverageAndRaw
model = AModel()
gates = MockGates('gates', model=model)
source = MockSource('source', model=model)
meter = MockMeter('meter', model=model)
station = qc.Station(gates, source, meter)

station.set_measurement(meter.amplitude)

c0, c1, c2, vsd = gates.chan0, gates.chan1, gates.chan2, source.amplitude


#%% 1D loop to make data

data = qc.Loop(c0[-20:20:0.2], 0.01).run(location='data/testsweep', overwrite=True)
data.complete()

Plotting the data is fine!

plotQ = qc.QtPlot(data.amplitude)

Now suppose we want to calculate the derivative and show results. We can convert to Numpy and show results, but then we have no axis labels...

X=np.array(data.amplitude)
Y=np.convolve(X, [1.,0,-1.])
plotQ = qc.QtPlot(X) # labels

Trying to make a copy of the DataArray and setting values fails...

dd=copy.deepcopy(data.amplitude) # all kinds of errors possible!
dd.ndarray = Y # fails, dd is a Numpy array

plotQ = qc.QtPlot(dd)

Finally: apply the derivative to the DataArray itself. No labels again...

Y=np.convolve(data.amplitude, [1.,0,-1.])
plotQ = qc.QtPlot(X) # no labels

Options I see:

  • Make a constructor for a DataArray accepting another DataArray and a plain numpy array
  • Adopt the BasePlot so we can do a .add([DataSet], [numpy array])
  • Add an add_array option to the DataSet with a Numpy array as argument (not a DataArray)
  • Make a separate showImage(data_set, image) function that duplicates part of the functionality of BasePlot

Any suggestions on which way to go?

Activity

  1. AdriaanRol commented on Jul 15, 2016

    @AdriaanRol

    Related to using Dataset outside of the loop.

    Not possible to change things and then save back the changes.

  2. kunnykun commented on Dec 31, 2017

    @kunnykun

    where can I find toymodel?

  3. WilliamHPNielsen commented on Jan 1, 2018

    @WilliamHPNielsen
    Contributor

    @kunnykun it no longer exists. If you need some toy (mock) instruments to play around with, see the Tutorial.ipynb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions