Commit 4e10ff12 authored by Nicolas Nunez Barreto's avatar Nicolas Nunez Barreto

todo

parent f024d1f0
......@@ -12,7 +12,7 @@ from scipy import interpolate
#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/20230912_RotationalDopplerShift_v6/Data')
#os.chdir('/home/nico/Documents/artiq_experiments/analisis/plots/20230912_RotationalDopplerShift_v6/Data')
"""
......@@ -78,12 +78,30 @@ PiezoHSFrequencies = []
BkgCounts = []
BkgFrequencies = []
Bkg2Counts = []
Bkg2Frequencies = []
#4 potencias de IR2, 0.13, 0.15, 0.17, 0.19 amps de IR2
Piezo3Counts1 = []
Piezo3Frequencies1 = []
Piezo3Counts2 = []
Piezo3Frequencies2 = []
Piezo3Counts3 = []
Piezo3Frequencies3 = []
Piezo3Counts4 = []
Piezo3Frequencies4 = []
PIEZOS1_FILES = [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]
PIEZOS2_FILES_LOWPOWER = [65,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,801,803,805,807,809,811]
PIEZOS2_FILES_HIGHPOWER = [65, 66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,800,802,804,806,808,810,812]
PIEZOS2_FILES_LOWPOWER = [65,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,801,803,805,807,809,811]+list(np.arange(813,851,2))
PIEZOS2_FILES_HIGHPOWER = [65, 66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,800,802,804,806,808,810,812]+list(np.arange(814,852,2))
PIEZOS3_FILES_POT1 = [51,55,59,66,70,80,84,88,93,97,901,905,909,913,917,921,925,929,933,937]
PIEZOS3_FILES_POT2 = [52,56,63,67,71,81,85,89,94,98,902,906,910,914,918,922,926,930,934,938]
PIEZOS3_FILES_POT3 = [53,57,64,68,72,82,86,90,95,99,903,907,911,915,919,923,927,931,935,939]
PIEZOS3_FILES_POT4 = [54,58,65,69,73,83,87,91,96,900,904,908,912,916,920,924,928,932,936,940]
BKG2 = [74]
BKG = [96]
......@@ -123,12 +141,64 @@ for i in PIEZOS2_FILES_HIGHPOWER:
Piezo2Frequencieshigh.append(np.array(data['datasets']['IR1_Frequencies']))
for i in PIEZOS3_FILES_POT1:
#print(str(i) + ' - ' + fname)
if i < 100 and i > 9:
data = h5py.File(f'VaryingBeamsize/Size3verticalvspow/0000158{i}-IR_Scan_withcal_optimized'+'.h5', 'r')
elif i <= 9:
data = h5py.File(f'VaryingBeamsize/Size3verticalvspow/00001580{i}-IR_Scan_withcal_optimized'+'.h5', 'r')
else:
data = h5py.File(f'VaryingBeamsize/Size3verticalvspow/000015{i}-IR_Scan_withcal_optimized'+'.h5', 'r')
Piezo3Counts1.append(np.array(data['datasets']['counts_spectrum']))
Piezo3Frequencies1.append(np.array(data['datasets']['IR1_Frequencies']))
for i in PIEZOS3_FILES_POT2:
#print(str(i) + ' - ' + fname)
if i < 100 and i > 9:
data = h5py.File(f'VaryingBeamsize/Size3verticalvspow/0000158{i}-IR_Scan_withcal_optimized'+'.h5', 'r')
elif i <= 9:
data = h5py.File(f'VaryingBeamsize/Size3verticalvspow/00001580{i}-IR_Scan_withcal_optimized'+'.h5', 'r')
else:
data = h5py.File(f'VaryingBeamsize/Size3verticalvspow/000015{i}-IR_Scan_withcal_optimized'+'.h5', 'r')
Piezo3Counts2.append(np.array(data['datasets']['counts_spectrum']))
Piezo3Frequencies2.append(np.array(data['datasets']['IR1_Frequencies']))
for i in PIEZOS3_FILES_POT3:
#print(str(i) + ' - ' + fname)
if i < 100 and i > 9:
data = h5py.File(f'VaryingBeamsize/Size3verticalvspow/0000158{i}-IR_Scan_withcal_optimized'+'.h5', 'r')
elif i <= 9:
data = h5py.File(f'VaryingBeamsize/Size3verticalvspow/00001580{i}-IR_Scan_withcal_optimized'+'.h5', 'r')
else:
data = h5py.File(f'VaryingBeamsize/Size3verticalvspow/000015{i}-IR_Scan_withcal_optimized'+'.h5', 'r')
Piezo3Counts3.append(np.array(data['datasets']['counts_spectrum']))
Piezo3Frequencies3.append(np.array(data['datasets']['IR1_Frequencies']))
for i in PIEZOS3_FILES_POT4:
#print(str(i) + ' - ' + fname)
if i < 100 and i > 9:
data = h5py.File(f'VaryingBeamsize/Size3verticalvspow/0000158{i}-IR_Scan_withcal_optimized'+'.h5', 'r')
elif i <= 9:
data = h5py.File(f'VaryingBeamsize/Size3verticalvspow/00001580{i}-IR_Scan_withcal_optimized'+'.h5', 'r')
else:
data = h5py.File(f'VaryingBeamsize/Size3verticalvspow/000015{i}-IR_Scan_withcal_optimized'+'.h5', 'r')
Piezo3Counts4.append(np.array(data['datasets']['counts_spectrum']))
Piezo3Frequencies4.append(np.array(data['datasets']['IR1_Frequencies']))
for i in BKG:
#print(str(i) + ' - ' + fname)
data = h5py.File(f'VaryingBeamsize/Size3/0000155{i}-IR_Scan_withcal_optimized'+'.h5', 'r')
BkgCounts.append(np.array(data['datasets']['counts_spectrum']))
BkgFrequencies.append(np.array(data['datasets']['IR1_Frequencies']))
for i in BKG2:
#print(str(i) + ' - ' + fname)
data = h5py.File(f'VaryingBeamsize/Size3verticalvspow/0000158{i}-IR_Scan_withcal_optimized'+'.h5', 'r')
Bkg2Counts.append(np.array(data['datasets']['counts_spectrum']))
Bkg2Frequencies.append(np.array(data['datasets']['IR1_Frequencies']))
def ErrorDRdepth(p, f, b):
ep = np.sqrt(p)
ef = np.sqrt(f)
......@@ -167,7 +237,9 @@ plotcurvita = 1
plt.figure()
bkg=1*np.mean(Piezo1Counts[4][-6:-1])
bkg2=np.mean(Bkg2Counts[0][76:])
bkg3=np.mean(list(Bkg2Counts[0][76:])+list(Piezo1Counts[4][-6:-1]))
pmdepthsdrver2=[]
errorpmdepthsdrver2=[]
......@@ -381,7 +453,493 @@ plt.plot(np.arange(0,len(Intensityver1),1), [i/np.max(Intensityver1) for i in In
plt.errorbar(np.arange(0,len(Intensityver1),1), [p for p in pmdepthsdrver1], yerr= errorpmdepthsdrver1, fmt='o', color='navy',alpha=1, capsize=3, markersize=8)
plt.plot(np.arange(0,len(Intensityver2),1), [i/np.max(Intensityver2) for i in Intensityver2], '-o',color='firebrick',markersize=8,alpha=0.5)
plt.errorbar(np.arange(0,len(Intensityver2),1), [p for p in pmdepthsdrver2], yerr= errorpmdepthsdrver2, fmt='o', color='firebrick',alpha=1,capsize=3, markersize=8)
#plt.xlim(-0.5, 30)
plt.xlim(-0.5, 36)
plt.ylim(-0.1,1.1)
plt.grid()
#%%
"""
Ahora voy a intentar ajustarlas con una lorentziana que es mejor
"""
import seaborn as sns
"""
Resonancias DD configuracion +2/-2 colineal variando la ubicacion del ion en los haces
Moviendo VERTICALMENTE el haz, pasos de a 50 (updated), lente 200 mm, haz chiquito.
Esto es para 4 potencias de IR2 distintas. La pot de IR1 es constante.
Las amps son 0.13, 0.15, 0.17, 0.19 para 1, 2, 3 y 4 respectivamente
"""
pmlocmedvec31 = np.arange(0,len(PIEZOS3_FILES_POT1),1)
#pmlocmedvec31 = [4]
plotcurvita = 0
plt.figure()
#bkg=1*np.mean(Piezo1Counts[4][-6:-1])
bkg2=np.mean(Bkg2Counts[0][76:])
bkg=np.mean(list(Bkg2Counts[0][76:])+list(Piezo1Counts[4][-6:-1]))
pmdepthsdrver31=[]
errorpmdepthsdrver31=[]
Intensityver31 = []
errorIntensityver31 = []
Gamas31 = []
ErrorGamas31 = []
jj=0
for med in pmlocmedvec31:
Freqs = [2*f*1e-6 for f in Piezo3Frequencies1[med][1:]]
Counts = [c for c in Piezo3Counts1[med][1:]]
if med == 0:
# popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-265,1700,435.5,0.,0), bounds=((-10000,0,435.,0,0),(0,1e4, 436, 100,1)))
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0.1), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1)))
elif med == 1:
# Counts = Counts[20:120]
# Freqs= Freqs[20:120]
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.5,0), bounds=((-10000,0,435.5,0.05,0),(0,1e4, 436.1, 1,1e3)))
elif med == 2:
# Counts = Counts[20:]
# Freqs= Freqs[20:]
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1e3)))
elif med == 4:
# Counts = Counts[50:150]
# Freqs= Freqs[50:150]
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1e4)))
else:
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0.1), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1e4)))
if med==0:
pmdepthsdrver31.append(1-(np.min(Lorentzian(np.array(Freqs),*popt))-bkg)/(popt[1]-bkg))
#errorpmdepthsdrver1.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
errorpmdepthsdrver31.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
else:
pmdepthsdrver31.append(1-(np.min(Lorentzian(np.array(Freqs),*popt))-bkg)/(popt[1]-bkg))
#errorpmdepthsdrver1.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
errorpmdepthsdrver31.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
Intens31 = popt[1]
Gamas31.append(popt[3])
ErrorGamas31.append(np.sqrt(pcov[3,3]))
Intensityver31.append(Intens31)
# errorIntensity.append(2*np.sqrt(np.mean(Piezo1Counts[med][1:][0:20]))+np.sqrt(bkg))
if med not in [1000]:
plt.plot([2*f*1e-6 for f in Piezo3Frequencies1[med][1:]], [c for c in Piezo3Counts1[med][1:]], '-o', markersize=2, alpha=0.7)
plt.plot([f*1 for f in Freqs],Lorentzian(Freqs,*popt))
plt.axhline(bkg,linestyle='dashed',color='k')
jj=jj+1
plt.grid()
if plotcurvita:
plt.figure()
plt.errorbar(np.arange(0,len(Intensityver31),1), [i/np.max(Intensityver31) for i in Intensityver31], yerr=np.sqrt(Intensityver31)/np.max(Intensityver31), fmt='-o', capsize=3,markersize=8)
plt.errorbar(np.arange(0,len(Intensityver31),1), [p for p in pmdepthsdrver31], yerr= errorpmdepthsdrver31, fmt='o', capsize=3, markersize=8)
#plt.errorbar(np.arange(0,len(Intensityver31),1), [p for p in Gamas31], yerr=ErrorGamas31, fmt='o', capsize=3, markersize=8)
plt.xlabel('Ion position')
plt.ylabel('Intensity / DR Relative depth')
#plt.xticks([1,2,3,4,5])
#plt.xlim(200,3200)
plt.ylim(-0.1,1.1)
plt.grid()
#plt.axvline(3, color='salmon')
plt.legend()
# plt.figure()
# plt.errorbar(np.arange(0,len(Intensityver1)-1,1), [p*1e3 for p in Gamas1[1:]], yerr=[e*1e3 for e in ErrorGamas1[1:]], fmt='o', capsize=3, markersize=3)
# plt.yscale('log')
# plt.grid()
# plt.yticks([1e3, 1e2, 1e1])
#%%
"""
Ahora voy a intentar ajustarlas con una lorentziana que es mejor
"""
import seaborn as sns
"""
Resonancias DD configuracion +2/-2 colineal variando la ubicacion del ion en los haces
Moviendo VERTICALMENTE el haz, pasos de a 50 (updated), lente 200 mm, haz chiquito.
Esto es para 4 potencias de IR2 distintas. La pot de IR1 es constante.
Las amps son 0.13, 0.15, 0.17, 0.19 para 1, 2, 3 y 4 respectivamente
"""
pmlocmedvec32 = np.arange(0,len(PIEZOS3_FILES_POT2),1)
# pmlocmedvec32 = [4]
plotcurvita = 1
plt.figure()
#bkg=1*np.mean(Piezo1Counts[4][-6:-1])
bkg2=np.mean(Bkg2Counts[0][76:])
bkg=np.mean(list(Bkg2Counts[0][76:])+list(Piezo1Counts[4][-6:-1]))
pmdepthsdrver32=[]
errorpmdepthsdrver32=[]
Intensityver32 = []
errorIntensityver32 = []
Gamas32 = []
ErrorGamas32 = []
jj=0
for med in pmlocmedvec32:
Freqs = [2*f*1e-6 for f in Piezo3Frequencies2[med][1:]]
Counts = [c for c in Piezo3Counts2[med][1:]]
if med == 0:
# popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-265,1700,435.5,0.,0), bounds=((-10000,0,435.,0,0),(0,1e4, 436, 100,1)))
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0.1), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1)))
elif med == 1:
# Counts = Counts[20:120]
# Freqs= Freqs[20:120]
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.5,0), bounds=((-10000,0,435.5,0.05,0),(0,1e4, 436.1, 1,1e3)))
elif med == 2:
# Counts = Counts[20:]
# Freqs= Freqs[20:]
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1e3)))
elif med == 4:
# Counts = Counts[50:150]
# Freqs= Freqs[50:150]
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1e4)))
else:
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0.1), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1e4)))
if med==0:
pmdepthsdrver32.append(1-(np.min(Lorentzian(np.array(Freqs),*popt))-bkg)/(popt[1]-bkg))
#errorpmdepthsdrver1.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
errorpmdepthsdrver32.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
else:
pmdepthsdrver32.append(1-(np.min(Lorentzian(np.array(Freqs),*popt))-bkg)/(popt[1]-bkg))
#errorpmdepthsdrver1.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
errorpmdepthsdrver32.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
Intens32 = popt[1]
Gamas32.append(popt[3])
ErrorGamas32.append(np.sqrt(pcov[3,3]))
Intensityver32.append(Intens32)
# errorIntensity.append(2*np.sqrt(np.mean(Piezo1Counts[med][1:][0:20]))+np.sqrt(bkg))
if med not in [1000]:
plt.plot([2*f*1e-6 for f in Piezo3Frequencies2[med][1:]], [c for c in Piezo3Counts2[med][1:]], '-o', markersize=2, alpha=0.7)
plt.plot([f*1 for f in Freqs],Lorentzian(Freqs,*popt))
plt.axhline(bkg,linestyle='dashed',color='k')
jj=jj+1
plt.grid()
if plotcurvita:
plt.figure()
plt.errorbar(np.arange(0,len(Intensityver32),1), [i/np.max(Intensityver32) for i in Intensityver32], yerr=np.sqrt(Intensityver32)/np.max(Intensityver32), fmt='-o', capsize=3,markersize=8)
plt.errorbar(np.arange(0,len(Intensityver32),1), [p for p in pmdepthsdrver32], yerr= errorpmdepthsdrver32, fmt='o', capsize=3, markersize=8)
#plt.errorbar(np.arange(0,len(Intensityver32),1), [p for p in Gamas32], yerr=ErrorGamas32, fmt='o', capsize=3, markersize=8)
plt.xlabel('Ion position')
plt.ylabel('Intensity / DR Relative depth')
#plt.xticks([1,2,3,4,5])
#plt.xlim(200,3200)
plt.ylim(-0.1,1.1)
plt.grid()
#plt.axvline(3, color='salmon')
plt.legend()
#%%
"""
Ahora voy a intentar ajustarlas con una lorentziana que es mejor
"""
import seaborn as sns
"""
Resonancias DD configuracion +2/-2 colineal variando la ubicacion del ion en los haces
Moviendo VERTICALMENTE el haz, pasos de a 50 (updated), lente 200 mm, haz chiquito.
Esto es para 4 potencias de IR2 distintas. La pot de IR1 es constante.
Las amps son 0.13, 0.15, 0.17, 0.19 para 1, 2, 3 y 4 respectivamente
"""
pmlocmedvec33 = np.arange(0,len(PIEZOS3_FILES_POT3),1)
# pmlocmedvec32 = [4]
plotcurvita = 1
plt.figure()
#bkg=1*np.mean(Piezo1Counts[4][-6:-1])
bkg2=np.mean(Bkg2Counts[0][76:])
bkg=np.mean(list(Bkg2Counts[0][76:])+list(Piezo1Counts[4][-6:-1]))
pmdepthsdrver33=[]
errorpmdepthsdrver33=[]
Intensityver33 = []
errorIntensityver33 = []
Gamas33 = []
ErrorGamas33 = []
jj=0
for med in pmlocmedvec33:
Freqs = [2*f*1e-6 for f in Piezo3Frequencies3[med][1:]]
Counts = [c for c in Piezo3Counts3[med][1:]]
if med == 0:
# popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-265,1700,435.5,0.,0), bounds=((-10000,0,435.,0,0),(0,1e4, 436, 100,1)))
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0.1), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1)))
elif med == 1:
# Counts = Counts[20:120]
# Freqs= Freqs[20:120]
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.5,0), bounds=((-10000,0,435.5,0.05,0),(0,1e4, 436.1, 1,1e3)))
elif med == 2:
# Counts = Counts[20:]
# Freqs= Freqs[20:]
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1e3)))
elif med == 4:
# Counts = Counts[50:150]
# Freqs= Freqs[50:150]
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1e4)))
else:
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0.1), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1e4)))
if med==0:
pmdepthsdrver33.append(1-(np.min(Lorentzian(np.array(Freqs),*popt))-bkg)/(popt[1]-bkg))
#errorpmdepthsdrver1.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
errorpmdepthsdrver33.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
else:
pmdepthsdrver33.append(1-(np.min(Lorentzian(np.array(Freqs),*popt))-bkg)/(popt[1]-bkg))
#errorpmdepthsdrver1.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
errorpmdepthsdrver33.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
Intens33 = popt[1]
Gamas33.append(popt[3])
ErrorGamas33.append(np.sqrt(pcov[3,3]))
Intensityver33.append(Intens33)
# errorIntensity.append(2*np.sqrt(np.mean(Piezo1Counts[med][1:][0:20]))+np.sqrt(bkg))
if med not in [1000]:
plt.plot([2*f*1e-6 for f in Piezo3Frequencies3[med][1:]], [c for c in Piezo3Counts3[med][1:]], '-o', markersize=2, alpha=0.7)
plt.plot([f*1 for f in Freqs],Lorentzian(Freqs,*popt))
plt.axhline(bkg,linestyle='dashed',color='k')
jj=jj+1
plt.grid()
if plotcurvita:
plt.figure()
plt.errorbar(np.arange(0,len(Intensityver33),1), [i/np.max(Intensityver33) for i in Intensityver33], yerr=np.sqrt(Intensityver33)/np.max(Intensityver33), fmt='-o', capsize=3,markersize=8)
plt.errorbar(np.arange(0,len(Intensityver33),1), [p for p in pmdepthsdrver33], yerr= errorpmdepthsdrver33, fmt='o', capsize=3, markersize=8)
#plt.errorbar(np.arange(0,len(Intensityver33),1), [p for p in Gamas33], yerr=ErrorGamas33, fmt='o', capsize=3, markersize=8)
plt.xlabel('Ion position')
plt.ylabel('Intensity / DR Relative depth')
#plt.xticks([1,2,3,4,5])
#plt.xlim(200,3200)
plt.ylim(-0.1,1.1)
plt.grid()
#plt.axvline(3, color='salmon')
plt.legend()
#%%
"""
Ahora voy a intentar ajustarlas con una lorentziana que es mejor
"""
import seaborn as sns
"""
Resonancias DD configuracion +2/-2 colineal variando la ubicacion del ion en los haces
Moviendo VERTICALMENTE el haz, pasos de a 50 (updated), lente 200 mm, haz chiquito.
Esto es para 4 potencias de IR2 distintas. La pot de IR1 es constante.
Las amps son 0.13, 0.15, 0.17, 0.19 para 1, 2, 3 y 4 respectivamente
"""
pmlocmedvec34 = np.arange(0,len(PIEZOS3_FILES_POT4),1)
#pmlocmedvec34 = [1]
plotcurvita = 1
plt.figure()
#bkg=1*np.mean(Piezo1Counts[4][-6:-1])
bkg2=np.mean(Bkg2Counts[0][76:])
bkg=np.mean(list(Bkg2Counts[0][76:])+list(Piezo1Counts[4][-6:-1]))
pmdepthsdrver34=[]
errorpmdepthsdrver34=[]
Intensityver34 = []
errorIntensityver34 = []
Gamas34 = []
ErrorGamas34 = []
jj=0
for med in pmlocmedvec34:
Freqs = [2*f*1e-6 for f in Piezo3Frequencies4[med][1:]]
Counts = [c for c in Piezo3Counts4[med][1:]]
if med == 0:
# popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-265,1700,435.5,0.,0), bounds=((-10000,0,435.,0,0),(0,1e4, 436, 100,1)))
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0.1), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1)))
elif med == 1:
Counts = Counts[20:120]
Freqs= Freqs[20:120]
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.5,0), bounds=((-10000,0,435.5,0.05,0),(0,1e4, 436.1, 1,1e3)))
elif med == 2:
# Counts = Counts[20:]
# Freqs= Freqs[20:]
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1e3)))
elif med == 4:
# Counts = Counts[50:150]
# Freqs= Freqs[50:150]
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1e4)))
else:
popt, pcov = curve_fit(Lorentzian, np.array(Freqs), np.array(Counts), p0=(-200,2100,435.8,0.05,0.1), bounds=((-10000,0,435.5,0,0),(0,1e4, 436.1, 1,1e4)))
if med==0:
pmdepthsdrver34.append(1-(np.min(Lorentzian(np.array(Freqs),*popt))-bkg)/(popt[1]-bkg))
#errorpmdepthsdrver1.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
errorpmdepthsdrver34.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
else:
pmdepthsdrver34.append(1-(np.min(Lorentzian(np.array(Freqs),*popt))-bkg)/(popt[1]-bkg))
#errorpmdepthsdrver1.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
errorpmdepthsdrver34.append(ErrorDRdepth(np.min(Lorentzian(Freqs,*popt)),popt[1], bkg))
Intens34 = popt[1]
Gamas34.append(popt[3])
ErrorGamas34.append(np.sqrt(pcov[3,3]))
Intensityver34.append(Intens34)
# errorIntensity.append(2*np.sqrt(np.mean(Piezo1Counts[med][1:][0:20]))+np.sqrt(bkg))
if med not in [1000]:
plt.plot([2*f*1e-6 for f in Piezo3Frequencies4[med][1:]], [c for c in Piezo3Counts4[med][1:]], '-o', markersize=2, alpha=0.7)
plt.plot([f*1 for f in Freqs],Lorentzian(Freqs,*popt))
plt.axhline(bkg,linestyle='dashed',color='k')
jj=jj+1
plt.grid()
if plotcurvita:
plt.figure()
plt.errorbar(np.arange(0,len(Intensityver34),1), [i/np.max(Intensityver34) for i in Intensityver34], yerr=np.sqrt(Intensityver34)/np.max(Intensityver34), fmt='-o', capsize=3,markersize=8)
plt.errorbar(np.arange(0,len(Intensityver34),1), [p for p in pmdepthsdrver34], yerr= errorpmdepthsdrver34, fmt='o', capsize=3, markersize=8)
#plt.errorbar(np.arange(0,len(Intensityver34),1), [p for p in Gamas34], yerr=ErrorGamas34, fmt='o', capsize=3, markersize=8)
plt.xlabel('Ion position')
plt.ylabel('Intensity / DR Relative depth')
#plt.xticks([1,2,3,4,5])
#plt.xlim(200,3200)
plt.ylim(-0.1,1.1)
plt.grid()
#plt.axvline(3, color='salmon')
plt.legend()
#%%
"""
Ahora ploteo cosas de las 4 mediciones conjuntas
"""
#potencias
plt.figure()
plt.errorbar(np.arange(0,len(Intensityver31),1), [i/np.max(Intensityver34) for i in Intensityver31], yerr=np.sqrt(Intensityver31)/np.max(Intensityver34), fmt='-o', color='blue',capsize=3,markersize=8)
plt.errorbar(np.arange(0,len(Intensityver32),1), [i/np.max(Intensityver34) for i in Intensityver32], yerr=np.sqrt(Intensityver32)/np.max(Intensityver34), fmt='-o', color='orange',capsize=3,markersize=8)
plt.errorbar(np.arange(0,len(Intensityver33),1), [i/np.max(Intensityver34) for i in Intensityver33], yerr=np.sqrt(Intensityver33)/np.max(Intensityver34), fmt='-o', color='green',capsize=3,markersize=8)
plt.errorbar(np.arange(0,len(Intensityver34),1), [i/np.max(Intensityver34) for i in Intensityver34], yerr=np.sqrt(Intensityver34)/np.max(Intensityver34), fmt='-o', color='red',capsize=3,markersize=8)
plt.grid()
#profundidades
plt.figure()
plt.errorbar(np.arange(0,len(Intensityver31),1), [p for p in pmdepthsdrver31], yerr= errorpmdepthsdrver31, fmt='o', capsize=3, color='blue',markersize=8)
plt.errorbar(np.arange(0,len(Intensityver32),1), [p for p in pmdepthsdrver32], yerr= errorpmdepthsdrver32, fmt='o', capsize=3, color='orange',markersize=8)
plt.errorbar(np.arange(0,len(Intensityver33),1), [p for p in pmdepthsdrver33], yerr= errorpmdepthsdrver33, fmt='o', capsize=3, color='green',markersize=8)
plt.errorbar(np.arange(0,len(Intensityver34),1), [p for p in pmdepthsdrver34], yerr= errorpmdepthsdrver34, fmt='o', capsize=3, color='red',markersize=8)
plt.ylim(0,1.05)
plt.grid()
#ahora la anterior con haz grande y alguna de las 4 potencias con haz chico
plt.figure()
# plt.plot(np.arange(0,len(Intensityver1),1), [i/np.max(Intensityver1) for i in Intensityver1], '-o', color='navy',alpha=0.5,markersize=8)
# plt.errorbar(np.arange(0,len(Intensityver1),1), [p for p in pmdepthsdrver1], yerr= errorpmdepthsdrver1, fmt='o', color='navy',alpha=1, capsize=3, markersize=8)
plt.plot(np.arange(0,len(Intensityver2),1), [i/np.max(Intensityver2) for i in Intensityver2], '-o', color='navy',alpha=0.5,markersize=8)
plt.errorbar(np.arange(0,len(Intensityver2),1), [p for p in pmdepthsdrver2], yerr= errorpmdepthsdrver2, fmt='o', color='navy',alpha=1, capsize=3, markersize=8)
plt.plot(np.arange(0,len(Intensityver33),1), [i/np.max(Intensityver33) for i in Intensityver33], '-o',color='green',markersize=8,alpha=0.5)
plt.errorbar(np.arange(0,len(Intensityver33),1), [1*p for p in pmdepthsdrver33], yerr= errorpmdepthsdrver33, fmt='o', color='green',alpha=1,capsize=3, markersize=8)
plt.xlim(-0.5, 20)
plt.ylim(-0.1,1.1)
plt.grid()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment