From 446e6e188d9155f9b3f7d3dcb3fefee406816af1 Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Tue, 2 Jul 2024 05:48:25 +0200 Subject: [PATCH] Add pulses --- .../tutorials/includes/pulses/pulses0.py | 36 ++++++++++++ .../tutorials/includes/pulses/pulses1.py | 16 ++++++ doc/source/tutorials/pulses.rst | 55 +------------------ 3 files changed, 54 insertions(+), 53 deletions(-) create mode 100644 doc/source/tutorials/includes/pulses/pulses0.py create mode 100644 doc/source/tutorials/includes/pulses/pulses1.py diff --git a/doc/source/tutorials/includes/pulses/pulses0.py b/doc/source/tutorials/includes/pulses/pulses0.py new file mode 100644 index 000000000..9532f8aaf --- /dev/null +++ b/doc/source/tutorials/includes/pulses/pulses0.py @@ -0,0 +1,36 @@ +# pulses0.py + +from qibolab.pulses import ( + DrivePulse, + ReadoutPulse, + PulseSequence, + Rectangular, + Gaussian, +) + +# Define PulseSequence +sequence = PulseSequence() + +# Add some pulses to the pulse sequence +sequence.add( + DrivePulse( + start=0, + frequency=200000000, + amplitude=0.3, + duration=60, + relative_phase=0, + shape=Gaussian(5), + qubit=0, + ) +) +sequence.add( + ReadoutPulse( + start=70, + frequency=20000000.0, + amplitude=0.5, + duration=3000, + relative_phase=0, + shape=Rectangular(), + qubit=0, + ) +) diff --git a/doc/source/tutorials/includes/pulses/pulses1.py b/doc/source/tutorials/includes/pulses/pulses1.py new file mode 100644 index 000000000..1b69a5583 --- /dev/null +++ b/doc/source/tutorials/includes/pulses/pulses1.py @@ -0,0 +1,16 @@ +from qibolab import create_platform +from qibolab.execution_parameters import ExecutionParameters +from pulses0 import sequence + +# Define platform and load specific runcard +platform = create_platform("dummy") + +# Connects to lab instruments using the details specified in the calibration settings. +platform.connect() + +# Executes a pulse sequence. +options = ExecutionParameters(nshots=1000, relaxation_time=100) +results = platform.execute_pulse_sequence(sequence, options=options) + +# Disconnect from the instruments +platform.disconnect() \ No newline at end of file diff --git a/doc/source/tutorials/pulses.rst b/doc/source/tutorials/pulses.rst index 51fa61d76..443c6348a 100644 --- a/doc/source/tutorials/pulses.rst +++ b/doc/source/tutorials/pulses.rst @@ -6,42 +6,7 @@ defining a :class:`qibolab.pulses.PulseSequence` object and adding different pulses (:class:`qibolab.pulses.Pulse`) through the :func:`qibolab.pulses.PulseSequence.add()` method: -.. testcode:: python - - from qibolab.pulses import ( - DrivePulse, - ReadoutPulse, - PulseSequence, - Rectangular, - Gaussian, - ) - - # Define PulseSequence - sequence = PulseSequence() - - # Add some pulses to the pulse sequence - sequence.add( - DrivePulse( - start=0, - frequency=200000000, - amplitude=0.3, - duration=60, - relative_phase=0, - shape=Gaussian(5), - qubit=0, - ) - ) - sequence.add( - ReadoutPulse( - start=70, - frequency=20000000.0, - amplitude=0.5, - duration=3000, - relative_phase=0, - shape=Rectangular(), - qubit=0, - ) - ) +.. literalinclude:: ./includes/pulses/pulses0.py The next step consists in connecting to a specific lab in which the pulse sequence will be executed. In order to do this we allocate a platform object @@ -55,23 +20,7 @@ After connecting and setting up the platform's instruments using the local oscillators and the ``execute`` method will execute the previous defined pulse sequence according to the number of shots ``nshots`` specified. -.. testcode:: python - - from qibolab import create_platform - from qibolab.execution_parameters import ExecutionParameters - - # Define platform and load specific runcard - platform = create_platform("dummy") - - # Connects to lab instruments using the details specified in the calibration settings. - platform.connect() - - # Executes a pulse sequence. - options = ExecutionParameters(nshots=1000, relaxation_time=100) - results = platform.execute_pulse_sequence(sequence, options=options) - - # Disconnect from the instruments - platform.disconnect() +.. literalinclude:: ./includes/pulses/pulses1.py Remember to turn off the instruments and disconnect from the lab using the ``stop()`` and ``disconnect()`` methods of the platform.