{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Example Q1: Configuring a Channel Library from Scratch \n", "This example notebook shows how, using QGL, one can configure a measurement system. All configuration occurs within the notebook, but interfaces with the QGL `ChannelLibrary` object that uses the `bbndb` package database backend.\n", "\n", "© Raytheon BBN Technologies 2018" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Creating a Channel Library " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `AWGDir` environment variable is used to indicate where QGL will store it's output sequence files. First we load the QGL module. It defaults to a temporary directory as provided by Python's `tempfile` module." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "AWG_DIR environment variable not defined. Unless otherwise specified, using temporary directory for AWG sequence file outputs.\n" ] } ], "source": [ "from QGL import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next we instantiate the channel library. By default `bbndb` will use an sqlite database at the location specified by the `BBN_DB` environment variabe, but we override this behavior below in order to use a temporary in memory database for testing purposes." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Creating engine...\n" ] } ], "source": [ "cl = ChannelLibrary(\":memory:\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The channel library has a number of convenience functions defined for create instruments and qubits, as well as functions to define the relationships between them. Let us create a qubit first:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "q1 = cl.new_qubit(\"q1\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Later on we will see how to save and load other versions of the channel library, so remember that *this reference will become stale if other library versions are loaded*. After creation it is safest to refer to channels using keyword syntax on the channel library, i.e. `cl[\"q1\"]`. We'll discuss this more later. Now we create some instrumentation: AWGs, a digitizer, and some microwave sources" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# Most calls required label and address\n", "aps2_1 = cl.new_APS2(\"BBNAPS1\", address=\"192.168.5.101\") \n", "aps2_2 = cl.new_APS2(\"BBNAPS2\", address=\"192.168.5.102\")\n", "dig_1 = cl.new_X6(\"X6_1\", address=0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There is more general syntax for arbitrary instruments:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# Label, instrument type, address, and an additional config parameter\n", "h1 = cl.new_source(\"Holz1\", \"HolzworthHS9000\", \"HS9004A-009-1\", power=-30)\n", "h2 = cl.new_source(\"Holz2\", \"HolzworthHS9000\", \"HS9004A-009-2\", power=-30) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we want to define which instruments control what." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "# Qubit q1 is controlled by AWG aps2_1, and uses microwave source h1\n", "cl.set_control(q1, aps2_1, generator=h1)\n", "# Qubit q1 is measured by AWG aps2_2 and digitizer dig_1, and uses microwave source h2\n", "cl.set_measure(q1, aps2_2, dig_1.ch(1), generator=h2)\n", "# The AWG aps2_1 is the master AWG, and distributes a synchronization trigger on its second marker channel\n", "cl.set_master(aps2_1, aps2_1.ch(\"m2\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "These objects are linked to one another, and belong to a relational database. Therefore once can easily drill through the heirarchy using typical \"dot\" attribute access. i.e. we can configure the sidebanding of q1 using the following:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "cl[\"q1\"].measure_chan.frequency = 10e6" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "All of the object above have been added to the current database session, but must be committed in order to be made permanent. That can be done as follows:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "cl.commit()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "At this point the channel database is automatically saved to the \"working\" copy. All of the current channel libraries can be listed (along with their ID and date stamp) with:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
id | Year | Date | Time | Name |
---|---|---|---|---|
1 | 2019 | Apr. 18 | 11:24:26 AM | working |