This page was generated from docs/examples/legacy/Measure without a Loop.ipynb. Interactive online version: Binder badge.

Measure without a Loop

If you have a parameter that returns a whole array at once, often you want to measure it directly into a DataSet.

This shows how that works in QCoDeS

[1]:
%matplotlib nbagg
import qcodes as qc
import numpy as np
# import dummy driver for the tutorial
from qcodes.tests.instrument_mocks import DummyInstrument, DummyChannelInstrument
from qcodes.measure import Measure
from qcodes.actions import Task

dac1 = DummyInstrument(name="dac")
dac2 = DummyChannelInstrument(name="dac2")


# the default dummy instrument returns always a constant value, in the following line we make it random
# just for the looks πŸ’…
dac2.A.dummy_array_parameter.get =  lambda: np.random.randint(0, 100, size=5)

# The station is a container for all instruments that makes it easy
# to log meta-data
station = qc.Station(dac1, dac2)
[dac2(DummyChannelInstrument)] Error getting or interpreting *IDN?: ''
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/site-packages/qcodes/instrument/instrument.py", line 136, in get_idn
    idstr = self.ask("*IDN?")
  File "/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/site-packages/qcodes/instrument/instrument.py", line 462, in ask
    raise e
  File "/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/site-packages/qcodes/instrument/instrument.py", line 455, in ask
    answer = self.ask_raw(cmd)
  File "/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/site-packages/qcodes/instrument/instrument.py", line 475, in ask_raw
    raise NotImplementedError(
NotImplementedError: ('Instrument DummyChannelInstrument has not defined an ask method', "asking '*IDN?' to <DummyChannelInstrument: dac2>")

Instantiates all the instruments needed for the demo

For this tutorial we’re going to use the regular parameters (c0, c1, c2, vsd) and ArrayGetter, which is just a way to construct a parameter that returns a whole array at once out of simple parameters, as well as AverageAndRaw, which returns a scalar and an array together.

Only array output

The arguments to Measure are all the same actions you use in a Loop. If they return only arrays, you will see exactly those arrays (with their setpoints) in the output DataSet

[2]:
data = Measure(
    Task(dac1.dac1.set, 0),
    dac2.A.dummy_array_parameter,
    Task(dac1.dac1.set, 2),
    dac2.A.dummy_array_parameter,
).run()
DataSet:
   location = 'data/2022-07-04/#010_{name}_11-39-26'
   <Type>   | <array_id>                         | <array.name>          | <array.shape>
   Measured | dac2_ChanA_dummy_array_parameter_1 | dummy_array_parameter | (5,)
   Measured | dac2_ChanA_dummy_array_parameter_3 | dummy_array_parameter | (5,)
acquired at 2022-07-04 11:39:26
[ ]: