qtt package

Quantum Technology Toolbox

The QTT package contains functionality for the tuning and calibration of spin-qubits. The package is divided into subpackages:

  • Measurements: functionality to perform measurements on devices

  • Algorithms: functionality to analyse measurements

  • Simulation: contains simulations of quantum dot systems

  • Tools: misc tools

  • Gui: Several gui element for visualization of data

  • Instrument drivers: contains QCoDeS drivers for various instruments

For more information see https://github.com/qutech-delft/qtt

qtt.abort_measurements(value=None)

Return True if the currently running measurement should be aborted

qtt.check_version(version, module=<module 'qcodes' from '/home/docs/checkouts/readthedocs.org/user_builds/qtt/envs/feat-copy_button/lib/python3.8/site-packages/qcodes/__init__.py'>, optional=False, install_message=None)[source]

Check whether a module has the corret version

qtt.liveValue(var='qtt_live_value1')

Return live control value retrieved from redis server and convert to string

qtt.liveValueSet(value, var='qtt_live_value1')

Set live control value on redis server

qtt.reset_abort(value=0)[source]

reset qtt_abort_running_measurement

qtt.set_location_name(name, verbose=1)[source]
qtt.start_dataviewer()[source]

Subpackages

Submodules

qtt.data module

Utilities to work with data and datasets

qtt.data.add_comment(txt, dataset=None, verbose=0)[source]

Add a comment to a DataSet

Parameters
  • comment (str) – comment to be added to the DataSet metadata

  • dataset (None or DataSet) – DataSet to add the comments to

qtt.data.compare_dataset_metadata(dataset1, dataset2, metakey='allgatevalues', verbose=1)[source]

Compare metadata from two different datasets.

Outputs the differences in metadata from dataset1 to dataset2. For now, only comparisons for the key ‘allgatevalues’ has been implemented.

Parameters
  • dataset1 (DataSet) – first dataset to compare

  • dataset2 (DataSet) – second dataset to compare

  • metakey (str) – key in the DataSet metadata to compare

qtt.data.dataset1Ddata(alldata)[source]

Parse a dataset into the x and y scan values

Returns

x (array) y (array)

qtt.data.dataset1Dmetadata(alldata, arrayname=None, verbose=0)[source]

Extract metadata from a 1D scan

Returns

x1,x2 g0 (string): step gate vstep (array): step values istep (float) arrayname (string): identifier of the main array

Return type

extent (list)

qtt.data.dataset2Dmetadata(alldata, arrayname=None, verbose=0)[source]

Extract metadata from a 2D scan

Returns

x1,x2,y1,y2 g0 (str): step gate (array_id) g1 (str): sweep gate (array_id) vstep (array): step values vsweep (array): sweep values arrayname (string): identifier of the main array

Return type

extent (list)

qtt.data.dataset2image(dataset, arrayname=None, unitsperpixel=None, mode='pixel')[source]

Extract image from a dataset

Parameters
  • dataset (DataSet) – structure with 2D data

  • arrayname (None or str) – nafme of array to select

  • mode (str) – if value is ‘pixel’ then the image is converted so that it is in conventional coordinates, e.g. the step values (vertical axis) go from low to high (bottom to top).

Returns

im (numpy array) tr (image_transform object)

qtt.data.dataset2image2(dataset, arrayname=None)[source]

Extract image from dataset

Parameters

dataset (DataSet) – measured data

Returns

raw image impixel (array): image in pixel coordinates tr (image_transform object): transformation object

Return type

imraw (array)

See also: dataset2image

qtt.data.datasetCentre(ds, ndim=None)[source]

Return centre position for dataset :param ds: :type ds: DataSet

Returns

centre position

Return type

cc (list of floats)

qtt.data.dataset_get_istep(alldata, mode=None)[source]

Return number of mV per pixel in scan

qtt.data.dataset_labels(alldata, tag=None, add_unit=False)[source]

Return label for axis of dataset

Parameters
  • ds (DataSet) – dataset

  • tag (str or int or None) – can be ‘x’, ‘y’ or ‘z’ or the index of the axis

  • add_unit (bool) – If True then add units

qtt.data.dataset_to_dictionary(data_set: qcodes.data.data_set.DataSet, include_data: bool = True, include_metadata: bool = True)Dict[str, Any][source]

Convert DataSet to dictionary.

Parameters
  • data_set – The data to convert.

  • include_data – If True then include the ndarray field.

  • include_metadata – If True then include the metadata.

Returns

Dictionary containing the serialized data.

qtt.data.dateString(t=None)[source]

Return date string with timezone

qtt.data.default_setpoint_array(dataset, measured_name='measured')[source]

Return the default setpoint array for a dataset

qtt.data.determine_parameter_unit(parameter)[source]

Determine unit associated with a parameter

Parameters

parameter (Any) – the parameter to get the unit from

Returns

The unit associated with the parameter when the parameter is a qcodes parameter, otherwise None

qtt.data.dictionary_to_dataset(data_dictionary: dict)qcodes.data.data_set.DataSet[source]

Convert dictionary to DataSet.

Parameters

data_dictionary – data to convert

Returns

DataSet with converted data.

qtt.data.diffDataset(alldata, diff_dir='y', sigma=2, fig=None, meas_arr_name='measured')[source]

Differentiate a dataset and plot the result.

Parameters
  • alldata (qcodes DataSet) –

  • diff_dir (str) – direction to differentiate in

  • meas_arr_name (str) – name of the measured array to be differentiated

  • fig (int) – the number for the figure to plot

  • sigma (float) – parameter for gaussian filter kernel

qtt.data.drawCrosshair(ds, ax=None, ndim=None, **kwargs)[source]

Draw a crosshair on the centre of the dataset

Parameters
  • ds (DataSet) –

  • ax (None or matplotlib axis handle) –

  • ndim (None or int) – dimension of dataset

  • kwargs – Arguments passed to the plotting command

