Control Your Measurements With QCoDeS and Labber

With this blog post, we introduce a new high-level Python programming interface for Zurich Instruments devices: the Zurich Instruments Toolkit. It is the basis of our new support for QCoDeS and Labber measurement frameworks.

A modern experiment can nowadays be a complex beast. Researchers put a great amount of time and care into creating an interesting sample to study, but also the measurement systems can be as complex as the physics under investigation. Many different instruments need to work together, every single one with its own physical interface and data format. To do that, many laboratories developed their own series of measurement and data analysis programs. These are sometimes written by graduate students and then inherited and improved by new generations, sometimes developed in a team of professional developers. However, a lot of tasks are common across different groups and it make sense to have a common platform to avoid duplicate efforts. This has the advantage to lower the access barriers to an experiment for new people and to focus on the science instead of technical programming. That is why measurement frameworks like QCoDeS and Labber were born.

QCoDeS originated as a collaborative effort of the universities of Copenhagen, Delft, Sydney and the Microsoft quantum computing consortium. It is a Python based measurement framework with support for many different instruments, measurement automation and data storage. While it is designed by and for the research of nanoelectronics and quantum computing, it can be used also for other applications. It is an open source project, so users can see and modify its code to their needs and eventually contribute back to the community.

Labber is a program with similar goals, developed by Simon Gustavsson (MIT) and Philip Krantz (Chalmers)​. It has a very large instrument library and an intuitive graphical user interface, that makes it easy to create complex experiment setups.

Since the beginning at Zurich Instruments, we provided our users with powerful LabOne APIs to access all the capabilities of their instruments without dealing with cumbersome raw programming interfaces. Everything is accessible with functions in your favorite programming language. With the emergence of these new frameworks, we decided that it was time to take the user experience to a new level. That is why we developed new controllers for our instruments in QCoDeS and Labber.

QCoDeS

zhinst-qcodes is the package that provides access to Zurich Instruments devices within QCoDeS. Please follow the QCoDeS Getting Started guide to install QCoDeS itself, and download and install Zurich Instruments LabOne from our website. Once that is done, you can install zhinst-qcodes by writing in a prompt

pip install zhinst-qcodes

Now you are ready to go. Open the Python interpreter or a Jupyter Notebook; to connect to a device it’s enough to import the library and create an instrument instance. For example:

import qcodes as qc
import zhinst.qcodes
 
hdawg = zhinst.qcodes.HDAWG("hdawg1", "dev8171")

with that you can start to play with the instrument!

All the parameters are available as properties of the instrument object. For example, to get or set the frequency of the first oscillator:

print(hdawg.oscs[0].freq())  # get and print the frequency
hdawg.oscs[0].freq(1e6)      # set the frequency to 1 MHz

Controlling your Zurich Instruments device interactively in a IPython console could look like this:

An interactive session in IPython and QCoDeS with the HDAWG

You can find extensive examples in the documentation at https://docs.zhinst.com/zhinst-qcodes/en/latest/examples/index.html

Labber

zhinst-labber is a collection of Labber instrument drivers that provide access to Zurich Instruments devices within the Labber measurement software.

You can find the installation package at https://github.com/zhinst/zhinst-labber/releases

To install it, extract all the files in your Local drivers folder. To find its location, open the Instrument Server and go to Edit>Preferences. Then you can find it in the section Folders. For more information, please check our Readme and the official Labber documentation.

Labber provides a graphical user interface for Zurich Instruments devices. For example for the MFLI Lock-In Amplifier:

MFLI Labber

A screenshot of MFLI interface in Labber

The Toolkit

QCoDeS and Labber are important and widespread frameworks, but there are many other used in various laboratories. It’s possible to use the same functionalities using the Zurich Instruments Toolkit (zhinst-toolkit). This package is the core of our instrument controllers for both QCoDeS and Labber. It contains all the features that are not specific to a single framework. It can be used from pure Python or integrated in a different measurement software. It is installed similarly to zhinst-qcodes with

pip install zhinst-toolkit

With the Toolkit you can access your instruments in a more user friendly way. For example, with the standard zhinst package, to access a property of the instrument you have ask the data server to get a specific node:

daq.getDouble('/dev337/oscs/0/freq')
Instead, with the Toolkit, every property is a callable attribute of the instrument object itself:
mfli.nodetree.oscs[0].freq()

You can find a detailed user guide here: https://docs.zhinst.com/zhinst-toolkit/en/latest/

AWG Control

Our AWGs can be controlled with seqC, our high-level programming language. In addition to that, the Toolkit offers a new programmatic interface in Python. In this way it is possible to create sequences on-the-fly with minimal code. For example, now it is only a few lines of code to create a Rabi sequence:

awg = hdawg.awgs[0]
awg.set_sequence_params(
  sequence_type="Rabi",
  trigger_mode="None",
  repetitions=1e3,
  period=20e-6,
  pulse_amplitudes=np.linspace(0.0, 1.0, 101),
  pulse_width=20e-9,
  pulse_truncation=4,
)
awg.compile()
awg.run()
awg.wait_done()

Of course, it is possible to also create more complex sequences involving several AWGs. For more information, check the documentation here.

Open software

This software would not have been possible without the work of the community that developed QCoDeS, Labber and all the researchers involved. That is why we are releasing these three packages as open software under the MIT license. It means that you can download, use and modify it as you like. We welcome your opinion using the Github Issues tracker and we will consider your pull requests if you have some modifications that can be helpful for everyone. If you publish an article using our software, we would appreciate if you cite us using the DOI present in the Github pages. If you create a software that includes one of these packages, please add the license file to your work,

You can find the source code on our Github page:

We would like to thank the Microsoft quantum computing consortium and the developers for QCoDeS for their help and support.
We thank Simon Gustavsson for his help with Labber.