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
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
# Solo levanto algunos experimentos
Calib_Files = """000007155-UV_Scan_withcalib_Haeffner
000007160-UV_Scan_withcalib_Haeffner
000007161-UV_Scan_withcalib_Haeffner
000007163-UV_Scan_withcalib_Haeffner
000007165-UV_Scan_withcalib_Haeffner
000007198-UV_Scan_withcalib_Haeffner
000007209-UV_Scan_withcalib_Haeffner
000007211-UV_Scan_withcalib_Haeffner
000007212-UV_Scan_withcalib_Haeffner"""
#carpeta pc nico labo escritorio:
#C:\Users\Usuario\Documents\artiq\artiq_experiments\analisis\plots\20220503_EspectrosUVnuevos\Data
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()))
#%%
Amps = []
Freqs = []
Counts = []
T_readouts = []
for i, fname in enumerate(Calib_Files.split()):
print(SeeKeys(Calib_Files))
print(i)
print(fname)
data = h5py.File(fname+'.h5', 'r') # Leo el h5: Recordar que nuestros datos estan en 'datasets'
print(list(data['datasets'].keys()))
Amps.append(np.array(data['datasets']['UV_Amplitudes']))
Freqs.append(np.array(data['datasets']['UV_Frequencies']))
Counts.append(np.array(data['datasets']['counts_spectrum']))
T_readouts.append(np.array(data['datasets']['t_readout']))
#def GetBackground(countsper100ms, )
#%%
from scipy.special import jv
def Lorentzian(f, A, x0, gamma, offset):
return (A/np.pi)*0.5*gamma/(((f-x0)**2)+((0.5*gamma)**2)) + offset #40 es el piso de ruido estimado
jvec = [8] #UV_cooling en 90 MHz
plt.figure()
for j in jvec:
FreqsChosen = [2*f*1e-6 for f in Freqs[j]]
CountsChosen = Counts[j]
portion = 0.
popt, pcov = curve_fit(Lorentzian, FreqsChosen[int(portion*len(FreqsChosen)):], CountsChosen[int(portion*len(FreqsChosen)):], p0=[12000, 208, 30, 30])
freqslong = np.arange(min(FreqsChosen)-10, max(FreqsChosen)+10, (FreqsChosen[1]-FreqsChosen[0])*0.01)
plt.errorbar(FreqsChosen, CountsChosen, yerr=np.sqrt(np.array(CountsChosen)), fmt='o', capsize=5, markersize=5)
#plt.plot(freqslong, Lorentzian(freqslong, popt[0], popt[1], popt[2]), label=f'FWHM {round(popt[1])} MHz')
plt.plot(freqslong, Lorentzian(freqslong, popt[0], popt[1], popt[2], popt[3]), label=f'FWHM 30 MHz')
#plt.axvline(popt[2]-22.1, linestyle='--', linewidth=1)
#plt.axvline(popt[2]+22.1, linestyle='--', linewidth=1)
plt.xlabel('Frecuencia (MHz)')
plt.ylabel('Cuentas')
plt.legend()
print(f'Ancho medido: {round(popt[2])} MHz')
#%%
from scipy.special import jv
from scipy.optimize import curve_fit
def Lorentzian(f, A, gamma, x0):
return (A/np.pi)*0.5*gamma/(((f-x0)**2)+((0.5*gamma)**2))
def MicromotionSpectra(det, A, beta, x0):
ftrap=22.1
gamma=23
P = A*(jv(0, beta)**2)/(((det-x0)**2)+(0.5*gamma)**2)+100
i = 1
#print(P)
while i <= 2:
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
jvec = [7] #UV_cooling en 90 MHz
"""
plt.figure()
for j in jvec:
FreqsChosen = [2*f*1e-6 for f in Freqs[j]]
CountsChosen = Counts[j]
portion = 0.
popt, pcov = curve_fit(Lorentzian, FreqsChosen[int(portion*len(FreqsChosen)):], CountsChosen[int(portion*len(FreqsChosen)):], p0=[12000, 25, 208, 30])
freqslong = np.arange(min(FreqsChosen)-10, max(FreqsChosen)+10, (FreqsChosen[1]-FreqsChosen[0])*0.01)
plt.errorbar(FreqsChosen, CountsChosen, yerr=np.sqrt(np.array(CountsChosen)), fmt='o', capsize=5, markersize=5)
#plt.plot(freqslong, Lorentzian(freqslong, popt[0], popt[1], popt[2]), label=f'FWHM {round(popt[1])} MHz')
plt.plot(freqslong, Lorentzian(freqslong, popt[0], popt[1], popt[2], popt[3]), label=f'FWHM 30 MHz')
plt.axvline(popt[2]+2*22.1, linestyle='--', linewidth=1)
plt.axvline(popt[2]+22.1, linestyle='--', linewidth=1)
plt.xlabel('Frecuencia (MHz)')
plt.ylabel('Cuentas')
plt.legend()
print(f'Ancho medido: {round(popt[1])} MHz')
"""
plt.figure()
for j in jvec:
FreqsChosen = [2*f*1e-6 for f in Freqs[j]]
CountsChosen = Counts[j]
portion = 0.
popt, pcov = curve_fit(MicromotionSpectra, FreqsChosen[int(portion*len(FreqsChosen)):], CountsChosen[int(portion*len(FreqsChosen)):],p0=[200,4,220], bounds=((-1000,-10,-300),(1000,10,300)))
freqslong = np.arange(min(FreqsChosen)-10, max(FreqsChosen)+10, (FreqsChosen[1]-FreqsChosen[0])*0.01)
plt.errorbar(FreqsChosen, CountsChosen, yerr=np.sqrt(np.array(CountsChosen)), fmt='o', capsize=5, markersize=5)
#plt.plot(freqslong, Lorentzian(freqslong, popt[0], popt[1], popt[2]), label=f'FWHM {round(popt[1])} MHz')
plt.plot(freqslong, MicromotionSpectra(freqslong, *popt), label=f'FWHM 30 MHz')
#plt.axvline(popt[2]+2*22.1, linestyle='--', linewidth=1)
#plt.axvline(popt[2]+22.1, linestyle='--', linewidth=1)
plt.xlabel('Frecuencia (MHz)')
plt.ylabel('Cuentas')
plt.legend()
print(f'Ancho medido: {round(popt[1])} MHz')