qtt.data.experimentFile(outputdir: str = '', tag=None, dstr=None, bname=None)[source]

Format experiment data file for later analysis

qtt.data.getDateString(t=None, full=False)[source]

Return date string

Parameters

t – datetime.datetime time

qtt.data.getTimeString(t=None)[source]

Return time string for datetime.datetime object

qtt.data.get_dataset(dataset_handle)[source]

Get a dataset from a results dictionary, a string or a dataset.

Parameters

dataset_handle (str, dict or DataSet) – either location of dataset, the dataset itself or a calibration structure.

Returns

The dataset from the handle.

Return type

DataSet

qtt.data.get_latest_dataset()[source]

Return latest dataset that was created

class qtt.data.image_transform(dataset=None, arrayname=None, mode='pixel', unitsperpixel=None, verbose=0)[source]

Bases: object

image()[source]
istep()[source]
istep_step()[source]
istep_sweep()[source]
matplotlib_image_extent()[source]

Return matplotlib style image extent

Returns

x1, x2, y1, y2

the y1 value is bottom left

Return type

extentImage (4 floats)

pixel2scan(pt)[source]

Convert pixels coordinates to scan coordinates (mV) :param pt: points in pixel coordinates (x,y) :type pt: array

Returns

ptx (array)

Return type

point in scan coordinates (sweep, step)

scan2pixel(pt)[source]

Convert scan coordinates to pixel coordinates :param pt: points in scan coordinates :type pt: array :param Returns: ptpixel (ndaray): points in pixel coordinates

scan_image_extent()[source]

Scan extent

Returns

x0, x1, y0, y1

x0, y0 is top left

Return type

extentImage (list)

scan_resolution()[source]

Return the scan resolution in [units]/pixel

transform_image(im)[source]
qtt.data.loadDataset(path)[source]

Wrapper function

Parameters

path – filename without extension

Returns dateset, metadata

qtt.data.loadExperimentData(outputdir, tag, dstr)[source]
qtt.data.load_data(mfile: str)[source]

Load data from specified file

qtt.data.load_dataset(location, io=None, verbose=0)[source]

Load a dataset from storage

An attempt is made to automatically detect the formatter. Supported are currently qcodes GNUPlotFormat, qcodes HDF5Format and json format.

Parameters
  • location (str) – either the relative or full location

  • io (None or qcodes.data.io.DiskIO) –

Returns

dataset (DataSet or None)

qtt.data.load_example_dataset(filename, verbose=0)[source]

Return an example dataset from qtt

Parameters
  • filename – Name of the dataset

  • verbose – Verbosity level

Returns

Example dataset or None of no dataset can be found

qtt.data.makeDataSet1D(p, yname='measured', y=None, location=None, loc_record=None, return_names=False)[source]

Make DataSet with one or multiple 1D arrays and one setpoint array.

Parameters
  • p (qcodes.SweepFixedValues) – the setpoint array of data

  • yname (str or list of str or Parameter or list of Parameter) – when type is str or list of str : the name of measured array(s) when type is parameter or list of parameter: the measured Parameters

  • y (array or list of array or None) – optional (measured) data to fill the DataSet

  • location (str, callable, bool or None) – If you provide a string, it must be an unused location in the io manager. Can also be: - a callable location provider with one required parameter (the io manager), and one optional (record dict), which returns a location string when called. - False - denotes an only-in-memory temporary DataSet.

  • loc_record (dict or None) – If location is a callable, this will be passed to it as record.

  • return_names (bool) – if True return array names in output

Raises
  • See _make_data_set for the ValueError and TypeError exceptions that can be raised

  • See _check_parameter for the TypeError exceptions that can be raised

Returns

Depending on parameter return_names

True: The resulting dataset and a tuple with the names of the added arrays (setpoint and measurements). False: The resulting dataset.

qtt.data.makeDataSet1Dplain(xname, x, yname, y=None, xunit=None, yunit=None, location=None, loc_record=None)[source]

Make DataSet with one 1D array and one setpoint array

Parameters
  • xname (string) – the name of the setpoint array

  • x (array or ndarray or list) – the setpoint data

  • yname (str or qcodes.Parameter or list) – the name of the measured array

  • y (array or ndarray or list) – the measured data

  • xunit (str or None) – optional, the unit of the values stored in x array.

  • yunit (str or None) – optional, the unit of the values stored in y array.

  • location (str, callable, bool or None) – If you provide a string, it must be an unused location in the io manager. Can also be: - a callable location provider with one required parameter (the io manager), and one optional (record dict), which returns a location string when called. - False - denotes an only-in-memory temporary DataSet.

  • loc_record (dict or None) – If location is a callable, this will be passed to it as record.

Raises

See _make_data_set for the ValueError and TypeError exceptions that can be raised

Returns

The resulting dataset.

qtt.data.makeDataSet2D(p1, p2, measure_names='measured', location=None, loc_record=None, preset_data=None, return_names=False)[source]

Make DataSet with one or multiple 2D array and two setpoint arrays.

If the preset_data is used for multiple 2D arrays, then the order of measure_names should match the order of preset_data.

Parameters
  • p1 (qcodes.SweepFixedValues) – first setpoint array of data

  • p2 (qcodes.SweepFixedValues) – second setpoint array of data

  • measure_names (str or list) – name(s) of measured array(s)

  • location (str, callable, bool or None) – If you provide a string, it must be an unused location in the io manager. Can also be: - a callable location provider with one required parameter (the io manager), and one optional (record dict), which returns a location string when called. - False - denotes an only-in-memory temporary DataSet.

  • loc_record (dict or None) – If location is a callable, this will be passed to it as record.

  • preset_data (array or ndarray or list or None) – optional array to fill the DataSet

  • return_names (bool) – if True return array names in output

