Measurement Control#

We first prepare some utilities necessarily for the examples.

from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np
import xarray as xr
from qcodes import ManualParameter, Parameter

import quantify_core.data.handling as dh
from quantify_core.measurement import MeasurementControl

dh.set_datadir(Path.home() / "quantify-data")
meas_ctrl = MeasurementControl("meas_ctrl")

par0 = ManualParameter(name="x0", label="X0", unit="s")
par1 = ManualParameter(name="x1", label="X1", unit="s")
par2 = ManualParameter(name="x2", label="X2", unit="s")
par3 = ManualParameter(name="x3", label="X3", unit="s")
sig = Parameter(name="sig", label="Signal", unit="V", get_cmd=lambda: np.exp(par0()))

Comparing iterative and batched execution loop#

Iterative settables only#

par0.batched = False
par1.batched = False
par2.batched = False

sig.batched = False

meas_ctrl.settables([par0, par1, par2])
meas_ctrl.setpoints_grid(
    [
        np.linspace(0, 1, 4),
        np.linspace(1, 2, 5),
        np.linspace(2, 3, 6),
    ]
)
meas_ctrl.gettables(sig)
dset = meas_ctrl.run("demo")
list(xr.plot.line(xi, label=name) for name, xi in dset.coords.items())
plt.gca().legend()
Starting iterative measurement...
<matplotlib.legend.Legend at 0x1e46f25f700>
../_images/193a1219a4d5bb494a00afb38edc40a615729f12384877fb36719be02335cfbd.png

Batched settables only#

Note that the settable with lowest .batch_size will be correspond to the innermost loop.

par0.batched = True
par1.batch_size = 8
par1.batched = True
par1.batch_size = 8
par2.batched = True
par2.batch_size = 4

sig = Parameter(name="sig", label="Signal", unit="V", get_cmd=lambda: np.exp(par2()))
sig.batched = True
sig.batch_size = 32

meas_ctrl.settables([par0, par1, par2])
meas_ctrl.setpoints_grid(
    [
        np.linspace(0, 1, 3),
        np.linspace(1, 2, 5),
        np.linspace(2, 3, 4),
    ]
)
meas_ctrl.gettables(sig)
dset = meas_ctrl.run("demo")
list(xr.plot.line(xi, label=name) for name, xi in dset.coords.items())
plt.gca().legend()
Starting batched measurement...
Iterative settable(s) [outer loop(s)]:
	 --- (None) --- 
Batched settable(s):
	 x0, x1, x2 
Batch size limit: 4
<matplotlib.legend.Legend at 0x1e46f25f7c0>
../_images/3d6a5f72cd04ad605b798e3292acc46cc331d127dcd649c657f1734dbf82f284.png

Mixed batched and iterative settables#

Note that the settable with lowest .batch_size will be correspond to the innermost loop. Furthermore, the iterative settables will be the outermost loops.

par0.batched = False
par1.batched = True
par1.batch_size = 8
par2.batched = False
par3.batched = True
par3.batch_size = 4

sig = Parameter(name="sig", label="Signal", unit="V", get_cmd=lambda: np.exp(par3()))
sig.batched = True
sig.batch_size = 32

meas_ctrl.settables([par0, par1, par2, par3])
meas_ctrl.setpoints_grid(
    [
        np.linspace(0, 1, 3),
        np.linspace(1, 2, 5),
        np.linspace(2, 3, 4),
        np.linspace(3, 4, 6),
    ]
)
meas_ctrl.gettables(sig)
dset = meas_ctrl.run("demo")
list(xr.plot.line(xi, label=name) for name, xi in dset.coords.items())
plt.gca().legend()
Starting batched measurement...
Iterative settable(s) [outer loop(s)]:
	 x0, x2 
Batched settable(s):
	 x1, x3 
Batch size limit: 4
<matplotlib.legend.Legend at 0x1e4715d4ca0>
../_images/f088fd2ee9e88bab5f80d64e5ecbbf7493e46199cb5f415d0efc6d50f08b353a.png

Instrument Monitor#

You can instantiate an instrument monitor in the following way:

from quantify_core.measurement import MeasurementControl
from quantify_core.visualization import InstrumentMonitor

instrument_monitor = InstrumentMonitor("instrument_monitor")
# Set True if you want to query the instruments about each parameter
# before updating the window. Can be slow due to communication overhead.
instrument_monitor.update_snapshot(False)
QFontDatabase: Cannot find font directory C:/Users/AmirthaVarshinyArumu/miniforge3/lib/site-packages/PyQt5/Qt5/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
QFontDatabase: Cannot find font directory C:/Users/AmirthaVarshinyArumu/miniforge3/lib/site-packages/PyQt5/Qt5/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
QFontDatabase: Cannot find font directory C:/Users/AmirthaVarshinyArumu/miniforge3/lib/site-packages/PyQt5/Qt5/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
QFontDatabase: Cannot find font directory C:/Users/AmirthaVarshinyArumu/miniforge3/lib/site-packages/PyQt5/Qt5/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
QFontDatabase: Cannot find font directory C:/Users/AmirthaVarshinyArumu/miniforge3/lib/site-packages/PyQt5/Qt5/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
QFontDatabase: Cannot find font directory C:/Users/AmirthaVarshinyArumu/miniforge3/lib/site-packages/PyQt5/Qt5/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
QFontDatabase: Cannot find font directory C:/Users/AmirthaVarshinyArumu/miniforge3/lib/site-packages/PyQt5/Qt5/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
QFontDatabase: Cannot find font directory C:/Users/AmirthaVarshinyArumu/miniforge3/lib/site-packages/PyQt5/Qt5/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
QFontDatabase: Cannot find font directory C:/Users/AmirthaVarshinyArumu/miniforge3/lib/site-packages/PyQt5/Qt5/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
QFontDatabase: Cannot find font directory C:/Users/AmirthaVarshinyArumu/miniforge3/lib/site-packages/PyQt5/Qt5/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.