Commit 613012b2de22b69ef6a3fbfca1aec6656754564f

Authored by bmarechal
1 parent 3c9512ae81
Exists in master

.

Showing 1 changed file with 8 additions and 8 deletions Side-by-side Diff

... ... @@ -11,8 +11,8 @@
11 11 data_iter = csv.reader(open(f, 'r'), delimiter = ',', quotechar = '"')
12 12 for i in range(2):
13 13 data_iter.next()
14   - temp_data = [value for value in data_iter] #if ends with a number
15   - #temp_data = [value[:-1] for value in data_iter]#if ends with a comma
  14 + #temp_data = [value for value in data_iter] #if ends with a number
  15 + temp_data = [value[:-1] for value in data_iter]#if ends with a comma
16 16 data.extend(temp_data)
17 17  
18 18 data = np.asarray(data, dtype = float)
... ... @@ -30,6 +30,12 @@
30 30 popt, pcov = curve_fit(func, data[data[:,0]>=0,0], data[data[:,0]>=0,1], p0 = [1e-5, 1e-2, 1e5, 1e10, 1e-4], maxfev=10000)
31 31 yfit = func(data[data[:,0]>=0,0], *popt)
32 32  
  33 +tau = float(popt[0])
  34 +Q = np.pi*299792458*tau/(2.*140e-3)
  35 +
  36 +#print(np.sqrt(np.diag(pcov)))
  37 +print(tau, Q)
  38 +
33 39 plt.plot(data[data[:,0]>=0,0], yfit, label ='fit')
34 40  
35 41 plt.xlabel('t')
... ... @@ -37,10 +43,4 @@
37 43 plt.grid(which='both')
38 44 plt.legend()
39 45 plt.show()
40   -
41   -tau = float(popt[0])
42   -Q = np.pi*299792458*tau/(2.*140e-3)
43   -
44   -#print(np.sqrt(np.diag(pcov)))
45   -print(tau, Q)