# Relaxation time T{sub}`1` Using {mod}`.pulsed` mode, we measure the energy-relaxation time $T_1$ of the qubit. The qubit-control pulse is a $\pi$ pulse with a $\sin^2$ envelope. The delay $\delta$ between the control pulse and the resonator-readout pulse is swept. The readout pulse is at the frequency of the readout resonator and has a square envelope. ![T1 pulse sequence](images/T1_pulse_sequence.svg){align=center} The class for performing the $T_1$ experiment is available at [presto-measure/t1.py][t1.py]. Here, we run the experiment and observe the exponential decay of the qubit population. We 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 `T1` to match your experiment and change `presto_address` to match the IP address of your Presto: ```python from t1 import T1 import numpy as np experiment = T1( readout_freq=6.2e9, control_freq=4.2e9, readout_amp=0.1, control_amp=0.5, readout_duration=2.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 = T1.load("data/t1_20220404_130724.h5") ``` In either case, we analyze the data to get a nice plot: ```python experiment.analyze() ``` ```{image} images/t1_light.svg :align: center :class: only-light ``` ```{image} images/t1_dark.svg :align: center :class: only-dark ``` The qubit starts close to the excited state at zero control-readout delay $\delta = 0~\mu s$, and exponentially decays towards the ground state for increasing $\delta$. Data is fitted to an exponentially-decaying function and relaxation time $T_1$ is extracted. The complex-valued readout signal is rotated using {func}`.utils.rotate_opt` so that all the information about the qubit state is in the I quadrature. ## Code explanation Here we discuss the main part of the code of the `T1` class: the definition of the experiment sequence. The full source is available at [presto-measure/t1.py][t1.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. ::: We implement the variable delay in the $T_1$ measurement with a single `for` loop: ```python T = 0.0 # s, start at time zero ... for delay in self.delay_arr: # π pulse pls.output_pulse(T, control_pulse) T += self.control_duration # increasing delay T += delay # readout pls.output_pulse(T, readout_pulse) pls.store(T + self.readout_sample_delay) T += self.readout_duration # Wait for decay T += self.wait_delay ``` As usual, we first output the qubit-control pulse and then we perform the readout. This time, however, we increase the time `T` in between the two pulses to achieve a variable delay between control and readout. --- {meth}`~.Pulsed.run` executes the experiment sequence. We set `repeat_count=1` since the whole pulse sequence is already programmed in the for loop. ```python pls.run(period=T, repeat_count=1, num_averages=self.num_averages) ``` [t1.py]: https://github.com/intermod-pro/presto-measure/blob/master/t1.py