Loading analisis/plots/20230920_CPT_TemperatureSens_v2/Data/EITfit/MM_eightLevel_2repumps_AnalysisFunctions.py +38 −9 Changes for analisis/plots/20230920_CPT_TemperatureSens_v2/Data/EITfit/MM_eightLevel_2repumps_AnalysisFunctions.py: 38 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -19,6 +19,16 @@ import random from scipy.signal import savgol_filter as sf from scipy.stats import norm def prob_energia(E,T): kboltz = 1.380649e-23 mcalcio = 6.655e-23*1e-3 prob = np.exp(-E/(kboltz*T)) #*E**2 return prob def PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, betag, betap, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None, dephasing = False, boltzmann = False): """ solvemode=1: resuelve con np.linalg.solve Loading @@ -37,8 +47,9 @@ def PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinew velvec = np.linspace(-4*sigmaT,4*sigmaT,100) MBprobVec = norm.pdf(velvec,loc = 0, scale = sigmaT) MBprobVec = MBprobVec/np.trapz(MBprobVec,velvec) for i in range(len(velvec)): detVel = (detpvec - kp*velvec[i])/(2*np.pi*1e6) detVel = detpvec - kp*velvec[i]/(2*np.pi*1e6) _, Fluorescence = CPTspectrum8levels( sg, sp, gPS, gPD, DetDoppler-kg*velvec[i]/(2*np.pi*1e6),u, DopplerLaserLinewidth, ProbeLaserLinewidth, 0,alpha, phidoppler, titadoppler, phiprobe, titaprobe,circularityprobe, betag, betap, drivefreq, freqMin=freqMin, freqMax=freqMax, freqStep=freqStep, plot=False,detpvec=detVel) FluorescencesVel.append(Fluorescence) Loading @@ -54,21 +65,29 @@ def PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinew else: drivefreq =2*np.pi* 1e3 drivefreq =2*np.pi* 0.6e6 FluorescencesVel = [] sigmaT = np.sqrt(T*kboltz/m) velvec = np.linspace(-4*sigmaT,4*sigmaT,100) MBprobVec = norm.pdf(velvec,loc = 0, scale = sigmaT) Evec = np.linspace(0,8*kboltz*T,100) velvec = np.zeros(2*len(Evec)) velvec= np.sqrt(2 * Evec/m) MBprobVec = prob_energia(Evec, T) MBprobVec = MBprobVec/np.trapz(MBprobVec,Evec) betagVec = velvec*kg/drivefreq betapVec = velvec*kp/drivefreq for i in range(len(betagVec)): betag,betap = betagVec[i],betapVec[i] Frequencies, Fluorescence = CPTspectrum8levels( sg, sp, gPS, gPD, DetDoppler,u, DopplerLaserLinewidth, ProbeLaserLinewidth, 0,alpha, phidoppler, titadoppler, phiprobe, titaprobe,circularityprobe, betag, betap, drivefreq, freqMin=freqMin, freqMax=freqMax, freqStep=freqStep, plot=False,detpvec=None) Frequencies, Fluorescence = CPTspectrum8levels( sg, sp, gPS, gPD, DetDoppler,u, DopplerLaserLinewidth, ProbeLaserLinewidth, 0,alpha, phidoppler, titadoppler, phiprobe, titaprobe,circularityprobe, betag, betap, drivefreq, freqMin=freqMin, freqMax=freqMax, freqStep=freqStep, plot=False,detpvec=detpvec) FluorescencesVel.append(Fluorescence) FluorescencesVel = np.array(FluorescencesVel) MBprobMat = np.tile(MBprobVec,(FluorescencesVel.shape[1],1)).T Fluorescence = np.trapz(FluorescencesVel*MBprobMat,velvec,axis = 0) Fluorescence = np.trapz(FluorescencesVel*MBprobMat,Evec,axis = 0) ProbeDetuningVectorL = Frequencies #print('Done, Total time: ', round((tfinal-tinicial), 2), "s") Loading Loading @@ -106,15 +125,25 @@ def SmoothNoisyCPT(Fluo, window=11, poly=3): def fitCPT_8levels(Freq,Fluo,sg,sp,gPS,gPD,DetDoppler,u,DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe,beta, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False,dephasing = False, boltzmann = False ): def fitCPT_8levels(Freq,Fluo,sg,sp,gPS,gPD,DetDoppler,u,DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe,betag,betar, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False,dephasing = False, boltzmann = False ): def SpectrumForFit(Freq,sg,sp,T,DetDoppler): freq,spectra = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, beta, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=Freq) return spectra def SpectrumForFit(Freq,sg,sp,T,DetDoppler,A,bgnd,f0): Freq = Freq - f0 freq,spectra = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, betag,betar, drivefreq, freqMin, freqMax, freqStep,circularityprobe=1, plot=False, detpvec=Freq, dephasing = dephasing, boltzmann = boltzmann) return spectra*A + bgnd popt,pcov = curve_fit(SpectrumForFit,Freq,Fluo,p0 = [sg,sp,T,DetDoppler],bounds = ([0.01,0.01,0.00001,-50e6],[1,20,1,30e6])) popt,pcov = curve_fit(SpectrumForFit,Freq,Fluo,p0 = [sg,sp,T,DetDoppler,20000,800,432],bounds = ([0.1,1,0.5e-3,-30,10000,0,420],[0.8,10,10e-3,0,100000,1000,500])) fitted_spectra = SpectrumForFit(Freq,*popt) return Freq, fitted_spectra,popt,pcov def try_fitCPT_8levels(A,bgnd,f0,Freq,Fluo,sg,sp,gPS,gPD,DetDoppler,u,DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe,betag,betar, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False,dephasing = False, boltzmann = False ): def SpectrumForFit(Freq,sg,sp,T,DetDoppler,A,bgnd,f0): Freq = Freq - f0 freq,spectra = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, betag,betar, drivefreq, freqMin, freqMax, freqStep,circularityprobe=1, plot=False, detpvec=Freq, dephasing = dephasing, boltzmann = boltzmann) return spectra*A + bgnd return SpectrumForFit(Freq, sg, sp, T, DetDoppler, A, bgnd, f0) No newline at end of file analisis/plots/20230920_CPT_TemperatureSens_v2/Data/EITfit/MM_eightLevel_2repumps_CPTPlotter.py +210 −52 Changes for analisis/plots/20230920_CPT_TemperatureSens_v2/Data/EITfit/MM_eightLevel_2repumps_CPTPlotter.py: 210 added lines, 52 removed lines. Original line number Diff line number Diff line Loading @@ -10,24 +10,106 @@ Created on Tue Sep 1 17:58:39 2020 import os import numpy as np from MM_eightLevel_2repumps_AnalysisFunctions import PerformExperiment_8levels, GenerateNoisyCPT_vel, SmoothNoisyCPT, PerformExperiment_8levels_vel from MM_eightLevel_2repumps_AnalysisFunctions import PerformExperiment_8levels, GenerateNoisyCPT_vel, SmoothNoisyCPT, PerformExperiment_8levels_vel,fitCPT_8levels,try_fitCPT_8levels import matplotlib.pyplot as plt import time import h5py def MB_prob(vel,T): return (m/(2*np.pi*kboltz*T))**(3/2)*2* vel**2 *np.exp(-vel**2 * m/(2*kboltz*T)) os.chdir('/home/muri/nubeDF/Documents/codigos/artiq_experiments/analisis/plots/20231218_CPT_muri/Data') CPT_FILES = """000016262-IR_Scan_withcal_optimized 000016239-IR_Scan_withcal_optimized 000016240-IR_Scan_withcal_optimized 000016241-IR_Scan_withcal_optimized 000016244-IR_Scan_withcal_optimized 000016255-IR_Scan_withcal_optimized 000016256-IR_Scan_withcal_optimized 000016257-IR_Scan_withcal_optimized """ 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(CPT_FILES)) #carpeta pc nico labo escritorio: #C:\Users\Usuario\Documents\artiq\artiq_experiments\analisis\plots\20211101_CPT_DosLaseres_v03\Data Counts = [] Freqs = [] AmpTisa = [] UVCPTAmp = [] No_measures = [] Voltages = [] for i, fname in enumerate(CPT_FILES.split()): print(str(i) + ' - ' + fname) #print(fname) data = h5py.File(fname+'.h5', 'r') # Leo el h5: Recordar que nuestros datos estan en 'datasets' # Aca hago algo repugnante para poder levantar los strings que dejamos # que además tenian un error de tipeo al final. Esto no deberá ser necesario # cuando se solucione el error este del guardado. Freqs.append(np.array(data['datasets']['IR1_Frequencies'])) Counts.append(np.array(data['datasets']['data_array'])) #AmpTisa.append(np.array(data['datasets']['TISA_CPT_amp'])) UVCPTAmp.append(np.array(data['datasets']['UV_CPT_amp'])) No_measures.append(np.array(data['datasets']['no_measures'])) Voltages.append(np.array(data['datasets']['scanning_voltages'])) def MB_prob_1d(vel,T): return np.sqrt(m/(2*np.pi*kboltz*T))*np.exp(-vel**2 * m/(2*kboltz*T)) 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 #plt.rcParams.update({ # "text.usetex": True, # "font.family": "CM Roman" #}) CountsSplit = [] CountsSplit.append(Split(Counts[0],len(Freqs[0]))) CountsSplit_2ions = [] CountsSplit_2ions.append(Split(Counts[4],len(Freqs[4]))) #%% """ Para distintos valores de j hay curvas CPT variando compensación. Las que valen la pena son de la 1 a la 9. En particular, la 4 tiene poca micromoción: """ jvec = [4] # de la 1 a la 9 vale la pena, despues no drive=22.1 Frequencies = Freqs[0] plt.figure() i = 0 for j in jvec: #plt.errorbar([2*f*1e-6-419-13 for f in Frequencies], CountsSplit[0][j], yerr=np.sqrt(CountsSplit[0][j]), fmt='o', capsize=2, markersize=2) i = i + 1 plt.xlabel('Frecuencia (MHz)') plt.ylabel('counts') plt.grid() #for dr in drs: # plt.axvline(dr) #plt.axvline(dr+drive) plt.legend() plt.rcParams["axes.prop_cycle"] = plt.cycler('color', ['#DBAD1F', '#C213DB', '#DB4F2A', '#0500DB', '#09DB9B', '#B4001B', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']) Loading @@ -46,10 +128,10 @@ B = (u/(2*np.pi))/c gPS, gPD, = 2*np.pi*21.58e6, 2*np.pi*1.35e6 #anchos de linea de las transiciones lw = 0.1 #ancho de linea de los laseres en MHz lw = 0.5 #ancho de linea de los laseres en MHz DopplerLaserLinewidth, ProbeLaserLinewidth = lw, lw #ancho de linea de los laseres DetDoppler = -15 #detuning doppler en MHz DetDoppler = -24.5 #detuning doppler en MHz T = 0.1e-3 #temperatura en K alpha = 0 #angulo entre los láseres Loading @@ -64,18 +146,18 @@ CircPr = 1 #Parametros de la simulacion cpt todo en MHz center = -15 span = 30 span = 80 freqMin = center-span*0.5 freqMax = center+span*0.5 freqStep = 0.5 freqStep = 0.25 print(freqMin,freqMax,freqStep) noiseamplitude = 0 #parametros de saturacion de los laseres. g: doppler. p: probe (un rebombeo que scanea), r: repump (otro rebombeo fijo) sg = 0.3 sp = 3 sg = 0.25 sp = 5.0 drivefreq=2*np.pi*22.135*1e6 Loading @@ -97,17 +179,17 @@ Tvec = np.linspace(0.5e-3,100e-3,15) #Tvec = np.linspace(0.001,0.1,20) s12vec = np.linspace(0.2,0.6,20) #s12vec = [s12vec[2],s12vec[4],s12vec[10],s12vec[18]] s12vec = [0.28] s12vec = [0.51] s23vec = np.linspace(0.5,15,20) #s23vec = [s23vec[2],s23vec[6],s23vec[10],s23vec[18]] s23vec = [10] s23vec = [3.5] Tmat = np.zeros((len(s12vec),len(s23vec))) Tvec_ajuste = np.zeros(len(Tvec)) phivect = 0 T = 10e-3 T = 8e-3 titavect = np.linspace(0,2*np.pi,100) Loading @@ -115,58 +197,134 @@ betag = 0 betap = 0 alpha = 0 SCALE = 5.60485992e+04 SCALE = 1 OFFSET = 0 OFFSET = 1.55401398e+02 Freq,Fluo_sb = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, betag, betap, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None, dephasing = False, boltzmann = False) Freq,Fluo_boltz = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, betag, betap, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None, dephasing = False, boltzmann = True) T = 0.8e-3 Freq,Fluo_deph = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, betag, betap, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None, dephasing = True, boltzmann = False) #%% plt.plot(Freq,Fluo_boltz,label = 'Velocities') plt.plot(Freq,Fluo_sb,label = 'Sideband') plt.plot(Freq,Fluo_deph, label = 'Dephasing') plt.plot(Freq,SCALE*Fluo_boltz+OFFSET,label = 'Semiclassic') plt.plot(Freq,SCALE*Fluo_sb+OFFSET,label = 'Sideband') plt.plot(Freq,SCALE*Fluo_deph+OFFSET, label = 'Dephasing') plt.legend() #%% os.chdir('/home/muri/nubeDF/Documents/codigos/artiq_experiments/analisis/plots/20230920_CPT_TemperatureSens_v2/Data/') from scipy.optimize import curve_fit phidoppler, titadoppler = 0, 90 phirepump, titarepump = 0, 0 phiprobe = 0 titaprobe = 90 Temp = 0.5e-3 sg = 0.544 sp = 4.5 sr = 0 DetRepump = 0 lw = 0.5 DopplerLaserLinewidth, RepumpLaserLinewidth, ProbeLaserLinewidth = lw, lw, lw #ancho de linea de los laseres u = 32.5e6 #B = (u/(2*np.pi))/c correccion = 13 offsetxpi = 419+correccion DetDoppler = -11.5-correccion gPS, gPD, = 2*np.pi*21.58e6, 2*np.pi*1.35e6 alpha = 0 drivefreq = 2*np.pi*22.135*1e6 selectedcurve = 4 FreqsDR = [2*f*1e-6-offsetxpi for f in Freqs[0]] CountsDR = CountsSplit[0][selectedcurve] CountsDR[100]=0.5*(CountsDR[99]+CountsDR[101]) CountsDR[105]=0.5*(CountsDR[104]+CountsDR[106]) freqslong = np.arange(min(FreqsDR), max(FreqsDR)+FreqsDR[1]-FreqsDR[0], 0.1*(FreqsDR[1]-FreqsDR[0])) CircPr = 1 alpha = 0 def FitEIT_MM_single(freqs, SG, SP, SCALE1, OFFSET, TEMP,f0): #def FitEIT_MM(freqs, SG, SP, SCALE1, OFFSET, BETA1): #BETA = 1.8 # SG = 0.6 # SP = 8.1 # TEMP = 0.2e-3 BETA1 = 0 BETA2 = 0 Detunings, Fluorescence1 = PerformExperiment_8levels(SG, SP, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, TEMP, alpha, phidoppler, titadoppler, phiprobe, titaprobe, BETA1, BETA2, drivefreq, min(freqs), max(freqs)+(freqs[1]-freqs[0]), freqs[1]-freqs[0], circularityprobe=CircPr, plot=False, solvemode=1, detpvec=np.array(freqs)-f0) ScaledFluo1 = np.array([f*SCALE1 + OFFSET for f in Fluorescence1]) return ScaledFluo1 #return ScaledFluo1 popt_1 = [4.82483692e-01, 8.18685518e+00, 6.48238914e+04, 1.54835760e+02, 5.56566519e-03, 5.24515673e-18] do_fit = True if do_fit: #popt_1, pcov_1 = curve_fit(FitEIT_MM_single, FreqsDR, CountsDR, p0=[0.2, 5, 6.89e4, 1.2723, 8e-3,1], bounds=((0, 0, 0, 0, 0, 0), (2, 20, 7e4, 5e4, 15e-3,5))) FittedEITpi_1 = FitEIT_MM_single(freqslong, *popt_1) beta1 = popt_1[4] errorbeta1 = np.sqrt(pcov_1[4,4]) temp1 = popt_1[5] errortemp1 = np.sqrt(pcov_1[5,5]) plt.figure() plt.errorbar(FreqsDR, CountsDR, yerr=2*np.sqrt(CountsDR), fmt='o', color='darkgreen', alpha=0.5, capsize=2, markersize=2) plt.plot(freqslong, FittedEITpi_1, color='darkolivegreen', linewidth=3, label='med 1') #plt.title(f'Sdop: {round(popt[0], 2)}, Spr: {round(popt[1], 2)}, T: {round(popt[2]*1e3, 2)} mK, detDop: {DetDoppler} MHz') plt.xlabel('Detuning (MHz)') plt.ylabel('Counts') plt.legend(loc='upper left', fontsize=20) plt.grid() CPT_FILES = """000011345-IR_Scan_withcal_optimized 000011331-IR_Scan_withcal_optimized """ for i in range(0,9): CPT_FILES = CPT_FILES + f'0000153{19 + i}-IR_Scan_withcal_optimized\n' CPT_FILES = CPT_FILES 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(CPT_FILES)) Counts = [] Freqs = [] AmpTisa = [] UVCPTAmp = [] No_measures = [] for i, fname in enumerate(CPT_FILES.split()): print(str(i) + ' - ' + fname) #print(fname) data = h5py.File(fname+'.h5', 'r') # Leo el h5: Recordar que nuestros datos estan en 'datasets' # Aca hago algo repugnante para poder levantar los strings que dejamos # que además tenian un error de tipeo al final. Esto no deberá ser necesario # cuando se solucione el error este del guardado. Freqs.append(np.array(data['datasets']['IR1_Frequencies'])) Counts.append(np.array(data['datasets']['counts_spectrum'])) #AmpTisa.append(np.array(data['datasets']['TISA_CPT_amp'])) UVCPTAmp.append(np.array(data['datasets']['UV_CPT_amp'])) No_measures.append(np.array(data['datasets']['no_measures'])) analisis/plots/20230920_CPT_TemperatureSens_v2/Data/EITfit/MM_eightLevel_2repumps_python_scripts.py +19 −7 Changes for analisis/plots/20230920_CPT_TemperatureSens_v2/Data/EITfit/MM_eightLevel_2repumps_python_scripts.py: 19 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -250,7 +250,7 @@ def dopplerBroadening(wlg, wlp, alpha, T, mcalcio = 6.655e-23*1e-3): kboltzmann = 1.38e-23 #J/K gammaD = (2*np.pi)*np.sqrt((1/(wlg*wlg)) + (1/(wlp*wlp)) - 2*(1/(wlg*wlp))*np.cos(alpha))*np.sqrt(kboltzmann*T/(2*mcalcio)) gammaD = (2*np.pi)*np.sqrt((1/(wlg*wlg)) + (1/(wlp*wlp)) - 2*(1/(wlg*wlp))*np.cos(alpha))*np.sqrt(kboltzmann*T/(mcalcio)) return gammaD Loading @@ -264,10 +264,16 @@ def FullL(rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u = 0, lwg = 0, lwp """ kg = 397e9 kp = 866e9 fg = kg**2/(kg**2+kp**2) fp = kp**2/(kg**2+kp**2) db = dopplerBroadening(0.397e-6, 0.866e-6, alpha, T) lwg = np.sqrt(lwg**2 + (db/2)**2)/2 lwp = np.sqrt(lwp**2 + (db/2)**2)/2 lwg = np.sqrt(lwg**2 + (fg*db)**2) lwp = np.sqrt(lwp**2 + (fp*db)**2) Loading Loading @@ -306,15 +312,18 @@ def FullL(rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u = 0, lwg = 0, lwp M = CalculateSingleMmatrix(gPS, gPD, lwg, lwp) L0 = np.array(np.matrix(Lfullpartial) + M) if betag !=0 and betap !=0: #ESTA PARTE ES CUANDO AGREGAS MICROMOCION nmax = 7 nmax = 2*int(betag) #print(nmax) Ltemp, Omega = LtempCalculus(betag,betap, drivefreq) #print(factor) L1 = GetL1(Ltemp, L0, Omega, nmax) Lfull = L0 + L1 #ESA CORRECCION ESTA EN L1 #HASTA ACA else: Lfull = L0 #NORMALIZACION DE RHO i = 0 while i < 64: Loading Loading @@ -423,6 +432,9 @@ def CPTspectrum8levels(sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidopp DetProbeVector = detpvec*1e6 * 2*np.pi Detg = 2*np.pi*Detg*1e6 #lwg, lwr, lwp = 2*np.pi*lwg*1e6, 2*np.pi*lwr*1e6, 2*np.pi*lwp*1e6 lwg, lwp = lwg*1e6, lwp*1e6 Loading Loading @@ -463,7 +475,7 @@ def CPTspectrum8levels(sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidopp plt.plot(DetProbeVectorMHz, [100*f for f in Fluovector], label=str(titaprobe) + 'º, T: ' + str(Temp*1e3) + ' mK') plt.legend() return DetProbeVectorMHz, Fluovector return DetProbeVectorMHz, np.array(Fluovector) def CPTspectrum8levels_vel(velvect,titavec,phivec,probvel,sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidoppler, titadoppler, phiprobe, titaprobe, Circularityprobe, beta, drivefreq, freqMin=-100, freqMax=100, freqStep=1e-1, plot=False, solvemode=1): Loading Loading @@ -613,7 +625,7 @@ def CPTspectrum8levels_vel(velvect,titavec,phivec,probvel,sg, sp, gPS, gPD, Detg plt.plot(DetProbeVectorMHz, [100*f for f in Fluovector], label=str(titaprobe) + 'º, T: ' + str(Temp*1e3) + ' mK') plt.legend() return DetProbeVectorMHz, Fluovector return DetProbeVectorMHz, np.array(Fluovector) if __name__ == "__main__": Loading analisis/plots/20231218_CPT_muri/CPT_plotter_20231123.py +1788 File added.Preview size limit exceeded, changes collapsed. Show changes analisis/plots/20231218_CPT_muri/CPT_plotter_20231218.py +202 Changes for analisis/plots/20231218_CPT_muri/CPT_plotter_20231218.py: 202 added lines, 0 removed lines. Original line number Diff line number Diff line 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 """ CPT con tres laseres pero lso dos IR son el mismo entonces las DD son mas finas """ #C:\Users\Usuario\Documents\artiq\artiq_experiments\analisis\plots\20211223_CPT_DosLaseres_v07_ChristmasSpecial\Data ALL_FILES = """000016420-IR_Scan_withcal_optimized """ 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(ALL_FILES)) #carpeta pc nico labo escritorio: #C:\Users\Usuario\Documents\artiq\artiq_experiments\analisis\plots\20211101_CPT_DosLaseres_v03\Data Counts = [] Freqs = [] AmpTisa = [] UVCPTAmp = [] No_measures = [] for i, fname in enumerate(ALL_FILES.split()): print(str(i) + ' - ' + fname) #print(fname) data = h5py.File(fname+'.h5', 'r') # Leo el h5: Recordar que nuestros datos estan en 'datasets' # Aca hago algo repugnante para poder levantar los strings que dejamos # que además tenian un error de tipeo al final. Esto no deberá ser necesario # cuando se solucione el error este del guardado. Freqs.append(np.array(data['datasets']['IR1_Frequencies'])) Counts.append(np.array(data['datasets']['counts_spectrum'])) #AmpTisa.append(np.array(data['datasets']['TISA_CPT_amp'])) #UVCPTAmp.append(np.array(data['datasets']['UV_CPT_amp'])) #No_measures.append(np.array(data['datasets']['no_measures'])) #%% #Barriendo angulo del IR con tisa apagado jvec = [0] jselected = jvec plt.figure() i = 0 for j in jvec: if j in jselected: plt.errorbar([2*f*1e-6 for f in Freqs[j]], Counts[j], yerr=np.sqrt(Counts[j]), fmt='o', capsize=2, markersize=2) #plt.plot([2*f*1e-6 for f in Freqs[j]], Counts[j], 'o-', label=f'Amp Tisa: {AmpTisa[i]}', mb arkersize=3) i = i + 1 plt.xlabel('Frecuencia (MHz)') plt.ylabel('counts') plt.grid() plt.legend() #%% from scipy.optimize import curve_fit import time phidoppler, titadoppler = 0, 90 phirepump, titarepump = 0, 90 phiprobe = 0 titaprobe = 0.1 Temp = 0.5e-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 = 32.5e6 #B = (u/(2*np.pi))/c gPS, gPD, = 2*np.pi*21.58e6, 2*np.pi*1.35e6 alpha = 0 drivefreq = 2*np.pi*22.135*1e6 noiseamplitude = 0 selectedcurve=0 FreqsDR = Freqs[selectedcurve] CountsDR = Counts[selectedcurve] freqslong = np.arange(min(FreqsDR), max(FreqsDR)+FreqsDR[1]-FreqsDR[0], 0.1*(FreqsDR[1]-FreqsDR[0])) CircPr = 1 alpha = 0 def FitEIT_MM_1ion(Freqs, offset, DetDoppler, DetRepump, SG, SP, SR, SCALE1, OFFSET, TEMP, U, plot=False): #def FitEIT_MM(freqs, SG, SP, SCALE1, OFFSET, BETA1): # BETA1 = 0 # SG = 0.6 # SP = 8.1 # TEMP = 0.2e-3 # U = 32.5e6 freqs = [2*f*1e-6-offset for f in Freqs] #Detunings, Fluorescence1 = PerformExperiment_8levels_MM(SG, SP, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, TEMP, alpha, phidoppler, titadoppler, phiprobe, titaprobe, BETA1, drivefreq, min(freqs), max(freqs)+(freqs[1]-freqs[0]), freqs[1]-freqs[0], circularityprobe=CircPr, plot=False, solvemode=1, detpvec=None) Detunings, Fluorescence1 = GenerateNoisyCPT_fit(SG, SR, SP, gPS, gPD, DetDoppler, DetRepump, U, DopplerLaserLinewidth, RepumpLaserLinewidth, ProbeLaserLinewidth, TEMP, alpha, phidoppler, titadoppler, phiprobe, [titaprobe], phirepump, titarepump, freqs, plot=False, solvemode=1, detpvec=None, noiseamplitude=noiseamplitude) ScaledFluo1 = np.array([f*SCALE1 + OFFSET for f in Fluorescence1]) if plot: return ScaledFluo1, Detunings else: return ScaledFluo1 #return ScaledFluo1 do_fit = True if do_fit: popt_1, pcov_1 = curve_fit(FitEIT_MM_1ion, FreqsDR, CountsDR, p0=[430, -25, 12, 0.9, 6.2, 3, 3e4, 2e3, 0.5e-3, 32e6], bounds=((0, -100, -20, 0, 0, 0, 0, 0, 0,20e6), (1000, 0, 50, 2, 20, 20, 5e6, 5e4, 15e-3,40e6))) FittedEITpi_1_short, Detunings_1_short = FitEIT_MM_1ion(FreqsDR, *popt_1, plot=True) freqslong = np.arange(min(FreqsDR), max(FreqsDR)+FreqsDR[1]-FreqsDR[0], 0.1*(FreqsDR[1]-FreqsDR[0])) FittedEITpi_1_long, Detunings_1_long = FitEIT_MM_1ion(freqslong, *popt_1, plot=True) #%% plt.figure() plt.errorbar(Detunings_1_short, CountsDR, yerr=2*np.sqrt(CountsDR), fmt='o', color='red', alpha=0.5, capsize=2, markersize=2) plt.plot(Detunings_1_long, FittedEITpi_1_long, color='darkolivegreen', linewidth=3, label='med 1') #plt.title(f'Sdop: {round(popt[0], 2)}, Spr: {round(popt[1], 2)}, T: {round(popt[2]*1e3, 2)} mK, detDop: {DetDoppler} MHz') plt.xlabel('Detuning (MHz)') plt.ylabel('Counts') #plt.xlim(-20,0) plt.legend(loc='upper left', fontsize=20) plt.grid() #%% u = 32.5e6 B = (u/(2*np.pi))/c correccion = 8 #con 8 fitea bien offsetxpi = 440+1+correccion DetDoppler = -5.0-correccion FreqsDRpi_3 = [2*f*1e-6-offsetxpi+14 for f in Freqs_B[5]] CountsDRpi_3 = Counts_B[5] freqslongpi_3 = np.arange(min(FreqsDRpi_3), max(FreqsDRpi_3)+FreqsDRpi_3[1]-FreqsDRpi_3[0], 0.1*(FreqsDRpi_3[1]-FreqsDRpi_3[0])) #[1.71811842e+04 3.34325038e-17] def FitEITpi(freqs, SG, SP): temp = 2e-3 MeasuredFreq, MeasuredFluo = GenerateNoisyCPT_fit(SG, sr, SP, gPS, gPD, DetDoppler, DetRepump, u, DopplerLaserLinewidth, RepumpLaserLinewidth, ProbeLaserLinewidth, temp, alpha, phidoppler, titadoppler, phiprobe, [titaprobe], phirepump, titarepump, freqs, plot=False, solvemode=1, detpvec=None, noiseamplitude=noiseamplitude) FinalFluo = [f*6.554e4 + 1.863e3 for f in MeasuredFluo] return FinalFluo popt_tisaoff, pcov_tisaoff = curve_fit(FitEITpi, FreqsDRpi_3, CountsDRpi_3, p0=[0.5, 4.5], bounds=((0, 0), (2, 10))) print(popt_tisaoff) Sat_3 = popt_tisaoff[0] Det_3 = popt_tisaoff[1] FittedEITpi_3 = FitEITpi(freqslongpi_3, *popt_tisaoff) plt.figure() plt.errorbar(FreqsDRpi_3, CountsDRpi_3, yerr=2*np.sqrt(CountsDRpi_3), fmt='o', capsize=2, markersize=2) plt.plot(freqslongpi_3, FittedEITpi_3) #plt.title(f'Sdop: {round(popt[0], 2)}, Spr: {round(popt[1], 2)}, T: {round(popt[2]*1e3, 2)} mK, detDop: {DetDoppler} MHz') FreqsCalibradas_B = FreqsDRpi_3 Loading
analisis/plots/20230920_CPT_TemperatureSens_v2/Data/EITfit/MM_eightLevel_2repumps_AnalysisFunctions.py +38 −9 Changes for analisis/plots/20230920_CPT_TemperatureSens_v2/Data/EITfit/MM_eightLevel_2repumps_AnalysisFunctions.py: 38 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -19,6 +19,16 @@ import random from scipy.signal import savgol_filter as sf from scipy.stats import norm def prob_energia(E,T): kboltz = 1.380649e-23 mcalcio = 6.655e-23*1e-3 prob = np.exp(-E/(kboltz*T)) #*E**2 return prob def PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, betag, betap, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None, dephasing = False, boltzmann = False): """ solvemode=1: resuelve con np.linalg.solve Loading @@ -37,8 +47,9 @@ def PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinew velvec = np.linspace(-4*sigmaT,4*sigmaT,100) MBprobVec = norm.pdf(velvec,loc = 0, scale = sigmaT) MBprobVec = MBprobVec/np.trapz(MBprobVec,velvec) for i in range(len(velvec)): detVel = (detpvec - kp*velvec[i])/(2*np.pi*1e6) detVel = detpvec - kp*velvec[i]/(2*np.pi*1e6) _, Fluorescence = CPTspectrum8levels( sg, sp, gPS, gPD, DetDoppler-kg*velvec[i]/(2*np.pi*1e6),u, DopplerLaserLinewidth, ProbeLaserLinewidth, 0,alpha, phidoppler, titadoppler, phiprobe, titaprobe,circularityprobe, betag, betap, drivefreq, freqMin=freqMin, freqMax=freqMax, freqStep=freqStep, plot=False,detpvec=detVel) FluorescencesVel.append(Fluorescence) Loading @@ -54,21 +65,29 @@ def PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinew else: drivefreq =2*np.pi* 1e3 drivefreq =2*np.pi* 0.6e6 FluorescencesVel = [] sigmaT = np.sqrt(T*kboltz/m) velvec = np.linspace(-4*sigmaT,4*sigmaT,100) MBprobVec = norm.pdf(velvec,loc = 0, scale = sigmaT) Evec = np.linspace(0,8*kboltz*T,100) velvec = np.zeros(2*len(Evec)) velvec= np.sqrt(2 * Evec/m) MBprobVec = prob_energia(Evec, T) MBprobVec = MBprobVec/np.trapz(MBprobVec,Evec) betagVec = velvec*kg/drivefreq betapVec = velvec*kp/drivefreq for i in range(len(betagVec)): betag,betap = betagVec[i],betapVec[i] Frequencies, Fluorescence = CPTspectrum8levels( sg, sp, gPS, gPD, DetDoppler,u, DopplerLaserLinewidth, ProbeLaserLinewidth, 0,alpha, phidoppler, titadoppler, phiprobe, titaprobe,circularityprobe, betag, betap, drivefreq, freqMin=freqMin, freqMax=freqMax, freqStep=freqStep, plot=False,detpvec=None) Frequencies, Fluorescence = CPTspectrum8levels( sg, sp, gPS, gPD, DetDoppler,u, DopplerLaserLinewidth, ProbeLaserLinewidth, 0,alpha, phidoppler, titadoppler, phiprobe, titaprobe,circularityprobe, betag, betap, drivefreq, freqMin=freqMin, freqMax=freqMax, freqStep=freqStep, plot=False,detpvec=detpvec) FluorescencesVel.append(Fluorescence) FluorescencesVel = np.array(FluorescencesVel) MBprobMat = np.tile(MBprobVec,(FluorescencesVel.shape[1],1)).T Fluorescence = np.trapz(FluorescencesVel*MBprobMat,velvec,axis = 0) Fluorescence = np.trapz(FluorescencesVel*MBprobMat,Evec,axis = 0) ProbeDetuningVectorL = Frequencies #print('Done, Total time: ', round((tfinal-tinicial), 2), "s") Loading Loading @@ -106,15 +125,25 @@ def SmoothNoisyCPT(Fluo, window=11, poly=3): def fitCPT_8levels(Freq,Fluo,sg,sp,gPS,gPD,DetDoppler,u,DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe,beta, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False,dephasing = False, boltzmann = False ): def fitCPT_8levels(Freq,Fluo,sg,sp,gPS,gPD,DetDoppler,u,DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe,betag,betar, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False,dephasing = False, boltzmann = False ): def SpectrumForFit(Freq,sg,sp,T,DetDoppler): freq,spectra = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, beta, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=Freq) return spectra def SpectrumForFit(Freq,sg,sp,T,DetDoppler,A,bgnd,f0): Freq = Freq - f0 freq,spectra = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, betag,betar, drivefreq, freqMin, freqMax, freqStep,circularityprobe=1, plot=False, detpvec=Freq, dephasing = dephasing, boltzmann = boltzmann) return spectra*A + bgnd popt,pcov = curve_fit(SpectrumForFit,Freq,Fluo,p0 = [sg,sp,T,DetDoppler],bounds = ([0.01,0.01,0.00001,-50e6],[1,20,1,30e6])) popt,pcov = curve_fit(SpectrumForFit,Freq,Fluo,p0 = [sg,sp,T,DetDoppler,20000,800,432],bounds = ([0.1,1,0.5e-3,-30,10000,0,420],[0.8,10,10e-3,0,100000,1000,500])) fitted_spectra = SpectrumForFit(Freq,*popt) return Freq, fitted_spectra,popt,pcov def try_fitCPT_8levels(A,bgnd,f0,Freq,Fluo,sg,sp,gPS,gPD,DetDoppler,u,DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe,betag,betar, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False,dephasing = False, boltzmann = False ): def SpectrumForFit(Freq,sg,sp,T,DetDoppler,A,bgnd,f0): Freq = Freq - f0 freq,spectra = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, betag,betar, drivefreq, freqMin, freqMax, freqStep,circularityprobe=1, plot=False, detpvec=Freq, dephasing = dephasing, boltzmann = boltzmann) return spectra*A + bgnd return SpectrumForFit(Freq, sg, sp, T, DetDoppler, A, bgnd, f0) No newline at end of file
analisis/plots/20230920_CPT_TemperatureSens_v2/Data/EITfit/MM_eightLevel_2repumps_CPTPlotter.py +210 −52 Changes for analisis/plots/20230920_CPT_TemperatureSens_v2/Data/EITfit/MM_eightLevel_2repumps_CPTPlotter.py: 210 added lines, 52 removed lines. Original line number Diff line number Diff line Loading @@ -10,24 +10,106 @@ Created on Tue Sep 1 17:58:39 2020 import os import numpy as np from MM_eightLevel_2repumps_AnalysisFunctions import PerformExperiment_8levels, GenerateNoisyCPT_vel, SmoothNoisyCPT, PerformExperiment_8levels_vel from MM_eightLevel_2repumps_AnalysisFunctions import PerformExperiment_8levels, GenerateNoisyCPT_vel, SmoothNoisyCPT, PerformExperiment_8levels_vel,fitCPT_8levels,try_fitCPT_8levels import matplotlib.pyplot as plt import time import h5py def MB_prob(vel,T): return (m/(2*np.pi*kboltz*T))**(3/2)*2* vel**2 *np.exp(-vel**2 * m/(2*kboltz*T)) os.chdir('/home/muri/nubeDF/Documents/codigos/artiq_experiments/analisis/plots/20231218_CPT_muri/Data') CPT_FILES = """000016262-IR_Scan_withcal_optimized 000016239-IR_Scan_withcal_optimized 000016240-IR_Scan_withcal_optimized 000016241-IR_Scan_withcal_optimized 000016244-IR_Scan_withcal_optimized 000016255-IR_Scan_withcal_optimized 000016256-IR_Scan_withcal_optimized 000016257-IR_Scan_withcal_optimized """ 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(CPT_FILES)) #carpeta pc nico labo escritorio: #C:\Users\Usuario\Documents\artiq\artiq_experiments\analisis\plots\20211101_CPT_DosLaseres_v03\Data Counts = [] Freqs = [] AmpTisa = [] UVCPTAmp = [] No_measures = [] Voltages = [] for i, fname in enumerate(CPT_FILES.split()): print(str(i) + ' - ' + fname) #print(fname) data = h5py.File(fname+'.h5', 'r') # Leo el h5: Recordar que nuestros datos estan en 'datasets' # Aca hago algo repugnante para poder levantar los strings que dejamos # que además tenian un error de tipeo al final. Esto no deberá ser necesario # cuando se solucione el error este del guardado. Freqs.append(np.array(data['datasets']['IR1_Frequencies'])) Counts.append(np.array(data['datasets']['data_array'])) #AmpTisa.append(np.array(data['datasets']['TISA_CPT_amp'])) UVCPTAmp.append(np.array(data['datasets']['UV_CPT_amp'])) No_measures.append(np.array(data['datasets']['no_measures'])) Voltages.append(np.array(data['datasets']['scanning_voltages'])) def MB_prob_1d(vel,T): return np.sqrt(m/(2*np.pi*kboltz*T))*np.exp(-vel**2 * m/(2*kboltz*T)) 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 #plt.rcParams.update({ # "text.usetex": True, # "font.family": "CM Roman" #}) CountsSplit = [] CountsSplit.append(Split(Counts[0],len(Freqs[0]))) CountsSplit_2ions = [] CountsSplit_2ions.append(Split(Counts[4],len(Freqs[4]))) #%% """ Para distintos valores de j hay curvas CPT variando compensación. Las que valen la pena son de la 1 a la 9. En particular, la 4 tiene poca micromoción: """ jvec = [4] # de la 1 a la 9 vale la pena, despues no drive=22.1 Frequencies = Freqs[0] plt.figure() i = 0 for j in jvec: #plt.errorbar([2*f*1e-6-419-13 for f in Frequencies], CountsSplit[0][j], yerr=np.sqrt(CountsSplit[0][j]), fmt='o', capsize=2, markersize=2) i = i + 1 plt.xlabel('Frecuencia (MHz)') plt.ylabel('counts') plt.grid() #for dr in drs: # plt.axvline(dr) #plt.axvline(dr+drive) plt.legend() plt.rcParams["axes.prop_cycle"] = plt.cycler('color', ['#DBAD1F', '#C213DB', '#DB4F2A', '#0500DB', '#09DB9B', '#B4001B', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']) Loading @@ -46,10 +128,10 @@ B = (u/(2*np.pi))/c gPS, gPD, = 2*np.pi*21.58e6, 2*np.pi*1.35e6 #anchos de linea de las transiciones lw = 0.1 #ancho de linea de los laseres en MHz lw = 0.5 #ancho de linea de los laseres en MHz DopplerLaserLinewidth, ProbeLaserLinewidth = lw, lw #ancho de linea de los laseres DetDoppler = -15 #detuning doppler en MHz DetDoppler = -24.5 #detuning doppler en MHz T = 0.1e-3 #temperatura en K alpha = 0 #angulo entre los láseres Loading @@ -64,18 +146,18 @@ CircPr = 1 #Parametros de la simulacion cpt todo en MHz center = -15 span = 30 span = 80 freqMin = center-span*0.5 freqMax = center+span*0.5 freqStep = 0.5 freqStep = 0.25 print(freqMin,freqMax,freqStep) noiseamplitude = 0 #parametros de saturacion de los laseres. g: doppler. p: probe (un rebombeo que scanea), r: repump (otro rebombeo fijo) sg = 0.3 sp = 3 sg = 0.25 sp = 5.0 drivefreq=2*np.pi*22.135*1e6 Loading @@ -97,17 +179,17 @@ Tvec = np.linspace(0.5e-3,100e-3,15) #Tvec = np.linspace(0.001,0.1,20) s12vec = np.linspace(0.2,0.6,20) #s12vec = [s12vec[2],s12vec[4],s12vec[10],s12vec[18]] s12vec = [0.28] s12vec = [0.51] s23vec = np.linspace(0.5,15,20) #s23vec = [s23vec[2],s23vec[6],s23vec[10],s23vec[18]] s23vec = [10] s23vec = [3.5] Tmat = np.zeros((len(s12vec),len(s23vec))) Tvec_ajuste = np.zeros(len(Tvec)) phivect = 0 T = 10e-3 T = 8e-3 titavect = np.linspace(0,2*np.pi,100) Loading @@ -115,58 +197,134 @@ betag = 0 betap = 0 alpha = 0 SCALE = 5.60485992e+04 SCALE = 1 OFFSET = 0 OFFSET = 1.55401398e+02 Freq,Fluo_sb = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, betag, betap, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None, dephasing = False, boltzmann = False) Freq,Fluo_boltz = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, betag, betap, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None, dephasing = False, boltzmann = True) T = 0.8e-3 Freq,Fluo_deph = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, betag, betap, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None, dephasing = True, boltzmann = False) #%% plt.plot(Freq,Fluo_boltz,label = 'Velocities') plt.plot(Freq,Fluo_sb,label = 'Sideband') plt.plot(Freq,Fluo_deph, label = 'Dephasing') plt.plot(Freq,SCALE*Fluo_boltz+OFFSET,label = 'Semiclassic') plt.plot(Freq,SCALE*Fluo_sb+OFFSET,label = 'Sideband') plt.plot(Freq,SCALE*Fluo_deph+OFFSET, label = 'Dephasing') plt.legend() #%% os.chdir('/home/muri/nubeDF/Documents/codigos/artiq_experiments/analisis/plots/20230920_CPT_TemperatureSens_v2/Data/') from scipy.optimize import curve_fit phidoppler, titadoppler = 0, 90 phirepump, titarepump = 0, 0 phiprobe = 0 titaprobe = 90 Temp = 0.5e-3 sg = 0.544 sp = 4.5 sr = 0 DetRepump = 0 lw = 0.5 DopplerLaserLinewidth, RepumpLaserLinewidth, ProbeLaserLinewidth = lw, lw, lw #ancho de linea de los laseres u = 32.5e6 #B = (u/(2*np.pi))/c correccion = 13 offsetxpi = 419+correccion DetDoppler = -11.5-correccion gPS, gPD, = 2*np.pi*21.58e6, 2*np.pi*1.35e6 alpha = 0 drivefreq = 2*np.pi*22.135*1e6 selectedcurve = 4 FreqsDR = [2*f*1e-6-offsetxpi for f in Freqs[0]] CountsDR = CountsSplit[0][selectedcurve] CountsDR[100]=0.5*(CountsDR[99]+CountsDR[101]) CountsDR[105]=0.5*(CountsDR[104]+CountsDR[106]) freqslong = np.arange(min(FreqsDR), max(FreqsDR)+FreqsDR[1]-FreqsDR[0], 0.1*(FreqsDR[1]-FreqsDR[0])) CircPr = 1 alpha = 0 def FitEIT_MM_single(freqs, SG, SP, SCALE1, OFFSET, TEMP,f0): #def FitEIT_MM(freqs, SG, SP, SCALE1, OFFSET, BETA1): #BETA = 1.8 # SG = 0.6 # SP = 8.1 # TEMP = 0.2e-3 BETA1 = 0 BETA2 = 0 Detunings, Fluorescence1 = PerformExperiment_8levels(SG, SP, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, TEMP, alpha, phidoppler, titadoppler, phiprobe, titaprobe, BETA1, BETA2, drivefreq, min(freqs), max(freqs)+(freqs[1]-freqs[0]), freqs[1]-freqs[0], circularityprobe=CircPr, plot=False, solvemode=1, detpvec=np.array(freqs)-f0) ScaledFluo1 = np.array([f*SCALE1 + OFFSET for f in Fluorescence1]) return ScaledFluo1 #return ScaledFluo1 popt_1 = [4.82483692e-01, 8.18685518e+00, 6.48238914e+04, 1.54835760e+02, 5.56566519e-03, 5.24515673e-18] do_fit = True if do_fit: #popt_1, pcov_1 = curve_fit(FitEIT_MM_single, FreqsDR, CountsDR, p0=[0.2, 5, 6.89e4, 1.2723, 8e-3,1], bounds=((0, 0, 0, 0, 0, 0), (2, 20, 7e4, 5e4, 15e-3,5))) FittedEITpi_1 = FitEIT_MM_single(freqslong, *popt_1) beta1 = popt_1[4] errorbeta1 = np.sqrt(pcov_1[4,4]) temp1 = popt_1[5] errortemp1 = np.sqrt(pcov_1[5,5]) plt.figure() plt.errorbar(FreqsDR, CountsDR, yerr=2*np.sqrt(CountsDR), fmt='o', color='darkgreen', alpha=0.5, capsize=2, markersize=2) plt.plot(freqslong, FittedEITpi_1, color='darkolivegreen', linewidth=3, label='med 1') #plt.title(f'Sdop: {round(popt[0], 2)}, Spr: {round(popt[1], 2)}, T: {round(popt[2]*1e3, 2)} mK, detDop: {DetDoppler} MHz') plt.xlabel('Detuning (MHz)') plt.ylabel('Counts') plt.legend(loc='upper left', fontsize=20) plt.grid() CPT_FILES = """000011345-IR_Scan_withcal_optimized 000011331-IR_Scan_withcal_optimized """ for i in range(0,9): CPT_FILES = CPT_FILES + f'0000153{19 + i}-IR_Scan_withcal_optimized\n' CPT_FILES = CPT_FILES 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(CPT_FILES)) Counts = [] Freqs = [] AmpTisa = [] UVCPTAmp = [] No_measures = [] for i, fname in enumerate(CPT_FILES.split()): print(str(i) + ' - ' + fname) #print(fname) data = h5py.File(fname+'.h5', 'r') # Leo el h5: Recordar que nuestros datos estan en 'datasets' # Aca hago algo repugnante para poder levantar los strings que dejamos # que además tenian un error de tipeo al final. Esto no deberá ser necesario # cuando se solucione el error este del guardado. Freqs.append(np.array(data['datasets']['IR1_Frequencies'])) Counts.append(np.array(data['datasets']['counts_spectrum'])) #AmpTisa.append(np.array(data['datasets']['TISA_CPT_amp'])) UVCPTAmp.append(np.array(data['datasets']['UV_CPT_amp'])) No_measures.append(np.array(data['datasets']['no_measures']))
analisis/plots/20230920_CPT_TemperatureSens_v2/Data/EITfit/MM_eightLevel_2repumps_python_scripts.py +19 −7 Changes for analisis/plots/20230920_CPT_TemperatureSens_v2/Data/EITfit/MM_eightLevel_2repumps_python_scripts.py: 19 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -250,7 +250,7 @@ def dopplerBroadening(wlg, wlp, alpha, T, mcalcio = 6.655e-23*1e-3): kboltzmann = 1.38e-23 #J/K gammaD = (2*np.pi)*np.sqrt((1/(wlg*wlg)) + (1/(wlp*wlp)) - 2*(1/(wlg*wlp))*np.cos(alpha))*np.sqrt(kboltzmann*T/(2*mcalcio)) gammaD = (2*np.pi)*np.sqrt((1/(wlg*wlg)) + (1/(wlp*wlp)) - 2*(1/(wlg*wlp))*np.cos(alpha))*np.sqrt(kboltzmann*T/(mcalcio)) return gammaD Loading @@ -264,10 +264,16 @@ def FullL(rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u = 0, lwg = 0, lwp """ kg = 397e9 kp = 866e9 fg = kg**2/(kg**2+kp**2) fp = kp**2/(kg**2+kp**2) db = dopplerBroadening(0.397e-6, 0.866e-6, alpha, T) lwg = np.sqrt(lwg**2 + (db/2)**2)/2 lwp = np.sqrt(lwp**2 + (db/2)**2)/2 lwg = np.sqrt(lwg**2 + (fg*db)**2) lwp = np.sqrt(lwp**2 + (fp*db)**2) Loading Loading @@ -306,15 +312,18 @@ def FullL(rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u = 0, lwg = 0, lwp M = CalculateSingleMmatrix(gPS, gPD, lwg, lwp) L0 = np.array(np.matrix(Lfullpartial) + M) if betag !=0 and betap !=0: #ESTA PARTE ES CUANDO AGREGAS MICROMOCION nmax = 7 nmax = 2*int(betag) #print(nmax) Ltemp, Omega = LtempCalculus(betag,betap, drivefreq) #print(factor) L1 = GetL1(Ltemp, L0, Omega, nmax) Lfull = L0 + L1 #ESA CORRECCION ESTA EN L1 #HASTA ACA else: Lfull = L0 #NORMALIZACION DE RHO i = 0 while i < 64: Loading Loading @@ -423,6 +432,9 @@ def CPTspectrum8levels(sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidopp DetProbeVector = detpvec*1e6 * 2*np.pi Detg = 2*np.pi*Detg*1e6 #lwg, lwr, lwp = 2*np.pi*lwg*1e6, 2*np.pi*lwr*1e6, 2*np.pi*lwp*1e6 lwg, lwp = lwg*1e6, lwp*1e6 Loading Loading @@ -463,7 +475,7 @@ def CPTspectrum8levels(sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidopp plt.plot(DetProbeVectorMHz, [100*f for f in Fluovector], label=str(titaprobe) + 'º, T: ' + str(Temp*1e3) + ' mK') plt.legend() return DetProbeVectorMHz, Fluovector return DetProbeVectorMHz, np.array(Fluovector) def CPTspectrum8levels_vel(velvect,titavec,phivec,probvel,sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidoppler, titadoppler, phiprobe, titaprobe, Circularityprobe, beta, drivefreq, freqMin=-100, freqMax=100, freqStep=1e-1, plot=False, solvemode=1): Loading Loading @@ -613,7 +625,7 @@ def CPTspectrum8levels_vel(velvect,titavec,phivec,probvel,sg, sp, gPS, gPD, Detg plt.plot(DetProbeVectorMHz, [100*f for f in Fluovector], label=str(titaprobe) + 'º, T: ' + str(Temp*1e3) + ' mK') plt.legend() return DetProbeVectorMHz, Fluovector return DetProbeVectorMHz, np.array(Fluovector) if __name__ == "__main__": Loading
analisis/plots/20231218_CPT_muri/CPT_plotter_20231123.py +1788 File added.Preview size limit exceeded, changes collapsed. Show changes
analisis/plots/20231218_CPT_muri/CPT_plotter_20231218.py +202 Changes for analisis/plots/20231218_CPT_muri/CPT_plotter_20231218.py: 202 added lines, 0 removed lines. Original line number Diff line number Diff line 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 """ CPT con tres laseres pero lso dos IR son el mismo entonces las DD son mas finas """ #C:\Users\Usuario\Documents\artiq\artiq_experiments\analisis\plots\20211223_CPT_DosLaseres_v07_ChristmasSpecial\Data ALL_FILES = """000016420-IR_Scan_withcal_optimized """ 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(ALL_FILES)) #carpeta pc nico labo escritorio: #C:\Users\Usuario\Documents\artiq\artiq_experiments\analisis\plots\20211101_CPT_DosLaseres_v03\Data Counts = [] Freqs = [] AmpTisa = [] UVCPTAmp = [] No_measures = [] for i, fname in enumerate(ALL_FILES.split()): print(str(i) + ' - ' + fname) #print(fname) data = h5py.File(fname+'.h5', 'r') # Leo el h5: Recordar que nuestros datos estan en 'datasets' # Aca hago algo repugnante para poder levantar los strings que dejamos # que además tenian un error de tipeo al final. Esto no deberá ser necesario # cuando se solucione el error este del guardado. Freqs.append(np.array(data['datasets']['IR1_Frequencies'])) Counts.append(np.array(data['datasets']['counts_spectrum'])) #AmpTisa.append(np.array(data['datasets']['TISA_CPT_amp'])) #UVCPTAmp.append(np.array(data['datasets']['UV_CPT_amp'])) #No_measures.append(np.array(data['datasets']['no_measures'])) #%% #Barriendo angulo del IR con tisa apagado jvec = [0] jselected = jvec plt.figure() i = 0 for j in jvec: if j in jselected: plt.errorbar([2*f*1e-6 for f in Freqs[j]], Counts[j], yerr=np.sqrt(Counts[j]), fmt='o', capsize=2, markersize=2) #plt.plot([2*f*1e-6 for f in Freqs[j]], Counts[j], 'o-', label=f'Amp Tisa: {AmpTisa[i]}', mb arkersize=3) i = i + 1 plt.xlabel('Frecuencia (MHz)') plt.ylabel('counts') plt.grid() plt.legend() #%% from scipy.optimize import curve_fit import time phidoppler, titadoppler = 0, 90 phirepump, titarepump = 0, 90 phiprobe = 0 titaprobe = 0.1 Temp = 0.5e-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 = 32.5e6 #B = (u/(2*np.pi))/c gPS, gPD, = 2*np.pi*21.58e6, 2*np.pi*1.35e6 alpha = 0 drivefreq = 2*np.pi*22.135*1e6 noiseamplitude = 0 selectedcurve=0 FreqsDR = Freqs[selectedcurve] CountsDR = Counts[selectedcurve] freqslong = np.arange(min(FreqsDR), max(FreqsDR)+FreqsDR[1]-FreqsDR[0], 0.1*(FreqsDR[1]-FreqsDR[0])) CircPr = 1 alpha = 0 def FitEIT_MM_1ion(Freqs, offset, DetDoppler, DetRepump, SG, SP, SR, SCALE1, OFFSET, TEMP, U, plot=False): #def FitEIT_MM(freqs, SG, SP, SCALE1, OFFSET, BETA1): # BETA1 = 0 # SG = 0.6 # SP = 8.1 # TEMP = 0.2e-3 # U = 32.5e6 freqs = [2*f*1e-6-offset for f in Freqs] #Detunings, Fluorescence1 = PerformExperiment_8levels_MM(SG, SP, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, TEMP, alpha, phidoppler, titadoppler, phiprobe, titaprobe, BETA1, drivefreq, min(freqs), max(freqs)+(freqs[1]-freqs[0]), freqs[1]-freqs[0], circularityprobe=CircPr, plot=False, solvemode=1, detpvec=None) Detunings, Fluorescence1 = GenerateNoisyCPT_fit(SG, SR, SP, gPS, gPD, DetDoppler, DetRepump, U, DopplerLaserLinewidth, RepumpLaserLinewidth, ProbeLaserLinewidth, TEMP, alpha, phidoppler, titadoppler, phiprobe, [titaprobe], phirepump, titarepump, freqs, plot=False, solvemode=1, detpvec=None, noiseamplitude=noiseamplitude) ScaledFluo1 = np.array([f*SCALE1 + OFFSET for f in Fluorescence1]) if plot: return ScaledFluo1, Detunings else: return ScaledFluo1 #return ScaledFluo1 do_fit = True if do_fit: popt_1, pcov_1 = curve_fit(FitEIT_MM_1ion, FreqsDR, CountsDR, p0=[430, -25, 12, 0.9, 6.2, 3, 3e4, 2e3, 0.5e-3, 32e6], bounds=((0, -100, -20, 0, 0, 0, 0, 0, 0,20e6), (1000, 0, 50, 2, 20, 20, 5e6, 5e4, 15e-3,40e6))) FittedEITpi_1_short, Detunings_1_short = FitEIT_MM_1ion(FreqsDR, *popt_1, plot=True) freqslong = np.arange(min(FreqsDR), max(FreqsDR)+FreqsDR[1]-FreqsDR[0], 0.1*(FreqsDR[1]-FreqsDR[0])) FittedEITpi_1_long, Detunings_1_long = FitEIT_MM_1ion(freqslong, *popt_1, plot=True) #%% plt.figure() plt.errorbar(Detunings_1_short, CountsDR, yerr=2*np.sqrt(CountsDR), fmt='o', color='red', alpha=0.5, capsize=2, markersize=2) plt.plot(Detunings_1_long, FittedEITpi_1_long, color='darkolivegreen', linewidth=3, label='med 1') #plt.title(f'Sdop: {round(popt[0], 2)}, Spr: {round(popt[1], 2)}, T: {round(popt[2]*1e3, 2)} mK, detDop: {DetDoppler} MHz') plt.xlabel('Detuning (MHz)') plt.ylabel('Counts') #plt.xlim(-20,0) plt.legend(loc='upper left', fontsize=20) plt.grid() #%% u = 32.5e6 B = (u/(2*np.pi))/c correccion = 8 #con 8 fitea bien offsetxpi = 440+1+correccion DetDoppler = -5.0-correccion FreqsDRpi_3 = [2*f*1e-6-offsetxpi+14 for f in Freqs_B[5]] CountsDRpi_3 = Counts_B[5] freqslongpi_3 = np.arange(min(FreqsDRpi_3), max(FreqsDRpi_3)+FreqsDRpi_3[1]-FreqsDRpi_3[0], 0.1*(FreqsDRpi_3[1]-FreqsDRpi_3[0])) #[1.71811842e+04 3.34325038e-17] def FitEITpi(freqs, SG, SP): temp = 2e-3 MeasuredFreq, MeasuredFluo = GenerateNoisyCPT_fit(SG, sr, SP, gPS, gPD, DetDoppler, DetRepump, u, DopplerLaserLinewidth, RepumpLaserLinewidth, ProbeLaserLinewidth, temp, alpha, phidoppler, titadoppler, phiprobe, [titaprobe], phirepump, titarepump, freqs, plot=False, solvemode=1, detpvec=None, noiseamplitude=noiseamplitude) FinalFluo = [f*6.554e4 + 1.863e3 for f in MeasuredFluo] return FinalFluo popt_tisaoff, pcov_tisaoff = curve_fit(FitEITpi, FreqsDRpi_3, CountsDRpi_3, p0=[0.5, 4.5], bounds=((0, 0), (2, 10))) print(popt_tisaoff) Sat_3 = popt_tisaoff[0] Det_3 = popt_tisaoff[1] FittedEITpi_3 = FitEITpi(freqslongpi_3, *popt_tisaoff) plt.figure() plt.errorbar(FreqsDRpi_3, CountsDRpi_3, yerr=2*np.sqrt(CountsDRpi_3), fmt='o', capsize=2, markersize=2) plt.plot(freqslongpi_3, FittedEITpi_3) #plt.title(f'Sdop: {round(popt[0], 2)}, Spr: {round(popt[1], 2)}, T: {round(popt[2]*1e3, 2)} mK, detDop: {DetDoppler} MHz') FreqsCalibradas_B = FreqsDRpi_3