qtt.measurements package

Contains functions and structures for performing measurements

Subpackages

Submodules

qtt.measurements.scans module

Basic scan functions

This module contains functions for basic scans, e.g. scan1D, scan2D, etc. This is part of qtt.

qtt.measurements.scans.acquire_segments(station, parameters, average=True, mV_range=2000, save_to_disk=True, location=None, verbose=True, trigger_re_arm_compensation=False, trigger_re_arm_padding=True)[source]

Record triggered segments as time traces into dataset. AWG must be already sending a trigger pulse per segment.

Note that if the requested period is equal or longer than the period on the AWG, then not all trigger events might be used by the M4i.

The saving to disk can take minutes or even longer.

Parameters:

parameters (dict) –

dictionary containing the following compulsory parameters: minstrhandle (instrument handle): measurement instrument handle (m4i digitizer). read_ch (list of int): channel numbers to record. period (float): time in seconds to record for each segment. nsegments (int): number of segments to record. average (bool): if True, dataset will contain a single time trace with the average of all acquired segments;

if False, dataset will contain nsegments single time trace acquisitions.

verbose (bool): print to the console.

Returns:

time trace(s) of the segments acquired.

Return type:

alldata (dataset)

qtt.measurements.scans.awgGate(gate, station)[source]

Return True if the specified gate can be controlled by the AWG

qtt.measurements.scans.ceilN(x, n)[source]
qtt.measurements.scans.checkReversal(im0, verbose=0)[source]

Check sign of a current scan

We assume that the current is either zero or positive Needed when the keithley (or some other measurement device) has been reversed

Parameters:

im0 (array) – measured data

Returns

bool

qtt.measurements.scans.createScanJob(g1, r1, g2=None, r2=None, step=-1, keithleyidx='keithley1')[source]

Create a scan job

Parameters:
  • (str) (g1) –

  • (array (r2) –

  • list) (Range to step) –

  • (str (g2) –

  • optional) (Step value (default is -1)) –

  • (array

  • list)

  • (int (step) –

  • optional)

qtt.measurements.scans.create_vectorscan(virtual_parameter, g_range=1, sweeporstepdata=None, remove_slow_gates=False, station=None, start=0, step=None)[source]

Converts the sweepdata or stepdata of a scanjob in those needed for virtual vector scans

Parameters:
  • virtual_parameter (obj) – parameter of the virtual gate which is varied

  • g_range (float) – scan range (total range)

  • remove_slow_gates – Removes slow gates from the linear combination of gates. Useful if virtual gates include

  • gates (compensation of slow) –

  • run. (but a fast measurement should be) –

  • station (None or qcodes.Station) – Used to access the virtual awg

  • start (float) – start if the scanjob data

  • step (None or float) – if not None, then add to the scanning field

Returns:

sweepdata or stepdata needed in the scanjob for virtual vector scans

Return type:

sweep_or_stepdata (dict)

qtt.measurements.scans.enforce_boundaries(scanjob, sample_data, eps=0.01)[source]

Make sure a scanjob does not go outside sample boundaries

Parameters:
qtt.measurements.scans.fastScan(scanjob, station)[source]

Returns whether we can do a fast scan using an awg

Parameters:

scanjob

Returns

f (int): 0: no fast scan possible, 1: scan2Dfast, 2: all axis

qtt.measurements.scans.fixReversal(im0, verbose=0)[source]

Fix sign of a current scan

We assume that the current is either zero or positive Needed when the keithley (or some other measurement device) has been reversed

qtt.measurements.scans.floorN(x, n)[source]
qtt.measurements.scans.getDefaultParameter(data)[source]

Return name of the main array in the dataset

qtt.measurements.scans.get_instrument(instr, station=None)[source]

Return handle to instrument

Parameters:

instr (str, Instrument, tuple, list) – name of instrument or handle or pair (handle, channel)

qtt.measurements.scans.get_instrument_parameter(handle)[source]

Return handle to instrument parameter or channel

Parameters:
  • handle (tuple or str) – name of instrument or handle. Tuple is a pair (instrument, paramname). A string is

  • 'instrument.parameter' (of the form) –

  • 'keithley3.amplitude' (e.g.) –

Returns:

h (object)

qtt.measurements.scans.get_measurement_params(station, mparams)[source]

Get qcodes parameters from an index or string or parameter

qtt.measurements.scans.get_minstrument_channels(minstrument)[source]
qtt.measurements.scans.get_param(gates, sweepgate)[source]

