{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "ef429fa6", "metadata": { "execution": { "iopub.execute_input": "2025-06-13T13:20:48.287228Z", "iopub.status.busy": "2025-06-13T13:20:48.286879Z", "iopub.status.idle": "2025-06-13T13:20:48.291455Z", "shell.execute_reply": "2025-06-13T13:20:48.290801Z" }, "nbsphinx": "hidden" }, "outputs": [], "source": [ "# Copyright 2025 Keysight Technologies Inc." ] }, { "cell_type": "raw", "id": "60bfaaeb", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Interfacing with HDF5 files\n", "===========================\n", "After executing a program, its results can be exported from the database to a portable\n", "HDF5 file with the :py:meth:`~keysight.qcs.programs.Program.to_hdf5` method, as shown\n", "in :doc:`hello_hardware`\\. In this tutorial, we go over of the structure of these\n", "files." ] }, { "cell_type": "code", "execution_count": 2, "id": "6474c849", "metadata": { "execution": { "iopub.execute_input": "2025-06-13T13:20:48.294533Z", "iopub.status.busy": "2025-06-13T13:20:48.294234Z", "iopub.status.idle": "2025-06-13T13:20:52.167229Z", "shell.execute_reply": "2025-06-13T13:20:52.165976Z" } }, "outputs": [], "source": [ "import h5py\n", "import keysight.qcs as qcs\n", "import numpy as np\n", "\n", "file = h5py.File(\"swept_program.hdf5\")" ] }, { "cell_type": "raw", "id": "ebef16ad", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Accessing the program and data through QCS\n", "------------------------------------------\n", "The program that was executed can be loaded from the file by calling\n", ":py:meth:`~keysight.qcs.utils.load`\\." ] }, { "cell_type": "code", "execution_count": 3, "id": "05a8eadc", "metadata": { "execution": { "iopub.execute_input": "2025-06-13T13:20:52.171418Z", "iopub.status.busy": "2025-06-13T13:20:52.170830Z", "iopub.status.idle": "2025-06-13T13:20:52.603844Z", "shell.execute_reply": "2025-06-13T13:20:52.603026Z" } }, "outputs": [], "source": [ "program = qcs.load(\"swept_program.hdf5\")" ] }, { "cell_type": "raw", "id": "b9cc1851", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "We can inspect the program that was executed." ] }, { "cell_type": "code", "execution_count": 4, "id": "fb534d11", "metadata": { "execution": { "iopub.execute_input": "2025-06-13T13:20:52.607433Z", "iopub.status.busy": "2025-06-13T13:20:52.607110Z", "iopub.status.idle": "2025-06-13T13:20:52.711115Z", "shell.execute_reply": "2025-06-13T13:20:52.710214Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", " \n", "\tkeysight-logo-svg\n", "\t\n", "\t\n", "\t\t\n", "\t\n", "\n", "\n", " \n", "
\n", " Program\n", "
\n", " \n", "\n", "\n", "\n", "
\n", " Program\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration89.375 ns
Layers1
Targets8
Repetitions\n", " Sweep with 11 repetitions\n", "
\n", " Associations\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
rfArray(name=freq_vals, shape=(11, 4), dtype=float, unit=none, value=[[3.85 GHz, 3.9 GHz, 3.95 GHz, 4 GHz], [3.89 GHz, 3.94 GHz, 3.99 GHz, 4.04 GHz], [3.93 GHz, 3.98 GHz, 4.03 GHz, 4.08 GHz], [3.97 GHz, 4.02 GHz, 4.07 GHz, 4.12 GHz], [4.01 GHz, 4.06 GHz, 4.11 GHz, 4.16 GHz], [4.05 GHz, 4.1 GHz, 4.15 GHz, 4.2 GHz], [4.09 GHz, 4.14 GHz, 4.19 GHz, 4.24 GHz], [4.13 GHz, 4.18 GHz, 4.23 GHz, 4.28 GHz], [4.17 GHz, 4.22 GHz, 4.27 GHz, 4.32 GHz], [4.21 GHz, 4.26 GHz, 4.31 GHz, 4.36 GHz], ... ])
\n", " Repeat with 10 repetitions\n", "
\n", "
\n", "
\n", "\n", "
\n", "
\n", "
\n", "
\n", " Layer #0\n", "
\n", " \n", "\n", "\n", "\n", "
\n", " Layer #0 \n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration89.375 ns
\n", "
\n", "\n", "
\n", "
\n", "
\n", " awgs\n", " \n", " 0\n", " \n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " RFWaveform on ('awgs', 0)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration80 ns
AmplitudeScalar(name=amps, value=0.2, dtype=float, unit=none)
FrequencyArray(name=rf, shape=(4,), dtype=float, unit=Hz, value=[4.05 GHz, 4.1 GHz, 4.15 GHz, 4.2 GHz])
EnvelopeGaussianEnvelope(4.0)
Instantaneous Phase0 rad
Post-phase0 rad
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " Delay on ('awgs', 0)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration9.375 ns
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", " 1\n", " \n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " RFWaveform on ('awgs', 1)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration80 ns
AmplitudeScalar(name=amps, value=0.2, dtype=float, unit=none)
FrequencyArray(name=rf, shape=(4,), dtype=float, unit=Hz, value=[4.05 GHz, 4.1 GHz, 4.15 GHz, 4.2 GHz])
EnvelopeGaussianEnvelope(4.0)
Instantaneous Phase0 rad
Post-phase0 rad
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " Delay on ('awgs', 1)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration9.375 ns
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", " 2\n", " \n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " RFWaveform on ('awgs', 2)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration80 ns
AmplitudeScalar(name=amps, value=0.2, dtype=float, unit=none)
FrequencyArray(name=rf, shape=(4,), dtype=float, unit=Hz, value=[4.05 GHz, 4.1 GHz, 4.15 GHz, 4.2 GHz])
EnvelopeGaussianEnvelope(4.0)
Instantaneous Phase0 rad
Post-phase0 rad
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " Delay on ('awgs', 2)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration9.375 ns
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", " 3\n", " \n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " RFWaveform on ('awgs', 3)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration80 ns
AmplitudeScalar(name=amps, value=0.2, dtype=float, unit=none)
FrequencyArray(name=rf, shape=(4,), dtype=float, unit=Hz, value=[4.05 GHz, 4.1 GHz, 4.15 GHz, 4.2 GHz])
EnvelopeGaussianEnvelope(4.0)
Instantaneous Phase0 rad
Post-phase0 rad
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " Delay on ('awgs', 3)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration9.375 ns
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", " digs\n", " \n", " 0\n", " \n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " Delay on ('digs', 0)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration9.375 ns
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " Acquisition on ('digs', 0)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration80 ns
Integration Filter\n", " \n", " \n", "\n", "\n", "\n", "
\n", " RFWaveform \n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration80 ns
Amplitude1
FrequencyArray(name=int_rf, shape=(4,), dtype=float, unit=Hz, value=[4.05 GHz, 4.1 GHz, 4.15 GHz, 4.2 GHz])
EnvelopeGaussianEnvelope(4.0)
Instantaneous Phase0 rad
Post-phase0 rad
\n", "
\n", "\n", "
ClassifierClassifier(Array(name=ref_pts, shape=(4, 2), dtype=complex, unit=none))
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", " 1\n", " \n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " Delay on ('digs', 1)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration9.375 ns
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " Acquisition on ('digs', 1)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration80 ns
Integration Filter\n", " \n", " \n", "\n", "\n", "\n", "
\n", " RFWaveform \n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration80 ns
Amplitude1
FrequencyArray(name=int_rf, shape=(4,), dtype=float, unit=Hz, value=[4.05 GHz, 4.1 GHz, 4.15 GHz, 4.2 GHz])
EnvelopeGaussianEnvelope(4.0)
Instantaneous Phase0 rad
Post-phase0 rad
\n", "
\n", "\n", "
ClassifierClassifier(Array(name=ref_pts, shape=(4, 2), dtype=complex, unit=none))
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", " 2\n", " \n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " Delay on ('digs', 2)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration9.375 ns
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " Acquisition on ('digs', 2)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration80 ns
Integration Filter\n", " \n", " \n", "\n", "\n", "\n", "
\n", " RFWaveform \n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration80 ns
Amplitude1
FrequencyArray(name=int_rf, shape=(4,), dtype=float, unit=Hz, value=[4.05 GHz, 4.1 GHz, 4.15 GHz, 4.2 GHz])
EnvelopeGaussianEnvelope(4.0)
Instantaneous Phase0 rad
Post-phase0 rad
\n", "
\n", "\n", "
ClassifierClassifier(Array(name=ref_pts, shape=(4, 2), dtype=complex, unit=none))
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", " 3\n", " \n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " Delay on ('digs', 3)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration9.375 ns
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", " \n", "
\n", " \n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", " Acquisition on ('digs', 3)\n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration80 ns
Integration Filter\n", " \n", " \n", "\n", "\n", "\n", "
\n", " RFWaveform \n", "
\n", "
\n", " Parameters\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Duration80 ns
Amplitude1
FrequencyArray(name=int_rf, shape=(4,), dtype=float, unit=Hz, value=[4.05 GHz, 4.1 GHz, 4.15 GHz, 4.2 GHz])
EnvelopeGaussianEnvelope(4.0)
Instantaneous Phase0 rad
Post-phase0 rad
\n", "
\n", "\n", "
ClassifierClassifier(Array(name=ref_pts, shape=(4, 2), dtype=complex, unit=none))
\n", "
\n", "\n", "\n", "
\n", "
\n", "
\n", "\n", "\n", "\n", "\n", "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": { "text/html": { "isolated": true } }, "output_type": "display_data" } ], "source": [ "program.draw()" ] }, { "cell_type": "raw", "id": "22d0d4ce", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "We can load the data. This will load from the hdf5 file, rather than the database." ] }, { "cell_type": "code", "execution_count": 5, "id": "8ec471d0", "metadata": { "execution": { "iopub.execute_input": "2025-06-13T13:20:52.715466Z", "iopub.status.busy": "2025-06-13T13:20:52.714938Z", "iopub.status.idle": "2025-06-13T13:20:53.096494Z", "shell.execute_reply": "2025-06-13T13:20:53.095383Z" }, "lines_to_next_cell": 2 }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
(((Channels(labels=[0], name=digs, absolute_phase=True))))...(((Channels(labels=[3], name=digs, absolute_phase=True))))
(rf, [3.85 GHz, 3.9 GHz, 3.95 GHz, ... ])...(rf, [4.25 GHz, 4.3 GHz, 4.35 GHz, ... ])
0123456789...0123456789
00.0079100.0076900.0068120.0081300.0050540.0059330.0074710.0081300.0087890.007471...0.0070310.0059330.0052730.0030760.0039550.0074710.0050540.0059330.0063720.005273
10.0076900.0072510.0072510.0083500.0083500.0079100.0070310.0090090.0065920.007690...0.0063720.0057130.0052730.0041750.0068120.0052730.0074710.0072510.0041750.005713
20.0092290.0059330.0068120.0052730.0076900.0083500.0068120.0076900.0061520.007471...0.0030760.0061520.0054930.0050540.0052730.0072510.0043950.0043950.0050540.003296
30.0070310.0096680.0101070.0065920.0065920.0096680.0081300.0068120.0098880.010547...0.0072510.0048340.0059330.0052730.0048340.0052730.0057130.0059330.0052730.005493
40.0083500.0065920.0057130.0107670.0079100.0072510.0072510.0096680.0074710.007031...0.0046140.0068120.0057130.0081300.0072510.0048340.0070310.0068120.0057130.005933
..................................................................
3790.0054930.0010990.0024170.0052730.0015380.0041750.0057130.0026370.0046140.002417...0.0081300.0039550.0052730.0070310.0083500.0087890.0087890.0070310.0083500.008789
3800.0008790.0015380.0013180.0028560.0030760.0048340.0035160.0032960.0035160.004395...0.0065920.0072510.0057130.0074710.0079100.0052730.0046140.0076900.0037350.005713
3810.0043950.0026370.0010990.0035160.0028560.0037350.0028560.0021970.0046140.002637...0.0092290.0057130.0072510.0076900.0068120.0057130.0068120.0059330.0061520.008130
3820.0057130.0035160.0006590.0032960.0041750.0015380.0041750.0017580.0000000.003296...0.0087890.0076900.0068120.0065920.0057130.0052730.0061520.0094480.0054930.006592
3830.0046140.0024170.0026370.0010990.0046140.0059330.0043950.0032960.0032960.001538...0.0070310.0085690.0068120.0065920.0059330.0076900.0054930.0048340.0059330.005273
\n", "

384 rows × 440 columns

\n", "
" ], "text/plain": [ " (((Channels(labels=[0], name=digs, absolute_phase=True)))) \\\n", " (rf, [3.85 GHz, 3.9 GHz, 3.95 GHz, ... ]) \n", " 0 1 \n", "0 0.007910 0.007690 \n", "1 0.007690 0.007251 \n", "2 0.009229 0.005933 \n", "3 0.007031 0.009668 \n", "4 0.008350 0.006592 \n", ".. ... ... \n", "379 0.005493 0.001099 \n", "380 0.000879 0.001538 \n", "381 0.004395 0.002637 \n", "382 0.005713 0.003516 \n", "383 0.004614 0.002417 \n", "\n", " \\\n", " \n", " 2 3 4 5 6 7 8 \n", "0 0.006812 0.008130 0.005054 0.005933 0.007471 0.008130 0.008789 \n", "1 0.007251 0.008350 0.008350 0.007910 0.007031 0.009009 0.006592 \n", "2 0.006812 0.005273 0.007690 0.008350 0.006812 0.007690 0.006152 \n", "3 0.010107 0.006592 0.006592 0.009668 0.008130 0.006812 0.009888 \n", "4 0.005713 0.010767 0.007910 0.007251 0.007251 0.009668 0.007471 \n", ".. ... ... ... ... ... ... ... \n", "379 0.002417 0.005273 0.001538 0.004175 0.005713 0.002637 0.004614 \n", "380 0.001318 0.002856 0.003076 0.004834 0.003516 0.003296 0.003516 \n", "381 0.001099 0.003516 0.002856 0.003735 0.002856 0.002197 0.004614 \n", "382 0.000659 0.003296 0.004175 0.001538 0.004175 0.001758 0.000000 \n", "383 0.002637 0.001099 0.004614 0.005933 0.004395 0.003296 0.003296 \n", "\n", " ... (((Channels(labels=[3], name=digs, absolute_phase=True)))) \\\n", " ... (rf, [4.25 GHz, 4.3 GHz, 4.35 GHz, ... ]) \n", " 9 ... 0 \n", "0 0.007471 ... 0.007031 \n", "1 0.007690 ... 0.006372 \n", "2 0.007471 ... 0.003076 \n", "3 0.010547 ... 0.007251 \n", "4 0.007031 ... 0.004614 \n", ".. ... ... ... \n", "379 0.002417 ... 0.008130 \n", "380 0.004395 ... 0.006592 \n", "381 0.002637 ... 0.009229 \n", "382 0.003296 ... 0.008789 \n", "383 0.001538 ... 0.007031 \n", "\n", " \\\n", " \n", " 1 2 3 4 5 6 7 \n", "0 0.005933 0.005273 0.003076 0.003955 0.007471 0.005054 0.005933 \n", "1 0.005713 0.005273 0.004175 0.006812 0.005273 0.007471 0.007251 \n", "2 0.006152 0.005493 0.005054 0.005273 0.007251 0.004395 0.004395 \n", "3 0.004834 0.005933 0.005273 0.004834 0.005273 0.005713 0.005933 \n", "4 0.006812 0.005713 0.008130 0.007251 0.004834 0.007031 0.006812 \n", ".. ... ... ... ... ... ... ... \n", "379 0.003955 0.005273 0.007031 0.008350 0.008789 0.008789 0.007031 \n", "380 0.007251 0.005713 0.007471 0.007910 0.005273 0.004614 0.007690 \n", "381 0.005713 0.007251 0.007690 0.006812 0.005713 0.006812 0.005933 \n", "382 0.007690 0.006812 0.006592 0.005713 0.005273 0.006152 0.009448 \n", "383 0.008569 0.006812 0.006592 0.005933 0.007690 0.005493 0.004834 \n", "\n", " \n", " \n", " 8 9 \n", "0 0.006372 0.005273 \n", "1 0.004175 0.005713 \n", "2 0.005054 0.003296 \n", "3 0.005273 0.005493 \n", "4 0.005713 0.005933 \n", ".. ... ... \n", "379 0.008350 0.008789 \n", "380 0.003735 0.005713 \n", "381 0.006152 0.008130 \n", "382 0.005493 0.006592 \n", "383 0.005933 0.005273 \n", "\n", "[384 rows x 440 columns]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "program.get_trace()" ] }, { "cell_type": "raw", "id": "f4cf14f9", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Inspecting the file directly\n", "----------------------------\n", "We can also use the hdf5 python library to inspect the file directly.\n", "The attributes of the HDF5 are accessed with the ``attrs`` property." ] }, { "cell_type": "code", "execution_count": 6, "id": "03391f62", "metadata": { "execution": { "iopub.execute_input": "2025-06-13T13:20:53.100086Z", "iopub.status.busy": "2025-06-13T13:20:53.099747Z", "iopub.status.idle": "2025-06-13T13:20:53.105187Z", "shell.execute_reply": "2025-06-13T13:20:53.104519Z" } }, "outputs": [ { "data": { "text/plain": [ "['Program', 'ChannelMapper', 'FPGAPostprocessing', 'Shape', 'Version']" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "list(file.attrs.keys())" ] }, { "cell_type": "raw", "id": "7a9949f3", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "The ``FPGAPostprocessing`` attribute specifies whether these results are obtained with\n", "(``True``) or without (``False``) hardware demodulation. The file contains either\n", "IQ or trace data, respectively. This file contains trace data." ] }, { "cell_type": "code", "execution_count": 7, "id": "150c2fc4", "metadata": { "execution": { "iopub.execute_input": "2025-06-13T13:20:53.108242Z", "iopub.status.busy": "2025-06-13T13:20:53.107959Z", "iopub.status.idle": "2025-06-13T13:20:53.113655Z", "shell.execute_reply": "2025-06-13T13:20:53.112983Z" } }, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "file.attrs[\"FPGAPostprocessing\"]" ] }, { "cell_type": "raw", "id": "00ada082", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "The ``Shape`` attribute describes how the program was repeated during execution and is\n", "similar to the shape of a program's\n", ":py:attr:`~keysight.qcs.programs.Program.repetitions`\\. As we flatten the data, this\n", "value describes how the data should be reshaped. For trace data the innermost value is\n", "set to :math:`-1` to account for different numbers of samples, following the\n", "the convention of, e.g., :py:meth:`numpy.reshape`\\." ] }, { "cell_type": "code", "execution_count": 8, "id": "d11ba57f", "metadata": { "execution": { "iopub.execute_input": "2025-06-13T13:20:53.116664Z", "iopub.status.busy": "2025-06-13T13:20:53.116388Z", "iopub.status.idle": "2025-06-13T13:20:53.121669Z", "shell.execute_reply": "2025-06-13T13:20:53.120820Z" } }, "outputs": [ { "data": { "text/plain": [ "array([[11, 10, -1]], dtype=int32)" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "file.attrs[\"Shape\"]" ] }, { "cell_type": "raw", "id": "09d59db8", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "The above value indicates that the trace data should be interpreted as an array of\n", "shape :math:`(11, 10, n / (11 * 10))`\\, where :math:`n` is the total number of data\n", "points.\n", "\n", "Finally, the ``Program`` and the ``ChannelMapper`` used during its execution are\n", "serialized and stored in the file.\n", "\n", "Datasets on the file\n", "--------------------\n", "The file structure is different dependent on whether the program contains IQ or trace\n", "data.\n", "\n", "Trace data\n", "^^^^^^^^^^\n", "An HDF5 file containing trace data will store each repeated acquisition in its own\n", "dataset. The datasets are stored in groups named\n", "``DutChannel_{channel_number}_Acquisition_{acquisition_number}`` that are keys of the\n", "file, each of which corresponds to a physical channel." ] }, { "cell_type": "code", "execution_count": 9, "id": "54f61eb4", "metadata": { "execution": { "iopub.execute_input": "2025-06-13T13:20:53.124715Z", "iopub.status.busy": "2025-06-13T13:20:53.124439Z", "iopub.status.idle": "2025-06-13T13:20:53.129208Z", "shell.execute_reply": "2025-06-13T13:20:53.128523Z" } }, "outputs": [ { "data": { "text/plain": [ "['DutChannel_20_Acquisition_0']" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "list(file.keys())" ] }, { "cell_type": "raw", "id": "a0308d19", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "This file contains a single group for the acquisitions on ``DutChannel_20``. The group\n", "has a dataset with no additional attributes named ``trace``." ] }, { "cell_type": "code", "execution_count": 10, "id": "815b5e12", "metadata": { "execution": { "iopub.execute_input": "2025-06-13T13:20:53.132225Z", "iopub.status.busy": "2025-06-13T13:20:53.131951Z", "iopub.status.idle": "2025-06-13T13:20:53.137521Z", "shell.execute_reply": "2025-06-13T13:20:53.136786Z" } }, "outputs": [ { "data": { "text/plain": [ "(42240,)" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "acquisition = file[\"DutChannel_20_Acquisition_0\"][\"trace\"]\n", "acquisition.shape" ] }, { "cell_type": "raw", "id": "3bb0f579", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "We then reshape to and display the innermost value, the number of samples per\n", "repetition." ] }, { "cell_type": "code", "execution_count": 11, "id": "317d2ba6", "metadata": { "execution": { "iopub.execute_input": "2025-06-13T13:20:53.140347Z", "iopub.status.busy": "2025-06-13T13:20:53.140071Z", "iopub.status.idle": "2025-06-13T13:20:53.145795Z", "shell.execute_reply": "2025-06-13T13:20:53.144611Z" } }, "outputs": [ { "data": { "text/plain": [ "384" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.reshape(acquisition, file.attrs[\"Shape\"][0]).shape[-1]" ] }, { "cell_type": "raw", "id": "dd353172", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "IQ data\n", "^^^^^^^\n", "We now load a file that contains results from the same program run with hardware\n", "demodulation." ] }, { "cell_type": "code", "execution_count": 12, "id": "2a5f96dd", "metadata": { "execution": { "iopub.execute_input": "2025-06-13T13:20:53.148870Z", "iopub.status.busy": "2025-06-13T13:20:53.148595Z", "iopub.status.idle": "2025-06-13T13:20:53.155114Z", "shell.execute_reply": "2025-06-13T13:20:53.154330Z" } }, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "file_demod = h5py.File(\"swept_program_demod.hdf5\")\n", "file_demod.attrs[\"FPGAPostprocessing\"]" ] }, { "cell_type": "raw", "id": "697f04e9", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Instead of using physical channels as keys, the IQ data uses virtual channels\n", "to label the groups as\n", "``Channel_{channel_name}_{channel_label}_Acquisition_{acquisition_number}``." ] }, { "cell_type": "code", "execution_count": 13, "id": "55f3f530", "metadata": { "execution": { "iopub.execute_input": "2025-06-13T13:20:53.158087Z", "iopub.status.busy": "2025-06-13T13:20:53.157802Z", "iopub.status.idle": "2025-06-13T13:20:53.162908Z", "shell.execute_reply": "2025-06-13T13:20:53.162155Z" } }, "outputs": [ { "data": { "text/plain": [ "['Channel_digs_0_Acquisition_0',\n", " 'Channel_digs_1_Acquisition_0',\n", " 'Channel_digs_2_Acquisition_0',\n", " 'Channel_digs_3_Acquisition_0']" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "list(file_demod.keys())" ] }, { "cell_type": "raw", "id": "607443fb", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "The IQ data is separated into real and imaginary parts." ] }, { "cell_type": "code", "execution_count": 14, "id": "6c6d98ea", "metadata": { "execution": { "iopub.execute_input": "2025-06-13T13:20:53.165838Z", "iopub.status.busy": "2025-06-13T13:20:53.165558Z", "iopub.status.idle": "2025-06-13T13:20:53.170767Z", "shell.execute_reply": "2025-06-13T13:20:53.169856Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n" ] } ], "source": [ "acquisition_demod = file_demod[\"Channel_digs_0_Acquisition_0\"]\n", "print(acquisition_demod[\"iq_real\"])\n", "print(acquisition_demod[\"iq_imaginary\"])" ] }, { "cell_type": "raw", "id": "e7c775e1", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "The shape of the IQ data is exactly the program's repetitions' shape." ] }, { "cell_type": "code", "execution_count": 15, "id": "332ef8d7", "metadata": { "execution": { "iopub.execute_input": "2025-06-13T13:20:53.173683Z", "iopub.status.busy": "2025-06-13T13:20:53.173406Z", "iopub.status.idle": "2025-06-13T13:20:53.179626Z", "shell.execute_reply": "2025-06-13T13:20:53.178745Z" } }, "outputs": [ { "data": { "text/plain": [ "(11, 10, 1)" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.reshape(acquisition_demod[\"iq_real\"], file_demod.attrs[\"Shape\"][0]).shape" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "raw_mimetype,nbsphinx,-all", "main_language": "python", "notebook_metadata_filter": "-all", "text_representation": { "extension": ".py", "format_name": "percent" } }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.15" } }, "nbformat": 4, "nbformat_minor": 5 }