Newer
Older
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import h5py
import matplotlib.pyplot as plt
import numpy as np
import sys
import re
import ast
from scipy.optimize import curve_fit
import os
# Solo levanto algunos experimentos
ALL_FILES_SP = """000008358-SingleLine
000008359-SingleLine
000008360-SingleLine
000008361-SingleLine
000008362-SingleLine
000008363-SingleLine
000008364-SingleLine
000008365-SingleLine
000008366-SingleLine
000008367-SingleLine
000008368-SingleLine
000008369-SingleLine
000008370-SingleLine
000008372-SingleLine
000008373-SingleLine
000008374-SingleLine
000008375-SingleLine
000008376-SingleLine
000008377-SingleLine
000008378-SingleLine
000008379-SingleLine
000008380-SingleLine
000008381-SingleLine
000008382-SingleLine
"""
#000001504-SingleLine.h5
def expo(T, tau, N0, C):
global T0
return N0*np.exp(-(T-T0)/tau) + C
def pow_from_amp(amp):
"""Paso de amplitud urukul a potencia medida por Nico"""
# Forma altamente ineficiente de hacer esto, pero me salio asi
amplitudes_UV = np.flip(np.array([0.08, 0.10, 0.12, 0.14, 0.16, 0.18, 0.20, 0.22, 0.24, 0.26, 0.28, 0.30]))
assert amp in amplitudes_UV
potencias_UV = np.flip(np.array([4, 10, 19, 32, 49, 71, 96, 125, 155, 183, 208, 229]))
return potencias_UV[np.where(amplitudes_UV == amp)][0]
"""
plt.plot(amplitudes_UV, potencias_UV, 'ko-', lw=0.2)
plt.xlabel("Amplitud Urukul")
plt.ylabel("Potencia /uW")
plt.grid()
"""
#%%
## Mostrar corte de los histos:
# fig, ax = plt.subplots()
# ax.axvline(T0, color='k')
#os.chdir('/home/oem/Documentos/Doctorado/Artiq/Repositorio/artiq_experiments/artiq_master/results/2021-07-02/17')
BINW = 20e-9
T0 = 0e-6
TotalHeights = []
TotalBins = []
UVampVec = [0.1, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.27, 0.06, 0.08, 0.10, 0.12, 0.14, 0.16, 0.18, 0.20, 0.22, 0.24, 0.26]
for i, fname in enumerate(ALL_FILES_SP.split()):
#print(i)
#print(fname)
data = h5py.File(fname+'.h5', 'r') # Leo el h5: Recordar que nuestros datos estan en 'datasets'
counts = np.array(data['datasets']['counts'])
bines = np.arange(counts.min(), counts.max()+BINW, BINW)
heigs, binsf = np.histogram(counts, bines[bines>T0])
TotalHeights.append(heigs)
TotalBins.append(binsf)
plt.figure()
plt.plot([t*1e6 for t in TotalBins[12][:-1]], TotalHeights[12],'o')
#%%
#Selected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
#Selected = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
Selected = [20, 21, 22, 23]
plt.figure()
for j in Selected:
plt.plot([t*1e6 for t in TotalBins[j][:-1]], TotalHeights[j])
plt.xlim(-0.1, 5)
#%%
allamps = np.array([])
allpows = np.array([])
alltaus = np.array([])
allN0 = np.array([])
fig0, [ax0, ax1_a] = plt.subplots(1, 2)
ax1_b = ax1_a.twinx()
ax0.step([t*1e6 for t in binsf[:-1]], heigs, label=f"AMP: {laser_UV_amp}", where='mid',
color=f"C{i}", lw=0.5, alpha=0.4)
popt, pcov = curve_fit(expo, binsf[:-1], heigs, p0=(2e-6, 400, 300))
print(popt) # tau, N0, C
ax0.plot([t*1e6 for t in binsf], expo(binsf, *popt), label=f"tau: {popt[0]}",
color=f"C{i}", ls='-', lw=1, zorder=99)
allamps = np.append(allamps, laser_UV_amp)
laser_pow = pow_from_amp(laser_UV_amp)
allpows = np.append(allpows, laser_pow)
alltaus = np.append(alltaus, popt[0])
allN0 = np.append(allN0, popt[1])
ax1_a.plot(laser_pow , 1e6*popt[0], 'o', color=f"C{i}", ms=5, )
ax1_b.plot(laser_pow, popt[1], '^', color=f"C{i}", ms=7, )
ax1_a.plot(allpows, [t*1e6 for t in alltaus], 'k-', lw=0.2, zorder=0)
ax1_b.plot(allpows, allN0, 'k-', lw=0.2, zorder=0)
# plt.annotate(f"bin: {BINW}", (0,5e-5, 700), fontsize=14)
ax0.set_xlabel("Tiempo (us)")
ax0.set_ylabel("Cuentas")
ax1_a.set_xlabel("Potencia [uW]")
ax1_a.set_ylabel("Tau (circulo) (us)")
ax1_b.set_ylabel("Alturas (triang)")
ax1_a.grid(alpha=0.3)
# plt.show()
plt.figure()
plt.plot(allpows, allN0/alltaus, 'ko-', lw=0.2)
plt.grid(alpha=0.3)
plt.xlabel("Potencia [uW]")
plt.ylabel("Alturas/Tau")
plt.show()
#input()