Skip to content

Measurements

qDrive can run measurements and store the results directly as datasets.

Note

Measurements are stored in the default scope. See setting the default scope for how to configure it.

Sweeps with do0D, do1D, and do2D

For most experiments, simple gridded sweeps in 0, 1, or 2 dimensions are enough. Some examples:

from qdrive.measurement.sweeps import do0D, do1D, do2D
from qdrive.demo.station import get_station

station = get_station()
t_exp = 10  # seconds

def run_0D_experiment():
    graph_instr = station.zero_D_graph_instr
    # add_qcodes_snapshot=True adds the QCoDeS snapshot (works in all doXD functions)
    return do0D("0D_sweep_example", graph_instr.m_param, add_qcodes_snapshot=True)

def run_1D_experiment():
    n_x_vals = 1000
    graph_instr = station.one_D_graph_instr
    graph_instr.set_shape(n_x_vals)  # for demo purposes; not needed with real instruments

    dac = station.QH_dac
    # sweep dac.ch1 from -200 to 250; wait t_exp/n_x_vals after each set point to let the output settle
    return do1D("1D_sweep_example", dac.ch1, -200, 250, n_x_vals, t_exp / n_x_vals, graph_instr.m_param)

def run_2D_experiment():
    n_x_vals = 100
    n_y_vals = 150
    graph_instr = station.two_D_graph_instr
    graph_instr.set_shape(n_x_vals, n_y_vals)  # for demo purposes; not needed with real instruments

    dac = station.QH_dac
    # sweep dac.ch1 from 0 to -400, and dac.ch2 from 200 to 350
    # wait t_exp/n_x_vals after setting ch1; don't wait after setting ch2
    return do2D("2D_sweep_example", dac.ch1, 0, -400, n_y_vals, t_exp / n_y_vals,
                                    dac.ch2, 200, 350, n_x_vals, 0, graph_instr.m_param)

You can also measure multiple parameters at once:

do1D("1D_sweep_example", dac.ch1, -200, 250, n_x_vals, t_exp / n_x_vals, m_param1, m_param2)  # and so on

Custom measurement loops

The example below uses a lower-level interface (built on the QCoDeS measurement object) to define your own loops:

import time
import numpy as np

from qdrive.measurement.measurement import Measurement
from qdrive.demo.station import get_station

n_x_vals = 100
n_y_vals = 150

station = get_station()

# Combine the previous 1D and 2D experiments into a single experiment

# 1. load the relevant instruments
graph_instr_1D = station.one_D_graph_instr
graph_instr_1D.set_shape(n_x_vals)
graph_instr_2D = station.two_D_graph_instr
graph_instr_2D.set_shape(n_x_vals, n_y_vals)

dac = station.QH_dac

# 2. create a measurement object
meas = Measurement("combined_1D_and_2D_measurement")
meas.register_m_param(graph_instr_1D.m_param, dac.ch1)
meas.register_m_param(graph_instr_2D.m_param, dac.ch1, dac.ch2)

# 3. run the measurement
with meas.measure() as data_collector:
    for ch1_voltage in np.arange(0, n_y_vals, 1):
        dac.ch1.set(ch1_voltage)
        data_collector.add_data({dac.ch1: ch1_voltage, graph_instr_1D.m_param: graph_instr_1D.m_param()})

        for ch2_voltage in np.arange(0, n_x_vals, 1):
            dac.ch2.set(ch2_voltage)
            data_collector.add_data({dac.ch1: ch1_voltage,
                                     dac.ch2: ch2_voltage,
                                     graph_instr_2D.m_param: graph_instr_2D.m_param()})
            time.sleep(0.001)

ds = meas.dataset