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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
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
from scipy import interpolate
#Mediciones barriendo angulo del TISA y viendo kicking de resonancias oscuras
#C:\Users\Usuario\Documents\artiq\artiq_experiments\analisis\plots\20220106_CPT_DosLaseres_v08_TISA_DR\Data
os.chdir('/home/nico/Documents/artiq_experiments/analisis/plots/20230720_EspectrosCristal2iones/Data/')
MOTIONAL_FILES = """000013489-IR_Scan_withcal_optimized_andor
000013490-IR_Scan_withcal_optimized_andor
000013491-IR_Scan_withcal_optimized_andor
000013493-IR_Scan_withcal_optimized_andor
000013494-IR_Scan_withcal_optimized_andor
000013479-IR_Scan_withcal_optimized_andor
"""
def SeeKeys(files):
for i, fname in enumerate(files.split()):
data = h5py.File(fname+'.h5', 'r') # Leo el h5: Recordar que nuestros datos estan en 'datasets'
print(fname)
print(list(data['datasets'].keys()))
print(SeeKeys(MOTIONAL_FILES))
#carpeta pc nico labo escritorio:
#C:\Users\Usuario\Documents\artiq\artiq_experiments\analisis\plots\20211101_CPT_DosLaseres_v03\Data
CountsRoi1 = []
CountsRoi2 = []
CountsRoi3 = []
CountsRoi4 = []
CountsRoi5 = []
CountsRoi6 = []
CountsRoi7 = []
#Amplitudes = []
IR1_Freqs = []
#IR_amps = []
for i, fname in enumerate(MOTIONAL_FILES.split()):
print(str(i) + ' - ' + fname)
data = h5py.File(fname+'.h5', 'r')
#Amplitudes.append(np.array(data['datasets']['amplitudes']))
CountsRoi1.append(np.array(data['datasets']['counts_roi1']))
CountsRoi2.append(np.array(data['datasets']['counts_roi2']))
IR1_Freqs.append(np.array(data['datasets']['IR1_Frequencies']))
#%%
"""
En cristal de 2 iones veo espectros cpt.
"""
medvec = [5]
plt.figure()
ftrap = 22.1
for med in medvec:
CountsRois = [CountsRoi1[med], CountsRoi2[med]]
#CountsRois = [CountsRoi1[med]]
#CountsRois = [CountsRoi2[med]]
i=0
for counts in CountsRois:
plt.plot([2*f*1e-6 for f in IR1_Freqs[0][1:]], [c for c in counts[1:]], '-o', markersize=2)
i=i+1
plt.xlabel('Frecuencia')
plt.ylabel('Cuentas ROI')
#plt.xlim(0.05,0.23)
#plt.ylim(15550,16400)
plt.grid()
plt.legend()
#%%
"""
En cristal de 2 iones veo espectros cpt.
"""
medvec = [5]
plt.figure()
ftrap = 22.1
for med in medvec:
CountsRois = [CountsRoi1[med], CountsRoi2[med]]
#CountsRois = [CountsRoi1[med]]
#CountsRois = [CountsRoi2[med]]
i=0
for counts in CountsRois:
plt.plot([2*f*1e-6 for f in IR1_Freqs[0][1:]], [c for c in counts[1:]], '-o', markersize=2)
i=i+1
plt.axvline(415.5)
plt.axvline(423)
plt.axvline(429)
plt.axvline(438.5)
plt.axvline(415.5+ftrap, color='red')
plt.axvline(423+ftrap, color='red')
plt.axvline(429+ftrap, color='red')
plt.axvline(438.5+ftrap, color='red')
plt.axvline(415.5-ftrap, color='red')
plt.axvline(423-ftrap, color='red')
plt.axvline(429-ftrap, color='red')
plt.axvline(438.5-ftrap, color='red')
plt.xlabel('Frecuencia')
plt.ylabel('Cuentas ROI')
#plt.xlim(430,445)
#plt.ylim(15550,16400)
plt.grid()
plt.legend()
#%%
#from EITfit.MM_eightLevel_2repumps_AnalysisFunctions import PerformExperiment_8levels_MM, GenerateNoisyCPT_MM_fit
from scipy.optimize import curve_fit
from time import time as titi
"""
Ajusto un cpt para obtener todos los parámetros relevantes primero.
I fit a cpt curve to retrieve all the relevant parameters first.
"""
phidoppler, titadoppler = 0, 90
phirepump, titarepump = 0, 0
phiprobe = 0
titaprobe = 90
gPS, gPD, = 2*np.pi*21.58e6, 2*np.pi*1.35e6
alpha = 0
noiseamplitude = 0
T = 0.6e-3
sg = 0.544
sp = 4.5
sr = 0
DetRepump = 0
lw = 0.1
DopplerLaserLinewidth, RepumpLaserLinewidth, ProbeLaserLinewidth = lw, lw, lw #ancho de linea de los laseres
u = 33.5e6
beta = 0
drivefreq = 2*np.pi*22.135e6
correccion = 6 #probe de 1 a 12 y 6 es la mejor
offsetxpi = 450+correccion
#DetDoppler = -20.5 -correccion
FreqsDRpi = [2*f*1e-6-offsetxpi for f in IR1_Freqs[0][1:]]
CountsDRpi = CountsRois[0][1:]
freqslongpi = np.arange(min(FreqsDRpi), max(FreqsDRpi)+FreqsDRpi[1]-FreqsDRpi[0], 0.1*(FreqsDRpi[1]-FreqsDRpi[0]))
#[1.71811842e+04 3.34325038e-17]
def FitEITpi(freqs, DetDoppler, SG, SP, temp, BETA):
#temp = 1e-3
#BETA=0
DetDoppler
MeasuredFreq, MeasuredFluo = PerformExperiment_8levels_MM(SG, SP, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, temp, alpha, phidoppler, titadoppler, phiprobe, titaprobe, BETA, drivefreq, min(freqs), max(freqs), freqs[1]-freqs[0])
scale = 2.77115328e+05
offset = 1.43353974e+04
FinalFluo = [f*scale + offset for f in MeasuredFluo]
return FinalFluo
t1 = titi()
popt_fullcpt, pcov_fullcpt = curve_fit(FitEITpi, FreqsDRpi, CountsDRpi, p0=[-21, 0.5, 8, 1e-3, 1], bounds=((-40, 0, 0, 0, 0), (0, 2, 20, 15e-3, 5)))
t2 = titi()
#print(f'Temperatura: ({round(1e3*popt_fullcpt[-1],2)} +- {round(1e3*np.sqrt(pcov_fullcpt[-1][-1]),2)}) mK')
print('done', correccion, f', took {round(t2-t1)} seconds')
#popt_fullcpt = array([1.17888250e+05, 1.92746338e+03, 6.15041437e-01, 7.41895643e+00, 1.97990392e-04, 7.14734207e-01]) #este anda bien
#FittedEITpi = FitEITpi(freqslongpi, 3.4e4, 1.6e4, 0.5, 8, 1e-3, 0)
FittedEITpi = FitEITpi(freqslongpi, *popt_fullcpt)
"""
Ploteo la CPT de referencia junto al ajuste y a la resonancia oscura de interes
I plot the reference CPT along with the fit to the model and the dark resonance of interest
"""
#i_DR = 955
DRs = [-42.5, -33.5, -27, -19]
plt.figure()
plt.errorbar(FreqsDRpi, CountsDRpi, yerr=0.1*np.sqrt(CountsDRpi), color='purple', alpha=0.6, fmt='o', capsize=2, markersize=2)
plt.plot(freqslongpi, FittedEITpi[1:], linewidth=2, color='purple')
# for dr in DRs:
# dr = dr
# plt.axvline(dr, color='black',alpha=0.5)
# plt.axvline(dr+22.135, color='blue',alpha=0.3)
# plt.axvline(dr-22.135, color='red',alpha=0.3)
#plt.axvline(DetDoppler-22.135)
#plt.axvline(DetDoppler+22.135)
#plt.plot(freqslongpi[i_DR], FittedEITpi[i_DR],'o', color='red', markersize=12)
plt.xlabel('Detuning (MHz)', fontsize=15)
plt.ylabel('Counts', fontsize=15)
plt.grid()
#plt.title(f'correccion: {correccion}')
#plt.title(f'Sdop: {round(popt[0], 2)}, Spr: {round(popt[1], 2)}, T: {round(popt[2]*1e3, 2)} mK, detDop: {DetDoppler} MHz')