Download
Download this file as Jupyter notebook: live_plotting.ipynb.
Live Plotting
The QCS is able to display live plots for the IQ data of programs while they are
running.
Currently the only programs capable of running live plots are one-dimensional
and two-dimensional software sweeps. The
HclBackend
must also be set with
hw_demod = True
.
In order to enable live plotting, set the live_plotting_config
parameter
on HclBackend
with the channels to visualize.
Live plotting on a program
[2]:
import keysight.qcs as qcs
import numpy as np
[3]:
# Define a channel mapper or load one from file.
channel_mapper_exists = False
if channel_mapper_exists:
mapper = qcs.load("<path/to/channel_mapper.qcs>")
else:
# generate an empty channel mapper with the correct address
mapper = qcs.ChannelMapper("127.0.0.1")
readout_pulse_channels = qcs.Channels([0, 1], "readout_pulse", absolute_phase=True)
readout_acquisition_channels = qcs.Channels(
[0, 1], "readout_acquisition", absolute_phase=True
)
[4]:
# Define a program to run
program = qcs.Program()
frequency = qcs.Scalar("frequency", dtype=float)
waveform = qcs.RFWaveform(80e-9, qcs.GaussianEnvelope(), 1, frequency)
int_filter = qcs.RFWaveform(80e-9, qcs.GaussianEnvelope(), 1, [5.1e9, 5.15e9])
program.add_waveform(waveform, readout_pulse_channels)
program.add_acquisition(int_filter, readout_acquisition_channels)
program.n_shots(50)
frequencies = qcs.Array("frequencies", value=np.linspace(5e9, 5.25e9, 50))
program.sweep(frequencies, frequency)
program.draw()
Program
Program
|
||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Layer #0
Layer #0
|
||||||||||||||||||
|
|
RFWaveform on ('readout_pulse', 0)
Parameters
|
||||||||||||||||
|
RFWaveform on ('readout_pulse', 1)
Parameters
|
|||||||||||||||||
|
|
Acquisition on ('readout_acquisition', 0)
Parameters
|
||||||||||||||||
|
Acquisition on ('readout_acquisition', 1)
Parameters
|
[5]:
# Setup live plotting to display the two digitizer channels
backend = qcs.HclBackend(
channel_mapper=mapper,
hw_demod=True,
live_plotting_config=readout_acquisition_channels,
)
[6]:
# Set this to True if connected to hardware
run_on_hw = False
if run_on_hw:
# Execute the program.
# While running, live IQ data for the frequency sweep will be shown.
program_result = qcs.Executor(backend).execute(program)
# Plot the "static" version of the plot to compare the results
program_result.plot_iq(channel_subplots=False, plot_type="linear")
Live plotting on an experiment
Live plotting can also be setup to run on experiments. Here we show an example of setting up live plotting to run with a 2D spectroscopy experiment. See Resonator Spectroscopy for more details on setting up this experiment.
[7]:
qubits = qcs.Qudits([0, 1])
calibration_set = qcs.experiments.make_calibration_set(qubits=len(qubits))
[8]:
# Create a resonator spectroscopy experiment with live plotting
# Note that the channels for live plotting match the channels from the calibration set.
backend = qcs.HclBackend(
channel_mapper=mapper,
hw_demod=True,
live_plotting_config=readout_acquisition_channels,
)
res_spectroscopy2D = qcs.experiments.ResonatorSpectroscopy2D(
backend=backend,
calibration_set=calibration_set,
qubits=qubits,
operation="measurement",
)
[9]:
# Draw the program to view the operations to be performed on hardware
res_spectroscopy2D.draw()
Program
Program
|
||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Layer #0
Layer #0
|
||||||||||||||||||||||||||
|
|
Delay on ('readout_pulse', 0)
Parameters
|
RFWaveform on ('readout_pulse', 0)
Parameters
|
Delay on ('readout_pulse', 0)
Parameters
|
||||||||||||||||||||||
|
Delay on ('readout_pulse', 1)
Parameters
|
RFWaveform on ('readout_pulse', 1)
Parameters
|
Delay on ('readout_pulse', 1)
Parameters
|
|||||||||||||||||||||||
|
|
Delay on ('readout_acquisition', 0)
Parameters
|
Acquisition on ('readout_acquisition', 0)
Parameters
|
Delay on ('readout_acquisition', 0)
Parameters
|
||||||||||||||||||||||
|
Delay on ('readout_acquisition', 1)
Parameters
|
Acquisition on ('readout_acquisition', 1)
Parameters
|
Delay on ('readout_acquisition', 1)
Parameters
|
Next, we define the sweep values for both the amplitude and frequency of the readout pulse.
[10]:
# Retrieve the readout frequencies stored in the calibration set for the target qubits
current_freq = res_spectroscopy2D.calibration_set.variables.readout_frequencies[
[0, 1]
].value
# Set the range for sweeping the readout pulse frequency
start_frequency = current_freq - 200e6
end_frequency = current_freq + 200e6
freq_steps = 9
freq_scan_values = np.linspace(start_frequency, end_frequency, freq_steps)
[11]:
# Set the range for sweeping the readout pulse amplitude (units = V)
start_amplitude = 0.1 if len(qubits) == 1 else [0.1] * len(qubits)
end_amplitude = 1 if len(qubits) == 1 else [1] * len(qubits)
ampl_steps = 10
ampl_scan_values = np.linspace(start_amplitude, end_amplitude, ampl_steps)
[12]:
# Configure the repetitions for this experiment
res_spectroscopy2D.configure_repetitions(
frequencies=freq_scan_values,
frequency_name="readout_frequencies",
amplitudes=ampl_scan_values,
amplitude_name="readout_pulse_amplitudes",
n_shots=10,
)
We can now execute the experiment and see the live 2D heatmaps.
[13]:
if run_on_hw:
res_spectroscopy2D.execute()
Download
Download this file as Jupyter notebook: live_plotting.ipynb.