Raises
  • See _make_data_set for the ValueError and TypeError exceptions that can be raised

  • See _check_parameter for the TypeError exceptions that can be raised

Returns

True: The resulting dataset and a tuple with the names of the added arrays (setpoint and measurements). False: The resulting dataset.

Return type

Depending on parameter return_names

qtt.data.makeDataSet2Dplain(xname, x, yname, y, zname='measured', z=None, xunit=None, yunit=None, zunit=None, location=None, loc_record=None)[source]

Make DataSet with one 2D array and two setpoint arrays

Parameters
  • xname (string) – the name of the setpoint x array.

  • x (array or ndarray or list) – the x setpoint data.

  • yname (string) – the name of the setpoint y array.

  • y (array or ndarray or list) – the y setpoint data.

  • zname (str or list of str) – the name of the measured array.

  • z (array or list or None) – optional the measured data.

  • xunit (str or None) – optional, the unit of the values stored in x.

  • yunit (str or None) – optional, the unit of the values stored in y.

  • zunit (str or None) – optional, the unit of the measured data.

  • location (str, callable, bool or None) – If you provide a string, it must be an unused location in the io manager. Can also be: - a callable location provider with one required parameter (the io manager), and one optional (record dict), which returns a location string when called. - False - denotes an only-in-memory temporary DataSet.

  • loc_record (dict or None) – If location is a callable, this will be passed to it as record.

Raises

See _make_data_set for the ValueError and TypeError exceptions that can be raised

Returns

The resulting dataset.

qtt.data.pickleload(pkl_file)[source]

Load objects from file with pickle

qtt.data.plot_dataset(dataset: qcodes.data.data_set.DataSet, parameter_names: Optional[list] = None, fig: Optional[int] = 1)None[source]

Plot a dataset to matplotlib figure window

Parameters
  • dataset – DataSet to be plotted

  • parameter_names – List of arrays to be plotted

  • fig – Specification if Matplotlib figure window

qtt.data.saveExperimentData(outputdir, dataset, tag, dstr)[source]
qtt.data.show2D(dd, impixel=None, im=None, fig=101, verbose=1, dy=None, sigma=None, colorbar=False, title=None, midx=2, units=None)[source]

Show result of a 2D scan

Parameters
  • dd (DataSet) –

  • impixel (array or None) –

  • im (array or None) –

qtt.data.stepgate(scanjob)[source]

Return the step gate in a scanjob

qtt.data.store_latest_decorator(function, obj)[source]

Decorator to store latest result of a function in an object

qtt.data.sweepgate(scanjob)[source]

Return the sweepgate in a scanjob

qtt.data.uniqueArrayName(dataset, name0)[source]

Generate a unique name for a DataArray in a dataset

qtt.data.writeDataset(path, dataset, metadata=None)[source]

Wrapper function

Parameters

path – filename without extension

qtt.data.write_data(mfile: str, data)[source]

Write data to specified file

qtt.dataset_processing module

qtt.dataset_processing.average_dataset(dataset: qcodes.data.data_set.DataSet, axis: Union[str, int] = 'vertical')qcodes.data.data_set.DataSet[source]

Calculate the mean signal of a 2D dataset over the specified axis

Parameters
  • dataset – DataSet to be processed

  • axis – Specification of the axis

Returns

Dataset with averaged signal

qtt.dataset_processing.average_multirow_dataset(dataset: qcodes.data.data_set.DataSet, number_of_repetitions: int, new_values=None, parameter_name: str = 'signal', output_parameter_name: str = 'signal')qcodes.data.data_set.DataSet[source]

Calculate the averaged signal from a 2D dataset with repeated rows

Parameters
  • dataset – Dataset containing the data to be averaged

  • number_of_repetitions – Number of rows over which to average

  • new_values – Optional new values for the averaged axis

  • parameter_name – Name of data array to process

  • output_parameter_name – Name of output array

Returns

Averaged dataset

qtt.dataset_processing.dataset_dimension(dataset: qcodes.data.data_set.DataSet)int[source]

Return dimension of DataSet

qtt.dataset_processing.process_dataarray(dataset: qcodes.data.data_set.DataSet, input_array_name: str, output_array_name: Optional[str], processing_function: Callable, label: Optional[str] = None, unit: Optional[str] = None)qcodes.data.data_set.DataSet[source]

Apply a function to a DataArray in a DataSet

Parameters
  • dataset – Input dataset containing the data array

  • input_array_name – Name of the data array to be processed

  • output_array_nane – Name of the output array or None to operate in place

  • processing_function – Method to apply to the data array

  • label – Label for the output array

  • unit – Unit for the output array

qtt.dataset_processing.resample_dataset(dataset: qcodes.data.data_set.DataSet, sample_rate: Tuple[int], copy_metadata: bool = False, output_parameter_name: Optional[str] = None)qcodes.data.data_set.DataSet[source]

Given a dataset resample the measurement array

Parameters
  • dataset – Dataset to be slice

  • sample_rate – Tuple with for each axis the sample rate. Must be a postive integer

  • copy_metadata – If True then copy the metadata of the input dataset

  • output_parameter_name – Name of the output array

Returns

Dataset with sliced data

qtt.dataset_processing.slice_dataset(dataset: qcodes.data.data_set.DataSet, window: Sequence[float], axis: int = 0, verbose: int = 0, copy_metadata: bool = False, output_parameter_name=None)qcodes.data.data_set.DataSet[source]

Given a dataset and a window for the horizontal axis return the dataset with selected window

Parameters
  • dataset – Dataset to be slice

  • window – Specification of the window to be selected

  • axis – Axis used for slicing

  • verbose – Verbosity level

  • copy_metadata – If True then copy the metadata of the input dataset

  • output_parameter_name – Name of the output array

Returns

Dataset with sliced data

qtt.exceptions module

exception qtt.exceptions.CalibrationException[source]

Bases: Exception

Exception thrown for a bad calibration