Get qcodes parameter from scanjob argument

qtt.measurements.scans.get_param_name(gates, sweepgate)[source]

Get qcodes parameter name from scanjob argument

qtt.measurements.scans.get_sampling_frequency(instrument_handle)[source]

Return sampling frequency of acquisition device

Parameters:

instrument_handle (str or Instrument) – handle to instrument

Returns:

sampling frequency

Return type:

float

qtt.measurements.scans.get_uhfli_scope_records(device, daq, scopeModule, number_of_records=1, timeout=30)[source]

Obtain scope records from the device using an instance of the Scope Module.

qtt.measurements.scans.instrumentName(namebase)[source]

Return name for qcodes instrument that is available

Parameters:

namebase (str) –

Returns:

name (str)

qtt.measurements.scans.lin_comb_type

Class to represent linear combinations of parameters

qtt.measurements.scans.makeDataset_sweep(data, sweepgate, sweeprange, sweepgate_value=None, ynames=None, gates=None, fig=None, location=None, loc_record=None)[source]

Convert the data of a 1D sweep to a DataSet.

Note: sweepvalues are only an approximation

Args:

data (1D array or kxN array) sweepgate (str) sweeprange (float)

Returns:

dataset

qtt.measurements.scans.makeDataset_sweep_2D(data, gates, sweepgates, sweepranges, measure_names='measured', location=None, loc_record=None, fig=None)[source]

Convert the data of a 2D sweep to a DataSet.

qtt.measurements.scans.makeScanjob(sweepgates, values, sweepranges, resolution)[source]

Create a scanjob from sweep ranges and a centre

qtt.measurements.scans.measure_raw_segment_m4i(digitizer, period, read_ch, mV_range, Naverage=100, verbose=0, trigger_re_arm_compensation=False, trigger_re_arm_padding=True)[source]

Record a trace from the digitizer

Parameters:
  • digitizer (obj) – handle to instrument

  • period (float) – length of segment to read

  • read_ch (list) – channels to read from the instrument

  • mV_range (float) – range for input

  • Naverage (int) – number of averages to perform

  • verbose (int) – verbosity level

  • trigger_arm_compensation (bool) – In block average mode the M4i needs a time of 40 samples + pretrigger to re-arm the triggering. With this option this is compensated for by measuring less samples and padding with zeros.

  • trigger_re_arm_padding (bool) – If True then remove any samples from the trigger re-arm compensation with zeros.

qtt.measurements.scans.measure_segment_scope_reader(scope_reader, waveform, number_of_averages, process=True, **kwargs)[source]

Measure block data with scope reader.

Parameters:
  • scope_reader (AcquisitionScopeInterface) – Instance of scope reader.

  • waveform (dict) – Information about the waveform that is to be collected.

  • number_of_averages (int) – Number of times the sample is collected.

  • process (bool) – If True, cut off the downward sawtooth slopes from the data.

Returns:

An array of arrays, one array per input channel.

Return type:

data (numpy array)

qtt.measurements.scans.measure_segment_uhfli(zi, waveform, channels, number_of_averages=100, **kwargs)[source]

Measure block data with Zurich Instruments UHFLI

Parameters:
  • zi (ZIUHFL) – Instance of QCoDeS driver for ZI UHF-LI

  • waveform (dict) – Information about the waveform that is to be collected

  • channels (list) – List of channels to read from, can be 1, 2 or both.

  • number_of_averages (int) – Number of times the sample is collected

Returns:

An array of arrays, one array per input channel.

Return type:

data (numpy array)

qtt.measurements.scans.measuresegment(waveform, Naverage, minstrhandle, read_ch, mV_range=2000, process=True, device_parameters=None)[source]

Wrapper to identify measurement instrument and run appropriate acquisition function. Supported instruments: m4i digitizer, ZI UHF-LI

Parameters:
  • waveform (dict) – waveform specification

  • Naverage (int) – number of averages to perform

  • minstrhandle (str or Instrument) – handle to acquisition device

  • read_ch (list) – channels to read from the instrument

  • mV_range (float) – range for input

  • process (bool) – If True, process the segment data from scope reader

  • device_parameters (dict) – dictionary passed as keyword parameters to the measurement methods

Returns:

recorded and processed data

Return type:

data (numpy array)

qtt.measurements.scans.measuresegment_m4i(digitizer, waveform, read_ch, mV_range, Naverage=100, process=False, verbose=0, fig=None, trigger_re_arm_compensation=False, trigger_re_arm_padding=True)[source]

