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
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/20230804_RotationalDopplerShift_v2/Data')
"""
en este codigo ploteo espectros CPT de resonancias D-D para configuracion +2/+2 y +2/-2 (usando pentaprisma)
"""
def find_nearest(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return idx
LOC_FILES = """VaryingBeamlocation/000014331-IR_Scan_withcal_optimized
VaryingBeamlocation/000014332-IR_Scan_withcal_optimized
VaryingBeamlocation/000014333-IR_Scan_withcal_optimized
VaryingBeamlocation/000014334-IR_Scan_withcal_optimized
VaryingBeamlocation/000014357-IR_Scan_withcal_optimized
VaryingBeamlocation/000014358-IR_Scan_withcal_optimized
"""
def Split(array,n):
length=len(array)/n
splitlist = []
jj = 0
while jj<length:
partial = []
ii = 0
while ii < n:
partial.append(array[jj*n+ii])
ii = ii + 1
splitlist.append(partial)
jj = jj + 1
return splitlist
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(LOC_FILES))
#carpeta pc nico labo escritorio:
#C:\Users\Usuario\Documents\artiq\artiq_experiments\analisis\plots\20211101_CPT_DosLaseres_v03\Data
LocCounts = []
LocFrequencies = []
for i, fname in enumerate(LOC_FILES.split()):
print(str(i) + ' - ' + fname)
data = h5py.File(fname+'.h5', 'r')
#Amplitudes.append(np.array(data['datasets']['amplitudes']))
LocCounts.append(np.array(data['datasets']['counts_spectrum']))
LocFrequencies.append(np.array(data['datasets']['IR1_Frequencies']))
def linealfunc(x,a,b):
return a*x+b
def normalizeplot(xvec, yvec,skip=0):
i_1, i_2, i_3, i_4 = 0, 20, -10-skip, -1-skip
popt, pcov = curve_fit(linealfunc, list(xvec[i_1:i_2])+list(xvec[i_3:i_4]), list(yvec[i_1:i_2])+list(yvec[i_3:i_4]))
print(popt)
yvecnorm = []
for jj in range(len(yvec)):
print(linealfunc(xvec[jj],*popt))
yvecnorm.append(yvec[jj]/linealfunc(xvec[jj],*popt))
return yvecnorm
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
#%%
"""
Resonancias DD configuracion +2/+2
"""
powermedvec = [0,1,2,3]
AmpsVecs = ['Colineal', 'Desplazada', 'Colineal', 'Desplazada']
plt.figure()
ftrap = 22.1
DR1 = 435.8
DR2 = 444.2
jj=0
for med in powermedvec:
plt.plot([2*f*1e-6 for f in LocFrequencies[med][1:]], [c for c in LocCounts[med][1:]], '-o', markersize=2, label=f'{AmpsVecs[jj]}')
jj=jj+1
plt.xlabel('Frecuencia (MHz)')
plt.ylabel('Counts')
plt.grid()
plt.legend()
plt.title('Espectros para distintas geometrías')
#%%
"""
Resonancias DD configuracion +2/-2 (usando un pentaprisma)
"""
powermedvec = [4,5]
AmpsVecs = ['Colineal', 'Desplazada']
plt.figure()
ftrap = 22.1
DR1 = 435.8
DR2 = 444.2
jj=0
for med in powermedvec:
plt.plot([2*f*1e-6 for f in LocFrequencies[med][1:]], [c for c in LocCounts[med][1:]], '-o', markersize=2, label=f'{AmpsVecs[jj]}')
jj=jj+1
plt.xlabel('Frecuencia (MHz)')
plt.ylabel('Counts')
plt.grid()
plt.legend()
plt.title('Espectros para distintas geometrías')
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
#%%
"""
Resonancias DD comparando +2/+2 con +2/-2 ambas colineales
"""
powermedvec = [2,4]
AmpsVecs = ['Colineal', 'Desplazada']
plt.figure()
ftrap = 22.1
DR1 = 435.8
DR2 = 444.2
jj=0
for med in powermedvec:
Freqs = [2*f*1e-6 for f in LocFrequencies[med][1:]]
Counts = [c for c in LocCounts[med][1:]]
CountsNorm = normalizeplot(Freqs,Counts)
plt.plot(Freqs,CountsNorm, '-o', markersize=2, label=f'{AmpsVecs[jj]}')
jj=jj+1
plt.xlabel('Frecuencia (MHz)')
plt.ylabel('Counts')
plt.grid()
plt.legend()
plt.title('Espectros para distintas geometrías')