exception qtt.exceptions.MissingOptionalPackageWarning[source]

Bases: UserWarning, ValueError

An optional package is missing

exception qtt.exceptions.PackageVersionWarning[source]

Bases: UserWarning

A package has the incorrect version

qtt.instrument_storage module

Functionality to store instrument data in a configuration file

qtt.instrument_storage.load_instrument(instr, ifile, verbose=1)

Load instrument configuration from configparser structure

Parameters
  • instr (Instrument) – instrument to apply settings to

  • ifile (str) – configuration file

qtt.instrument_storage.load_instrument_configparser(instr, ifile, verbose=1)[source]

Load instrument configuration from configparser structure

Parameters
  • instr (Instrument) – instrument to apply settings to

  • ifile (str) – configuration file

qtt.instrument_storage.load_instrument_json(instr, ifile, verbose=1)[source]

Load instrument configuration from json

qtt.instrument_storage.save_instrument(instr, ifile, verbose=1)

Save instrument configuration to configparser structure

Parameters
  • instr (Instrument) – instrument to apply settings to

  • ifile (str) – configuration file

qtt.instrument_storage.save_instrument_configparser(instr, ifile, verbose=1)[source]

Save instrument configuration to configparser structure

Parameters
  • instr (Instrument) – instrument to apply settings to

  • ifile (str) – configuration file

qtt.instrument_storage.save_instrument_json(instr, ifile, verbose=1)[source]

Save instrument configuration to json

qtt.legacy module

Legacy functions (do not use)

qtt.legacy.cmap_discretize(cmap, N, m=1024)[source]

Return a discrete colormap from the continuous colormap cmap.

cmap: colormap instance, eg. cm.jet. N: number of colors.

Example

x = resize(arange(100), (5,100)) djet = cmap_discretize(cm.jet, 5) imshow(x, cmap=djet)

qtt.legacy.cmap_map(function, cmap)[source]