Measure block data with M4i

Parameters:
  • digitizer (object) – handle to instrument

  • waveform (dict) – waveform specification

  • read_ch (list) – channels to read from the instrument

  • mV_range (float) – range for input

  • Naverage (int) – number of averages to perform

  • verbose (int) – verbosity level

  • trigger_re_arm_compensation (bool) – Passed to raw measurement function

  • trigger_re_arm_padding (bool) – Passed to raw measurement function

Returns:

recorded and processed data

Return type:

data (numpy array)

qtt.measurements.scans.parse_minstrument(scanjob)[source]

Extract the parameters to be measured from the scanjob

qtt.measurements.scans.plotData(alldata, diff_dir=None, fig=1)[source]

Plot a dataset and optionally differentiate

qtt.measurements.scans.process_1d_sawtooth(data, width, period, samplerate, resolution=None, padding=0, start_zero=False, fig=None, verbose=0)[source]

Process data from the M4i and a sawtooth trace

This is done to remove the extra padded data of the digitizer and to extract the forward trace of the sawtooth.

Parameters:
  • data (Nxk array) –

  • width (float) – width of the sawtooth

  • period (float) –

  • samplerate (float) – sample rate of digitizer

Returns

processed_data (Nxk array): processed data rr (tuple)

qtt.measurements.scans.process_2d_sawtooth(data, period, samplerate, resolution, width, verbose=0, start_zero=True, fig=None)[source]

Extract a 2D image from a double sawtooth signal

Parameters:
  • data (numpy array) – measured trace

  • period (float) – period of the full signal

  • samplerate (float) – sample rate of the acquisition device

  • resolution (list) – resolution nx, ny. The nx corresonds to the fast oscillating sawtooth

  • width (list of float) – width paramter of the sawtooth signals

  • verbose (int) – verbosity level

  • start_zero (bool) – Default is True

  • fig (int or None) – figure handle

Returns

processed_data (list of arrays): the extracted 2D arrays results (dict): contains metadata

class qtt.measurements.scans.sample_data_t[source]

Bases: dict

Hold all kind of sample specific data

The structure is that of a dictionary. Typical fields:

gate_boundaries (dict): dictionary with gate boundaries

gate_boundaries(gate)[source]
restrict_boundaries(gate, value)[source]
qtt.measurements.scans.scan1D(station, scanjob, location=None, liveplotwindow=None, plotparam='measured', verbose=1, extra_metadata=None)[source]

Simple 1D scan.

Parameters:
  • station (object) – contains all data on the measurement station

  • scanjob (scanjob_t) – data for scan

  • extra_metadata (None or dict) – additional metadata to be included in the dataset

Returns:

contains the measurement data and metadata

Return type:

alldata (DataSet)

qtt.measurements.scans.scan1Dfast(station, scanjob, location=None, liveplotwindow=None, delete=True, verbose=1, plotparam=None, extra_metadata=None)[source]

Fast 1D scan. The scan is performed by putting a sawtooth signal on the AWG and measuring with a fast acquisition device.

Parameters:
  • station (object) – contains all data on the measurement station

  • scanjob (scanjob_t) – data for scan

  • extra_metadata (None or dict) – additional metadata to be included in the dataset

Returns:

contains the measurement data and metadata

Return type:

DataSet

qtt.measurements.scans.scan2D(station, scanjob, location=None, liveplotwindow=None, plotparam='measured', diff_dir=None, write_period=None, update_period=5, verbose=1, extra_metadata=None)[source]

Make a 2D scan and create dictionary to store on disk.

For 2D vector scans see also the documentation of the _convert_scanjob_vec method of the scanjob_t class.

Parameters:
  • station (object) – contains all the instruments

  • scanjob (scanjob_t) – data for scan

  • write_period (float) – save-to-disk interval in lines, None for no writing before finished

  • update_period (float) – liveplot update interval in lines, None for no updates

  • extra_metadata (None or dict) – additional metadata to be included in the dataset

Returns:

contains the measurement data and metadata

Return type:

alldata (DataSet)

qtt.measurements.scans.scan2Dfast(station, scanjob, location=None, liveplotwindow=None, plotparam='measured', diff_dir=None, verbose=1, extra_metadata=None)[source]

Make a 2D scan and create qcodes dataset to store on disk.

Parameters:
  • station (object) – contains all the instruments

  • scanjob (scanjob_t) – data for scan

  • extra_metadata (None or dict) – additional metadata to be included in the dataset

