-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathT1_VaryTstep.py
63 lines (54 loc) · 1.96 KB
/
T1_VaryTstep.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from matplotlib import pyplot as plt
import numpy as np
import h5py
from scipy.optimize import curve_fit
def func(x, a, b, c, d):
return a*np.exp(-(x-c)/b) + d
def func_dick(x, a, b, c, d, e, f):
return a*np.exp(-(x-c)/b)*np.exp(e*(np.exp(-(x-c)/f)-1)) + d
directory = 'D:\Data\Fluxonium #28\T1'
fname = '050718_T1_YOKO_delayVary_1.221mA_Cav7.3367GHz_-25dBm_Qubit3.869GHz_25dBm_PiPulse926ns_Count20_TimeStep_consec_sum1000.h5'
path = directory + '\\' + fname
pts_num = 20
time_step = 1000
t1_guess = 10e-6
t1_qp_guess = 1e-6
time = np.zeros(pts_num)
for i in range(pts_num):
var = i*(i+1.0)/2.0
time[i] = var*time_step
print (i)
print(var)
#Read data and fit
with h5py.File(path,'r') as hf:
print('List of arrays in this file: \n', hf.keys())
count = np.array(hf.get('count'))
phase_raw = hf.get('PHASEMAG_Phase0')
# print phase_raw
phase = phase_raw[0, 0][0:]
phase = np.unwrap(phase)*180/np.pi
phase = phase - np.min(phase)
phase = abs(phase[0::])
plt.figure(1)
plt.plot(time*1e-3, phase, 'd-')
guess = [phase[0]-phase[-1], t1_guess, 0, phase[-1]]
popt, pcov = curve_fit(func, time*1e-9, phase, guess)
a,b,c,d = popt #b is T1
time_nice = np.linspace(0, (pts_num+1)*pts_num*0.5*time_step, 1001)
phase_fit = func(time_nice*1e-9, a, b, c, d)
perr = np.sqrt(abs(np.diag(pcov)))
plt.plot(time_nice*1e-3, phase_fit)
plt.title(str( b*1e6)+ r'$\pm$' +str(perr[1]*1e6))
plt.tick_params(labelsize = 18.0)
plt.figure(2)
plt.plot(time*1e-3, phase, 'd-')
guess = [phase[0]-phase[-1], t1_guess, 0, phase[-1], 1, t1_qp_guess]
popt, pcov = curve_fit(func_dick, time*1e-9, phase, guess)
a,b,c,d,e,f = popt #b is T1
time_nice = np.linspace(0, (pts_num+1)*pts_num*0.5*time_step, 1001)
phase_fit = func_dick(time_nice*1e-9, *popt)
perr = np.sqrt(abs(np.diag(pcov)))
plt.plot(time_nice*1e-3, phase_fit)
plt.title(str( b*1e6)+ r'$\pm$' +str(perr[1]*1e6) + '\n' + str(f*1e6)+ r'$\pm$' +str(perr[5]*1e6)+ '; ' + str(e))
plt.tick_params(labelsize = 18.0)
plt.show()