Applies function (which should operate on vectors of shape 3: [r, g, b], on colormap cmap. This routine will break any discontinuous points in a colormap.

qtt.legacy.createDoubleDotJobs(two_dots, one_dots, resultsdir, basevalues={}, sdinstruments=[], fig=None, verbose=1)[source]

Create settings for a double-dot from scans of the individual one-dots

qtt.legacy.filterBG(imx, ksize, sigma=None)[source]

Filter away background using Gaussian filter

qtt.legacy.filterGabor(im, theta0=- 0.39269908169872414, istep=1, widthmv=2, lengthmv=10, gammax=1, cut=None, verbose=0, fig=None)[source]

Filter image with Gabor

step is in pixel/mV

Parameters
  • im (array) – input image

  • theta0 (float) – angle of Gabor filter (in radians)

qtt.legacy.getODbalancepoint(od)[source]
qtt.legacy.getPinchvalues(od, xdir, verbose=1)[source]

Get pinch values from recorded data

qtt.legacy.loadOneDotPinchvalues(od, outputdir, verbose=1)[source]

Load the pinch-off values for a one-dot

Parameters
  • od (dict) – one-dot structure

  • outputdir (string) – location of the data

qtt.legacy.loadpickle(pkl_file)[source]

Load objects from file

qtt.legacy.plotCircle(pt, radius=11.5, color='r', alpha=0.5, linewidth=3, **kwargs)[source]

Plot a circle in a matplotlib figure

Parameters
  • pt (array) – center of circle

  • radius (float) – radius of circle

  • color (str or list) –

  • alpha (float) – transparency

qtt.legacy.positionScanjob(scanjob, pt)[source]

Helper function

Changes an existing scanjob to scan at the centre of the specified point

qtt.legacy.printGateValues(gv, verbose=1)[source]
qtt.legacy.saveImage(resultsdir, name, fig=None, dpi=300, ext='png', tight=False)[source]

Save matplotlib figure to disk

Parameters

name (str) – name of file to save

Returns

imfilerel, imfile – filenames

Return type

string

qtt.legacy.scaleCmap(imx, setclim=True, verbose=0)[source]

Scale colormap of sensing dot image

qtt.legacy.showDotGraph(dot, fig=10)[source]
qtt.legacy.showIm(ims, fig=1, title='', showz=False)[source]

Show image with nearest neighbor interpolation and axis scaling

qtt.legacy.writeBatchData(outputdir, tag, timestart, timecomplete)[source]

qtt.pgeometry module

pgeometry

A collection of usefull functions.

For additional options also see numpy and matplotlib.

platform

Unix, Windows

Additions:

Copyright 2012-2016 TNO

Original code:

Copyright 2011 Pieter Eendebak <pieter.eendebak@gmail.com>

@author: eendebakpt

qtt.pgeometry.RBE2euler(Rbe)[source]

Convert rotation matrix to Euler angles

qtt.pgeometry.T2opencv(T)[source]

Convert transformation to OpenCV rvec, tvec pair

Example

>>> rvec, tvec = T2opencv(np.eye(4))
qtt.pgeometry.addfigurecopy(fig=None)[source]

Add callback to figure window

By pressing the ‘c’ key figure is copied to the clipboard

qtt.pgeometry.angleDiff(x, y)[source]

Return difference between two angles in radians modulo 2* pi

>>> d=angleDiff( 0.01, np.pi+0.02)
>>> d=angleDiff( 0.01, 2*np.pi+0.02)
qtt.pgeometry.angleDiffOri(x, y)[source]

Return difference between two angles in radians modulo pi

>>> d=angleDiff( 0.01, np.pi+0.02)
>>> d=angleDiff( 0.01, 2*np.pi+0.02)
qtt.pgeometry.auto_canny(image, sigma=0.33)[source]

Canny edge detection with automatic parameter detection

>>> imc=auto_canny(np.zeros( (200,300)).astype(np.uint8))
Parameters

image (array) – input image

Returns

edged – detected edges

Return type

array

Code from: http://www.pyimagesearch.com/2015/04/06/zero-parameter-automatic-canny-edge-detection-with-python-and-opencv/

qtt.pgeometry.blur_measure(im, verbose=0)[source]

Calculate bluriness for an image

Parameters

im (array) – input image

qtt.pgeometry.breakLoop(wk=None, dt=0.001, verbose=0)[source]

Break a loop using OpenCV image feedback

qtt.pgeometry.cd(dd='')[source]

Change current working directory

qtt.pgeometry.cfigure(*args, **kwargs)[source]

Create Matplotlib figure with copy to clipboard functionality

By pressing the ‘c’ key figure is copied to the clipboard

qtt.pgeometry.checkmodule(module_name, verbose=1)[source]

Return location of module based on module name

Parameters

module_name (str) – name of module to inspect

Returns

obj: module specification

qtt.pgeometry.choose(n, k)[source]

Binomial coefficients Return the n!/((n-k)!k!)

Parameters
  • -- Integer (k) –

  • -- Integer

Returns

The bionomial coefficient n choose k

Example

>>> choose(6,2)
15
qtt.pgeometry.circular_mean(weights, angles)[source]

Calculate circular mean of a set of 2D vectors

qtt.pgeometry.decomposeProjectiveTransformation(H, verbose=0)[source]

Decompose projective transformation H is decomposed as H = Hs*Ha*Hp with

Hs = [sR t]

[0 1]

Ha = [K 0]

[0 1]

Hp = [I 0]

[v’ eta]

If H is 3-dimensional, then R = [ cos(phi) -sin(phi); sin(phi) cos(phi)];

For more information see “Multiple View Geometry”, paragraph 1.4.6.

>>> Ha, Hs, Hp, rest = decomposeProjectiveTransformation( np.eye(3) )
qtt.pgeometry.dehom(x)[source]

Convert homogeneous points to affine coordinates

qtt.pgeometry.deprecation(message)[source]

Issue a deprecation warning message

qtt.pgeometry.detect_local_minima(arr, thr=None)[source]

Takes an array and detects the troughs using the local maximum filter. Returns a boolean mask of the troughs (i.e. 1 when the pixel’s value is the neighborhood maximum, 0 otherwise)

Parameters

arr (array) – input array

qtt.pgeometry.dir2R(d, a=None)[source]

Convert direction to rotation matrix

Note: numerically not stable near singular points!

Parameters
  • d (numpy array of size 3) – direction to rotation to a

  • a (numpy array of size 3) – target direction

Returns

matrix R such that R*a = d

Return type

R (3x3 numpy array)

Example:

>>> d = np.array([0, 1, 0]); a = np.array([0, -1, 0])
>>> R = dir2R(d, a)

Pieter Eendebak <pieter.eendebak@tno.nl>

qtt.pgeometry.directionMean(vec)[source]

Calculate the mean of a set of directions

The initial direction is determined using the oriented direction. Then a non-linear optimization is done.

Parameters

vec – List of directions

Returns

Angle of mean of directions

>>> vv=np.array( [[1,0],[1,0.1], [-1,.1]])
>>> a=directionMean(vv)
qtt.pgeometry.enlargelims(factor=1.05)[source]

Enlarge the limits of a plot

Parameters

factor (float or list of float) – Factor to expand the limits of the current plot

Example

>>> enlargelims(1.1)
qtt.pgeometry.euler2RBE(theta)[source]

Convert Euler angles to rotation matrix

Example

>>> np.set_printoptions(precision=4, suppress=True)
>>> euler2RBE( [0,0,np.pi/2] )
array([[ 0., -1.,  0.],
       [ 1.,  0.,  0.],
       [-0.,  0.,  1.]])
qtt.pgeometry.findImageHandle(fig, verbose=0, otype=<class 'matplotlib.image.AxesImage'>)[source]

Search for specific type of object in Matplotlib figure

qtt.pgeometry.finddirectories(p, patt)[source]

Get a list of files

qtt.pgeometry.findfiles(p, patt, recursive=False)[source]

Get a list of files

qtt.pgeometry.findfilesR(p, patt, show_progress=False)[source]

Get a list of files (recursive)

Parameters
  • p (string) – directory

  • patt (string) – pattern to match

  • show_progress (bool) –

Returns

lst (list of str)

qtt.pgeometry.fitPlane(X)[source]

Determine plane going through a set of points

Parameters

X (array) – aray of size Nxk. Points in affine coordinates

Returns

fitted plane in homogeneous coordinates

Return type

array

Example

>>> X=np.array([[1,0,0 ], [0,1,0], [1,1,0], [2,2,0]])
>>> t=fitPlane(X)
class qtt.pgeometry.fps_t(nn=40)[source]

Bases: object

addtime(t, x=0)[source]

Add a timestamp to the object

framerate()[source]

Return the current framerate

iim()[source]

Return index modulo number of elements

loop(s='')[source]

Helper function

show()[source]

Print the current framerate

showloop(dt=2, s='')[source]

Print current framerate

value()[source]

Return mean of current values

qtt.pgeometry.frame2T(f)[source]

Convert frame into 4x4 transformation matrix

qtt.pgeometry.freezeclass(cls)[source]

Decorator to freeze a class

This means that no attributes can be added to the class after instantiation.

qtt.pgeometry.fullpath(*args)[source]

Return full path from a list

qtt.pgeometry.gaborFilter(ksize, sigma, theta, Lambda=1, psi=0, gamma=1, cut=None)[source]

Create a Gabor filter of specified size

Parameters
  • ksize (integer) – kernel size in pixels

  • sigma (float) – parameters of Gabor function

  • theta (float) – parameters of Gabor function

  • Lambda (float) – parameters of Gabor function

  • psi (float) – parameters of Gabor function

  • cut (boolean) – if True cut off the angular component after specified distance (in radians)

Returns

g – constructed kernel

Return type

array

Example

>>> g = gaborFilter(ksize=15, sigma=2,theta=2,Lambda=1, gamma=1)
qtt.pgeometry.getWindowRectangle()[source]

Return current matplotlib window rectangle

qtt.pgeometry.ginput(n=1, drawmode='', **kwargs)[source]

Select points from figure

Press middle mouse button to stop selection

Parameters
  • - number of points to select (n) –

  • - style to plot selected points (drawmode) –

  • kwargs – arguments passed to plot function

qtt.pgeometry.histogram(x, nbins=30, fig=1)[source]

Return histogram of data

>>> _=histogram(np.random.rand(1,100))
qtt.pgeometry.hom(x)[source]

Create affine to homogeneous coordinates

Parameters

x (kxN array) – affine coordinates

Returns

homogeneous coordinates

Return type

h ( (k+1xN) array)

qtt.pgeometry.imshowz(im, *args, **kwargs)[source]

Show image with interactive z-values

qtt.pgeometry.intersect2lines(l1, l2)[source]

Calculate intersection between 2 lines

Parameters
  • l1 (array) – first line in homogeneous format

  • l2 (array) – first line in homogeneous format

Returns

intersection in homogeneous format. To convert to affine coordinates use dehom

Return type

array

qtt.pgeometry.list_objects(objectype=None, objectclassname='__123', verbose=1)[source]

List all objects in memory of a specific type or with a specific class name

Parameters
  • objectype (None or class) –

  • objectclassname (str) –

Returns

list of objects found

Return type

ll (list)

qtt.pgeometry.load(pkl_file)[source]

Load objects from file

qtt.pgeometry.logistic(x, x0=0, alpha=1)[source]

Simple logistic function

Parameters

x (float or array) –

>>> t=np.arange(0,600,1.)
>>> _ = plt.plot(t, logistic(t, 300, alpha=1./100),'.b')
qtt.pgeometry.memUsage()[source]

Prints the memory usage in MB

Uses the resource module

qtt.pgeometry.memory()[source]

Return the memory usage in MB

Returns

memory usage in mb

Return type

float

qtt.pgeometry.minAlg_5p4(A)[source]

Algebraic minimization function

Function computes the vector x that minimizes ||Ax|| subject to the condition ||x||=1. Implementation of Hartley and Zisserman A5.4 on p593 (2nd Ed)

Usage: [x,V] = minAlg_5p4(A) :param A: The constraint matrix, ||Ax|| to be minimized :type A: numpy array

Returns

x - The vector that minimizes ||Ax|| subject to the

condition ||x||=1

qtt.pgeometry.mkdirc(d)[source]

Similar to mkdir, but no warnings if the directory already exists

qtt.pgeometry.modulepath(m)[source]

Return path for module

Parameters

m (str or module) – module to return path

Returns

path of module

Return type

str

qtt.pgeometry.monitorSizes(verbose=0)[source]

Return monitor sizes

qtt.pgeometry.mpl2clipboard(event=None, verbose=1, fig=None)[source]

Copy current Matplotlib figure to clipboard

qtt.pgeometry.null(a, rtol=1e-05)[source]

Calculate null space of a matrix

qtt.pgeometry.opencv2T(rvec, tvec)[source]

Convert OpenCV pose to homogenous transform

qtt.pgeometry.opencv2TX(rvecs, tvecs)[source]

Convert OpenCV pose to homogenous transform

qtt.pgeometry.opencv_draw_points(bgr, imgpts, drawlabel=True, radius=3, color=(255, 0, 0), thickness=- 1, copyimage=True)[source]

Draw points on image with opencv

Parameters
  • bgr (numpy array) – image to draw points into

  • impts (array) – locations of points to plot

qtt.pgeometry.opencvpose2attpos(rvecs, tvecs)[source]
qtt.pgeometry.orthogonal_proj(zfront, zback)[source]

see http://stackoverflow.com/questions/23840756/how-to-disable-perspective-in-mplot3d

qtt.pgeometry.otsu(im, fig=None)[source]

Calculate threshold on data using Otsu’s method

Parameters
  • im (array) – data to be processed

  • fig (number, optional) – If set to a number show results in a histogram

Returns

thr – The threshold value

Return type

float

Examples

>>> thr = otsu(np.random.rand( 2000), fig=100)
qtt.pgeometry.package_versions(verbose=1)[source]

Report package versions installed

qtt.pgeometry.partiala(method, **kwargs)[source]

Function to perform functools.partial on named arguments

qtt.pgeometry.pcolormesh_centre(x, y, im, *args, **kwargs)[source]

Wrapper for pcolormesh to plot pixel centres at data points

qtt.pgeometry.pg_rotation2H(R)[source]

Convert rotation matrix to homogenous transform matrix

qtt.pgeometry.pg_rotx(phi)[source]

Rotate around the x-axis with angle

qtt.pgeometry.pg_scaling(scale, cc=None)[source]

Create scaling with specified centre

Example

>>> pg_scaling( [1.,2])
array([[ 1.,  0.,  0.],
       [ 0.,  2.,  0.],
       [ 0.,  0.,  1.]])
qtt.pgeometry.pg_transl2H(tr)[source]

Convert translation to homogeneous transform matrix

>>> pg_transl2H( [1,2])
array([[ 1.,  0.,  1.],
        [ 0.,  1.,  2.],
        [ 0.,  0.,  1.]])
qtt.pgeometry.plot2Dline(line, *args, **kwargs)[source]

Plot a 2D line in a matplotlib figure

Parameters

line (3x1 array) – line to plot

>>> plot2Dline([-1,1,0], 'b')
class qtt.pgeometry.plotCallback(func=None, xdata=None, ydata=None, scale=[1, 1], verbose=0)[source]

Bases: object

connect(fig)[source]
qtt.pgeometry.plotCostFunction(fun, x0, fig=None, marker='.', scale=1, c=None)[source]

Plot a cost function on specified data points

Example with variation of Booth’s function:

>>> fun = lambda x: 2*(x[0]+2*x[1]-7)**2 + (2*x[0]+x[1]-5)**2
>>> plotCostFunction(fun, np.array([1,3]), fig=100, marker='-')
qtt.pgeometry.plotLabels(xx, *args, **kwargs)[source]

Plot labels next to points

Parameters
  • xx (2xN array) – points to plot

  • *kwargs – arguments past to plotting function

Example: >>> xx=np.random.rand(2, 10) >>> fig=plt.figure(10); plt.clf() >>> _ = plotPoints(xx, ‘.b’); _ = plotLabels(xx)

qtt.pgeometry.plotPoints(xx, *args, **kwargs)[source]

Plot 2D or 3D points

Parameters
  • xx (array) – array of points to plot

  • *args – arguments passed to the plot function of matplotlib

  • **kwargs – arguments passed to the plot function of matplotlib

Example: >>> plotPoints(np.random.rand(2,10), ‘.-b’)

qtt.pgeometry.plotPoints3D(xx, *args, **kwargs)[source]

Plot 3D points

Parameters

xx (3xN array) – the 3D data points

Example

>> ax=plotPoints3D(np.random.rand(3, 1) ,’.r’, markersize=10, fig=12)

qtt.pgeometry.point_in_polygon(pt, pp)[source]

Return True if point is in polygon

Parameters
  • pt (1x2 array) – point

  • pp (Nx2 array) – polygon

Returns

1.0 if point is inside 1.0, otherwise -1.0

Return type

r (float)

qtt.pgeometry.points_in_polygon(pts, pp)[source]

Return all points contained in a polygon

Parameters
  • pt (Nx2 array) – points

  • pp (Nxk array) – polygon

Returns

rr (bool array)

qtt.pgeometry.polyarea(p)[source]

Return signed area of polygon

Parameters

p (Nx2 numpy array or list of vertices) – vertices of polygon

Returns

area – area of polygon

Return type

float

>>> polyarea( [ [0,0], [1,0], [1,1], [0,2]] )
1.5
qtt.pgeometry.polyintersect(x1: numpy.ndarray, x2: numpy.ndarray)numpy.ndarray[source]

Calculate intersection of two polygons

Parameters
  • x1 – First polygon. Shape is (N, 2) with N the number of vertices

  • x2 – Second polygon

Returns

Intersection of both polygons

Raises

ValueError if the intersection consists of multiple polygons

>>> x1=np.array([(0, 0), (1, 1), (1, 0)] )
>>> x2=np.array([(1, 0), (1.5, 1.5), (.5, 0.5)])
>>> x=polyintersect(x1, x2)
>>> _=plt.figure(10); plt.clf()
>>> plotPoints(x1.T, '.:r' )
>>> plotPoints(x2.T, '.:b' )
>>> plotPoints(x.T, '.-g' , linewidth=2)
qtt.pgeometry.projectiveTransformation(H, x)[source]

Apply a projective transformation to a kxN array

>>> y = projectiveTransformation( np.eye(3), np.random.rand( 2, 10 ))
qtt.pgeometry.qtModules(verbose=0)[source]

Return list of Qt modules loaded

qtt.pgeometry.raiseWindow(fig)[source]

Raise a matplotlib window to to front

qtt.pgeometry.region2poly(rr)[source]

Convert a region (bounding box xxyy) to polygon

qtt.pgeometry.robustCost(x, thr, method='L1')[source]

Robust cost function

Parameters
  • x (array) – data to be transformed

  • thr (float or 'auto' or None) – threshold. If None then the input x is returned unmodified. If ‘auto’ then use automatic detection (at 95th percentile)

  • method (str) – method to be used. use ‘show’ to show the options

Example

>>> robustCost([2,3,4],thr=2.5)
array([ 2. ,  2.5,  2.5])
>>> robustCost(2, thr=1)
1
>>> methods=robustCost(np.arange(-5,5,.2), thr=2, method='show')
qtt.pgeometry.rot2D(phi)[source]

Return 2x2 rotation matrix from angle

Parameters

phi (float) – Angle in radians

Returns

R – The 2x2 rotation matrix

Return type

array

Examples

>>> R = rot2D(np.pi)
qtt.pgeometry.rottra2mat(rot, tra)[source]

create 4x4 matrix from 3x3 rot and 1x3 tra

qtt.pgeometry.runcmd(cmd, verbose=0)[source]

Run command and return output

qtt.pgeometry.save(pkl_file, *args)[source]

Save objects to file

Parameters
  • pkl_file (string) – filename

  • *args (anything) – Python objects to save

qtt.pgeometry.scaleImage(image, display_min=None, display_max=None)[source]

Scale any image into uint8 range

Parameters
  • image (numpy array) – input image

  • display_min (float) – value to map to min output range

  • display_max (float) – value to map to max output range

Returns

the scaled image

Return type

image (numpy array)

Example

>>> im=scaleImage(255*np.random.rand( 30,40), 40, 100)

Code modified from: https://stackoverflow.com/questions/14464449/using-numpy-to-efficiently-convert-16-bit-image-data-to-8-bit-for-display-with?noredirect=1&lq=1

qtt.pgeometry.setFontSizes(labelsize=20, fsize=17, titlesize=None, ax=None)[source]

Update font sizes for a matplotlib plot

qtt.pgeometry.setWindowRectangle(x, y=None, w=None, h=None, fig=None, mngr=None)[source]

Position the current Matplotlib figure at the specified position

Parameters
  • x – position in format (x,y,w,h)

  • fig (None or int) – specification of figure window. Use None for the current active window

Usage: setWindowRectangle([x,y,w,h])

qtt.pgeometry.setregion(im, subim, pos, mask=None, clip=False)[source]

Set region in Numpy image

Parameters
  • im (Numpy array) – image to fill region in

  • subim (Numpy array) – subimage

  • pos (array) – position to place image

  • (None or array) (mask) –

  • (bool) (clip) –

class qtt.pgeometry.signalTest[source]

Bases: PyQt5.QtCore.QObject

Helper function for Qt signals

go()[source]
s
qtt.pgeometry.signedmin(val, w)[source]

Signed minimum value function

>>> signedmin(-3, 5)
-3
>>> signedmin(-10, 5)
-5
qtt.pgeometry.signedsqrt(val)[source]

Signed square root function

>>> signedsqrt([-4.,4,0])
array([-2.,  2.,  0.])
>>> signedmin(-10, 5)
-5
qtt.pgeometry.slotTest(txt)[source]

Helper function for Qt slots

qtt.pgeometry.smoothstep(x, x0=0, alpha=1)[source]

Smooth step function

>>> t=np.arange(0,600,1.)
>>> _ = plt.plot(t, smoothstep(t, 300, alpha=1./100),'.b')
qtt.pgeometry.static_var(varname, value)[source]

Helper function to create a static variable

Parameters
  • varname (str) –

  • value (anything) –

qtt.pgeometry.tilefigs(lst, geometry=[2, 2], ww=None, raisewindows=False, tofront=False, verbose=0, monitorindex=None)[source]

Tile figure windows on a specified area

Parameters
  • lst (list) – list of figure handles or integers

  • geometry (2x1 array) – layout of windows

  • (None or int) (monitorindex) –

  • (None or list) (ww) –

qtt.pgeometry.tprint(string, dt=1, output=False, tag='default')[source]

Print progress of a loop every dt seconds

Parameters
  • string (str) – text to print

  • dt (float) – delta time in seconds

  • output (bool) – if True return whether output was printed or not

  • tag (str) – optional tag for time

Returns

output (bool)

qtt.pgeometry.writeTxt(im, txt, pos=(10, 10), fontsize=25, color=(0, 0, 0), fonttype=None)[source]

Write text on image using PIL

qtt.structures module

Contains code for various structures

class qtt.structures.CombiParameter(name, params, label=None, unit='a.u.', **kwargs)[source]

Bases: qcodes.instrument.parameter.Parameter

Create a parameter which is a combination of multiple other parameters, which are always set to the same value.

The get function returns the mean of the individual parameters.

name

name for the parameter

Type

str

params

the parameters to combine

Type

list

get_raw()[source]

get_raw is called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if get_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a get method on the parameter instance.

set_raw(value)[source]

set_raw is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if set_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a set method on the parameter instance.

class qtt.structures.MultiParameter(name, params, label=None, unit=None, **kwargs)[source]

Bases: qcodes.instrument.parameter.Parameter

Create a parameter which is a combination of multiple other parameters.

name

name for the parameter

Type

str

params

the parameters to combine

Type

list

get_raw()[source]

get_raw is called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if get_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a get method on the parameter instance.

set_raw(values)[source]

set_raw is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if set_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a set method on the parameter instance.

class qtt.structures.VectorParameter(name, comb_map, **kwargs)[source]

Bases: qcodes.instrument.parameter.Parameter

Create parameter which controls linear combinations.

name

the name given to the new parameter

Type

str

comb_map

tuples with in the first entry a parameter and in the second a coefficient

Type

list

coeffs_sum

the sum of all the coefficients

Type

float

get_raw()[source]

Return the value of this parameter.

set_raw(value)[source]

Set the parameter to value.

Note: the set is not unique, i.e. the result of this method depends on the previous value of this parameter.

Parameters

value (float) – the value to set the parameter to.

class qtt.structures.onedot_t(gates, name=None, data=None, station=None, transport_instrument=None)[source]

Bases: dict

Class representing a single quantum dot

name()[source]
class qtt.structures.sensingdot_t(gate_names, gate_values=None, station=None, index=None, minstrument=None, virt_gates=None)[source]

Bases: object

autoTune(scanjob=None, fig=200, outputdir=None, step=- 2.0, max_wait_time=1.0, scanrange=300, add_slopes=False)[source]

Automatically determine optimal value of plunger

autoTuneInit(scanjob, mode='center')[source]
detune(value)[source]

Detune the sensing dot by the specified amount

detuning_scan(stepsize=2, nsteps=5, verbose=1, fig=None)[source]

Optimize the sensing dot by making multiple plunger scans for different detunings

Parameters
Returns

list of optimal detuning and sd plunger value results (dict)

Return type

best (list)

fastTune(Naverage=90, sweeprange=79, period=0.001, location=None, fig=201, sleeptime=2, delete=True, add_slopes=False, invert=False, verbose=1)[source]

Fast tuning of the sensing dot plunger.

If the sensing dot object is initialized with a virtual gates object the virtual plunger will be used for the sweep.

Parameters
  • Naverage (int) – number of averages

  • scanrange (float) – Range to be used for scanning

  • period (float) – Period to be used in the scan sweep

  • fig (int or None) – window for plotting results

Returns

value of plunger alldata (dataset): measured data

Return type

plungervalue (float)

gate_names()[source]

Return names of the gates used to the define the SD

gates()[source]

Return values on the gates used to the define the SD

initialize(sdval=None, setPlunger=False)[source]
plungervalue()[source]

Return current value of the chemical potential plunger

scan1D(outputdir=None, step=- 2.0, max_wait_time=0.75, scanrange=300)[source]

Make 1D-scan of the sensing dot.

scan2D(ds=90, stepsize=4, fig=None, verbose=1)[source]

Make 2D-scan of the sensing dot.

show()[source]
tunegate()[source]

Return the gate used for tuning the potential in the dot

value()[source]

Return current through sensing dot

class qtt.structures.twodot_t(*args, **kwargs)[source]

Bases: dict

name()[source]

qtt.version module