Returns:

contains the measurement data and metadata

Return type:

alldata (DataSet)

qtt.measurements.scans.scan2Dturbo(station, scanjob, location=None, liveplotwindow=None, delete=True, verbose=1)[source]

Perform a very fast 2d scan by varying two physical gates with the AWG.

The function assumes the station contains an acquisition device that is supported by the measuresegment function. The number of the measurement channels is supplied via the minstrument field in the scanjob.

Parameters:
  • station (object) – contains all the instruments

  • scanjob (scanjob_t) – data for scan

Returns:

contains the measurement data and metadata

Return type:

alldata (DataSet)

class qtt.measurements.scans.scanjob_t[source]

Bases: dict

Structure that contains information about a scan

A typical scanjob contains the following (optional) fields:

Fields:

sweepdata (dict): stepdata (dict) minstrument (str, Parameter or tuple) wait_time_startscan (float):

The sweepdata and stepdata are structures with the following fields:

param (str, Parameter or dict): parameter to vary start, end, step (float) wait_time (float)

Note: currently the scanjob_t is a thin wrapper around a dict.

add_minstrument(minstrument)[source]

Add measurement instrument to scan job

add_sweep(param, start, end, step, **kwargs)[source]

Add sweep to scan job

check_format()[source]

Check the format of the scanjob for consistency and legacy style arguments

parse_param(field, station, paramtype='slow')[source]

Process str params for virtual gates

setWaitTimes(station, min_time=0)[source]

Set default waiting times based on gate filtering

qtt.measurements.scans.select_digitizer_memsize(digitizer, period, trigger_delay=None, nsegments=1, verbose=1)[source]

Select suitable memory size for a given period

Parameters:
  • digitizer (object) – handle to instrument

  • period (float) – period of signal to measure

  • trigger_delay (float) – delay in seconds between ingoing signal and returning signal

  • nsegments (int) – number of segments of period length to fit in memory

Returns:

memsize (int)

qtt.measurements.scans.select_m4i_memsize(digitizer, period, trigger_delay=None, nsegments=1, verbose=1, trigger_re_arm_compensation=False)[source]

Select suitable memory size for a given period

The selected memory size is the period times the sample rate, but rounded above to a multiple of 16. Additionally, extra pixels are added because of pretrigger_memsize requirements of the m4i.

Parameters:
  • digitizer (object) –

  • period (float) – period of signal to measure

  • trigger_delay (float) – delay in seconds between ingoing signal and returning signal

  • nsegments (int) – number of segments of period length to fit in memory

  • trigger_arm_compensation (bool) – In block average mode the M4i needs a time of 40 samples + pretrigger to re-arm the triggering. With this option the segment size is reduced. The signal_end can be larger then the segment size.

Returns:

total memory size selected pre_trigger (int): size of pretrigger selected signal_start (int): starting position of signal in pixels signal_end (int): end position of signal in pixels

Return type:

memsize (int)

qtt.measurements.scans.single_shot_readout(minstparams, length, shots, threshold=None)[source]

Acquires several measurement traces, averages the signal over the entire trace for each shot and returns the proportion of shots that are above a defined threshold. NOTE: The AWG marker delay should be set so that the triggered acquisition starts at the correct part of the readout pulse.

Parameters:
  • minstparams (dict) – required parameters of the digitizer (handle, read_ch, mV_range)

  • length (float) – length of each shot, in seconds

  • shots (int) – number of shots to acquire

  • threshold (float) – signal discrimination threshold. If None, readout proportion is not calculated.

Returns:

proportion of shots above the threshold allshots (array of floats): average signal of every shot taken

Return type:

proportion (float [0,1])

qtt.measurements.scans.waitTime(gate, station=None, gate_settle=None, default=0.001)[source]

Return settle times for gates on a station

qtt.measurements.videomode module

Contains code for the VideoMode tools

class qtt.measurements.videomode.VideoMode(station, sweepparams=None, sweepranges=None, minstrument=None, nplots=None, Naverage=10, resolution=(96, 96), sample_rate='default', diff_dir=None, verbose=1, dorun=True, show_controls=True, add_ppt=True, crosshair=False, averaging=True, name=None, mouse_click_callback=None, videomode_processor=None)[source]

Bases: object

Controls the videomode tool.

