# Ramsey T{sub}`2`* Using {mod}`.pulsed` mode, we measure Ramsey oscillations. We send two $\pi/2$ pulses separated by a variable delay $\delta$. The frequency of the pulses is detuned from the qubit frequency by the oscillation frequency of the Ramsey fringes. The $\pi/2$ pulses have a $\sin^2$ envelope, while the readout pulse is at the frequency of the readout resonator and has a square envelope. ![Ramsey pulse sequence](images/Ramsey_pulse_sequence.svg){align=center} The full code of the Ramsey experiment is available at [presto-measure/ramsey_single.py][ramsey_single.py]. Here we run the experiment and fit the resulting data, and then have a look at the main parts of the code. You can create a new experiment and run it on your Presto. Be sure to change the parameters of `RamseySingle` to match your experiment and change `presto_address` to match the IP address of your Presto: ```python from ramsey_single import RamseySingle import numpy as np experiment = RamseySingle( readout_freq=6.2e9, control_freq=4.2e9, readout_amp=0.1, control_amp=0.25, readout_duration=1e-6, control_duration=100e-9, sample_duration=2.5e-6, delay_arr=np.linspace(0, 50e-6, 101), readout_port=1, control_port=4, sample_port=1, wait_delay=100e-6, readout_sample_delay=0e-9, num_averages=100, ) presto_address = "192.168.88.65" # your Presto IP address save_filename = experiment.run(presto_address) ``` Or you can also load older data: ```python experiment = RamseySingle.load("data/ramsey_single_20220401_213253.h5") ``` In either case, we analyze the data to get a nice plot: ```python experiment.analyze() ``` ```{image} images/ramsey_single_light.svg :align: center :class: only-light ``` ```{image} images/ramsey_single_dark.svg :align: center :class: only-dark ``` We fit the data to an exponentially-decaying cosine function and we extract the Ramsey decay time $T_2^*$ and the qubit frequency detuning $\Delta$. ## Code explanation Here we discuss the core part of the code under the hood of the `RamseySingle` class: the scheduling of the pulse sequence. The full source is available at [presto-measure/ramsey_single.py][ramsey_single.py]. :::{note} If this is your first measurement in {mod}`.pulsed` mode, you might want to first have a look at the [Rabi amplitude](rabi_amp) chapter in this tutorial. There we describe the code more pedagogically and in more detail. ::: Since we are using only one frequency and one amplitude for each output pulse, programming the experimental sequence is just about timing the output of the pulses. We sweep the delay between two identical qubit-control pules in a `for` loop: ```python T = 0.0 # s, start at time zero ... for delay in self.delay_arr: # first π/2 pulse pls.output_pulse(T, control_pulse) T += self.control_duration T += delay # variable delay # second π/2 pulse pls.output_pulse(T, control_pulse) T += self.control_duration # readout pls.output_pulse(T, readout_pulse) pls.store(T + self.readout_sample_delay) T += self.readout_duration T += self.wait_delay # wait for decay ``` [ramsey_single.py]: https://github.com/intermod-pro/presto-measure/blob/master/ramsey_single.py