68 lines
1.7 KiB
Python
68 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
Created on Wed Feb 5 13:08:12 2025
|
|
|
|
@author: shen_t2
|
|
"""
|
|
|
|
|
|
import os
|
|
# os.chdir(os.path.abspath(os.path.dirname(__file__)))
|
|
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
plt.rcParams.update({'font.size': 14})
|
|
|
|
from scipy import optimize
|
|
|
|
|
|
# %%
|
|
|
|
MAIN_EXP_folder = 'C:/RE_qubit_TS/202510_T1_pair/20250208_T1/'
|
|
os.chdir(MAIN_EXP_folder)
|
|
|
|
timestampsuffix = '_02081615.npy'
|
|
|
|
time_scan = np.load('detection_delay_x_axis_0-120ms' + timestampsuffix) # in [us]
|
|
time_scan *= 1e-3 # in [ms]
|
|
|
|
# raw_count_rep = np.load('raw_counts_B150Gs_rep0_exc30ms_count3ms' + timestampsuffix)
|
|
actual_count_rep = np.load('actual_counts_B150Gs_rep0_exc30ms_count3ms' + timestampsuffix)
|
|
actual_count_rep /= np.max(actual_count_rep)
|
|
|
|
|
|
|
|
# %%
|
|
|
|
def _ExpDecay(t, tau):
|
|
return np.exp(-t/tau)
|
|
|
|
(popt, pcov, infodict, mesg, ier) = optimize.curve_fit(_ExpDecay, time_scan, actual_count_rep,
|
|
# p0 = [0, 1.88, 1.94, 5.5],
|
|
full_output=True)
|
|
# (popt, pcov, infodict, mesg, ier)
|
|
|
|
|
|
|
|
# %%
|
|
|
|
|
|
plt.figure(131, figsize=[9,6], dpi=100)
|
|
plt.clf()
|
|
# plt.plot(time_scan, raw_count_rep, '.-b', label= 'raw counts' )
|
|
plt.plot(time_scan, actual_count_rep, '.-r', label='Experiment' )
|
|
plt.plot(time_scan, _ExpDecay(time_scan, *popt), '--b', label='Fitted $T_1$ = {:.2f} ms'.format(popt[0]) )
|
|
|
|
plt.grid()
|
|
plt.legend(loc=1)
|
|
plt.title('$T_1$ measurement')
|
|
plt.xlabel('Detection delay time/ms')
|
|
plt.ylabel('Actual photon counts (normalized)')
|
|
plt.tight_layout()
|
|
|
|
plt.savefig( MAIN_EXP_folder + 'fitted_T1_{:.0f}ms{:}.jpg'.format(popt[0], timestampsuffix[:-4]) )
|
|
plt.show()
|
|
|
|
|
|
|