The VideoMode tools allows for fast plotting of measurement results. The basic operation of the VideoMode consists of the following stages:

  1. Initialize. For example start a periodic waveform on the AWG

  2. Start the readout. This starts a loop with the following steps: - Measure data - Post-process data - Plot data The loop continues running in the background untill the user aborts the loop.

  3. Stop the readout. This stops the measure-process-plot loop

  4. Stop. This stops all activity (e.g. both the readout loop and and activity on the AWG)

station

contains all the information about the set-up

Type:

qcodes station

videomode_processor

class performing the measurements and post-processing

Type:

VideoModeProcessor

Naverage

the number of times the raw measurement data should be averaged

Type:

Parameter

addPPT()[source]

Copy image of videomode window to PPT

static all_instances(verbose=1)[source]

Return all VideoMode instances

close()[source]

Stop the videomode and close the GUI

crosshair(*args, **kwargs)[source]

Enable or disable a crosshair in the plotting windows

static destruct()[source]

Stop all VideoMode instances and cleanup

enable_averaging_slot(averaging=None, *args, **kwargs)[source]

Update the averaging mode of the widget

get_dataset()[source]

Return latest recorded dataset

Returns:

alldata (dataset or list of datasets)

static get_instance(idx)[source]

Return instance by index

initialize()[source]

Initialize the videomode tool for the readout loop

is_running()[source]

Return True if the readout loop is running

run(start_readout=True)[source]

Initialize the tool and start the readout loop

set_videomode_name(name)[source]

Set the name for this instance of the tool

single()[source]

Do a single scan with a lot averaging.

Note: this does not yet support the usage of linear combinations of gates (a.k.a. virtual gates).

startreadout(callback=None, rate=30, maxidx=None)[source]

Start the readout loop

Parameters:

rate (float) – sample rate in ms

stop()[source]

Stops the readout loop and the input signals

static stop_all_instances()[source]

Stop readout on all all VideoMode instances

stop_videomode()[source]
stopreadout()[source]

Stop the readout loop

updatebg()[source]

Update function for the tool

Calls the videomode_processor.measure() and videomode_processor.process() and updates the GUI

videomode_class_index = 0
qtt.measurements.videomode.add_sawtooth_videomode_processor(videomode, sweepparams, sweepranges, resolution, sample_rate, minstrument)[source]

Add all required variables to the VideoMode for the VideomodeSawtoothMeasurement

qtt.measurements.videomode_processor module

class qtt.measurements.videomode_processor.DummyVideoModeProcessor(station, verbose=1)[source]

Bases: VideoModeProcessor

initialize(videomode)[source]
measure(videomode)[source]
ppt_notes()[source]

Generate notes to be added in a powerpoint slide

process(measurement_data, videomode)[source]
scan_dimension()[source]

Return the dimension of the data to be shown (1 or 2)

stop()[source]
class qtt.measurements.videomode_processor.VideoModeProcessor[source]

Bases: ABC

Base class for VideoMode processing functionality

acquisition_device_type()[source]

Return type of acquisition device

Returns:

Device type as a string. Can be

create_dataset(processed_data, metadata)[source]
classmethod default_processing(measurement_data, videomode)[source]
classmethod extend_videomode_name(name)[source]

String to append to VideoMode name

abstract initialize(videomode)[source]
abstract measure(videomode)[source]
classmethod plot_title(index)[source]

Return title for plot window

classmethod ppt_notes()[source]

Generate notes to be added in a powerpoint slide

abstract process(measurement_data, videomode)[source]
abstract scan_dimension()[source]

Return the dimension of the data to be shown (1 or 2)

abstract stop()[source]
class qtt.measurements.videomode_processor.VideomodeSawtoothMeasurement(station, verbose=1)[source]

Bases: VideoModeProcessor

create_dataset(processed_data, metadata)[source]
extend_videomode_name(name)[source]

String to append to VideoMode name

initialize(videomode)[source]
measure(videomode)[source]
parse_instrument(measurement_instrument_handle, sample_rate)[source]
plot_title(index)[source]

Return title for plot window

ppt_notes()[source]

Generate notes to be added in a powerpoint slide

process(measurement_data, videomode)[source]
scan_dimension()[source]

Return the dimension of the data to be shown (1 or 2)

set_properties(waveform, measurement_instrument, resolution=None)[source]

Create callback object for videmode data

Parameters:
  • station (QCoDeS station) –

  • waveform

  • measurement_instrument (tuple) – instrumentname, channel

  • diff_dir (list or (int, str)) – differentiation modes for the data

set_scan_parameters(scan_parameters)[source]
stop()[source]
update_position(position, verbose=1)[source]