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
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/20230713_EspectrosCristal6iones/Data/')
MOTIONAL_FILES = """000013259-UV_Scan_withcal_optimized_andor
000013260-UV_Scan_withcal_optimized_andor
000013261-UV_Scan_withcal_optimized_andor
000013262-UV_Scan_withcal_optimized_andor
000013263-UV_Scan_withcal_optimized_andor
000013264-UV_Scan_withcal_optimized_andor
000013266-UV_Scan_withcal_optimized_andor
000013267-UV_Scan_withcal_optimized_andor
000013268-UV_Scan_withcal_optimized_andor
000013269-UV_Scan_withcal_optimized_andor
000013270-UV_Scan_withcal_optimized_andor
000013271-UV_Scan_withcal_optimized_andor
000013272-UV_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 = []
UV_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']))
CountsRoi3.append(np.array(data['datasets']['counts_roi3']))
CountsRoi4.append(np.array(data['datasets']['counts_roi4']))
CountsRoi5.append(np.array(data['datasets']['counts_roi5']))
CountsRoi6.append(np.array(data['datasets']['counts_roi6']))
CountsRoi7.append(np.array(data['datasets']['counts_roi7']))
UV_Freqs.append(np.array(data['datasets']['UV_Frequencies']))
#IR_amps.append(np.array(data['datasets']['IR1_measurement_amp']))
#%%
"""
En cristal de 7 iones (uno de ellos oscuro) veo espectros. Primero espectros uv.
La roi1 es la general. Las demas son de cada uno de los 6 ioens brillantes del cristal.
"""
i = 0
jvec=[0,1,2,3,5]
step=0.1e8
Desplazamientos = [0, 0.8*step, 1*step, -1*step, -2*step]
plt.figure()
for j in jvec:
if i in [2,4]:
#plt.errorbar(Amplitudes[j], CountsRoi1[j], yerr=np.sqrt(CountsRoi1[j]), color='red', fmt='-o', capsize=2, markersize=2)
#plt.plot(Amplitudes[j][1:], CountsRoi1[j][1:], 'o',color='red', markersize=2,label=f'UVamp: {UV_amps[j]}')
plt.plot([Desplazamientos[i]+f for f in UV_Freqs[j][1:]], CountsRoi3[j][1:], '-o', markersize=2)
i = i + 1
plt.xlabel('Frecuencia')
plt.ylabel('Cuentas ROI')
#plt.xlim(0.05,0.23)
#plt.ylim(7800,8550)
plt.grid()
plt.legend()
#%%
#mergeo mediciones porque medi variando el piezoB para tener mas rango
Frequencies_vector = []
Counts_vector = []
kfin1 = 37
kin2 = 9
for counts in [CountsRoi1, CountsRoi2, CountsRoi3, CountsRoi4, CountsRoi5, CountsRoi6, CountsRoi7]:
Frequencies_vector.append([1e-6*2*f for f in [Desplazamientos[4]+f for f in UV_Freqs[5][1:kfin1]]+list(UV_Freqs[2][kin2:])])
Counts_vector.append(list(counts[5][1:kfin1])+list(counts[2][kin2:]))
ivecs = [3,4]
#ivecs = [2, 5, 6]
#ivecs = [1]
plt.figure()
for i in range(len(Frequencies_vector)):
if i in ivecs:
plt.plot(Frequencies_vector[i], Counts_vector[i],'-o')
plt.grid()
plt.xlabel('Frequency (MHz)')
plt.ylabel('Counts')
#%%
ftrap=22.1
#ahora intento ajustarlos con modelo con micromocion
from scipy.special import jv
from scipy.optimize import curve_fit
def MicromotionSpectra(det, A, beta, x0, gamma, offset):
ftrap=22.1
#gamma=30
P = A*(jv(0, beta)**2)/(((det-x0)**2)+(0.5*gamma)**2)+offset
i = 1
#print(P)
while i <= 1:
P = P + A*((jv(i, beta))**2)/((((det-x0)+i*ftrap)**2)+(0.5*gamma)**2) + A*((jv(-i, beta))**2)/((((det-x0)-i*ftrap)**2)+(0.5*gamma)**2)
i = i + 1
#print(P)
return P
popt_vec = []
pcov_vec = []
#uso como refe k=3
jref=3
popt_ref, pcov_ref = curve_fit(MicromotionSpectra, Frequencies_vector[jref], Counts_vector[jref], p0=[1000, 2, 274, 90, 14000], bounds=((0,0,200,20,0),(1e7,100,600,1000,25650)))
freqslong = np.arange(min(Frequencies_vector[jref]), max(Frequencies_vector[jref])+100, (Frequencies_vector[jref][1]-Frequencies_vector[jref][0])*0.01)
print(popt_ref)
plt.figure()
for j in range(1,len(Frequencies_vector)):
plt.plot(Frequencies_vector[j], Counts_vector[j])
if j == jref:
plt.plot(freqslong, MicromotionSpectra(freqslong, *popt_ref))
for i in range(5):
plt.axvline(popt_ref[2]-i*ftrap, linestyle='dashed', color='black', linewidth=1, zorder=0)
plt.grid()
#%%
for i in range(len(Frequencies_vector)):
if i != jref:
popt, pcov = curve_fit(MicromotionSpectra, Frequencies_vector[i], Counts_vector[i], p0=[popt_ref[0], 5, popt_ref[2], 60, popt_ref[4]], bounds=((popt_ref[0]-0.001*popt_ref[0],0,popt_ref[2]-0.001*popt_ref[2],0,popt_ref[4]-0.001*popt_ref[4]),(popt_ref[0]+0.001*popt_ref[0],100,popt_ref[2]+0.001*popt_ref[2],300, popt_ref[4]+0.001*popt_ref[4])))
popt_vec.append(popt)
pcov_vec.append(pcov)
else:
popt_vec.append(popt_ref)
pcov_vec.append(pcov_ref)
ftrap=22.1
jeval=1
freqslong = np.arange(min(Frequencies_vector[jeval]), max(Frequencies_vector[jeval])+100, (Frequencies_vector[jeval][1]-Frequencies_vector[jeval][0])*0.01)
print(popt_vec[jeval])
plt.figure()
plt.plot(Frequencies_vector[jeval], Counts_vector[jeval])
plt.plot(freqslong, MicromotionSpectra(freqslong, *popt_ref))
plt.axvline(popt_ref[2], linestyle='dashed')
plt.axvline(popt_ref[2]-ftrap, linestyle='dashed')
plt.axvline(popt_ref[2]+ftrap, linestyle='dashed')
plt.axvline(popt_ref[2]-2*ftrap, linestyle='dashed')
plt.axvline(popt_ref[2]+2*ftrap, linestyle='dashed')
plt.axvline(popt_ref[2]-3*ftrap, linestyle='dashed')
plt.axvline(popt_ref[2]+3*ftrap, linestyle='dashed')