Commit 346282a9 authored by Nicolas Nunez Barreto's avatar Nicolas Nunez Barreto

cosas desde la cnotebook

parent ee19408c
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 2 16:30:09 2020
@author: oem
"""
"""
ESTE ES EL CODIGO QUE PLOTEA CPT CON MICROMOCION BIEN
"""
import os
import numpy as np
import time
import matplotlib.pyplot as plt
from scipy.signal import argrelextrema
#from EITfit.MM_eightLevel_2repumps_python_scripts import CPTspectrum8levels_MM
import random
from scipy.signal import savgol_filter as sf
def PerformExperiment_8levels_MM(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=None):
"""
solvemode=1: resuelve con np.linalg.solve
solvemode=2: resuelve invirtiendo L con la funcion np.linalg.inv
"""
#tinicial = time.time()
ProbeDetuningVectorL, Fluovector = CPTspectrum8levels_MM(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, circularityprobe, beta, drivefreq, freqMin=freqMin, freqMax=freqMax, freqStep=freqStep, plot=False, solvemode=1)
#tfinal = time.time()
#print('Done, Total time: ', round((tfinal-tinicial), 2), "s")
return ProbeDetuningVectorL, Fluovector
def GenerateNoisyCPT_MM(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobeVec, kg, kr, v0, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None, noiseamplitude=0.001):
Frequencyvector, Fluovector = PerformExperiment_8levels_MM(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobeVec, kg, kr, v0, drivefreq, freqMin, freqMax, freqStep, circularityprobe, plot=False, solvemode=1, detpvec=None)
NoisyFluovector = [fluo+noiseamplitude*(2*random.random()-1) for fluo in Fluovector]
return Frequencyvector, NoisyFluovector
def GenerateNoisyCPT_MM_fit(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobeVec, beta, drivefreq, freqs, circularityprobe=1, plot=False, solvemode=1, detpvec=None, noiseamplitude=0.001):
Frequencyvector, Fluovector = PerformExperiment_8levels_MM(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobeVec, beta, drivefreq, freqs[0], freqs[-1], freqs[1]-freqs[0], circularityprobe, plot=False, solvemode=1, detpvec=None)
#NoisyFluovector = [fluo+noiseamplitude*(2*random.random()-1) for fluo in Fluovector]
return Frequencyvector, Fluovector
def SmoothNoisyCPT(Fluo, window=11, poly=3):
SmoothenFluo = sf(Fluo, window, poly)
return SmoothenFluo
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 1 17:58:39 2020
@author: nico
"""
import os
import numpy as np
#os.chdir('/home/oem/Nextcloud/G_liaf/liaf-TrampaAnular/Código General/EIT-CPT/Buenos Aires/Experiment Simulations/CPT scripts/Eight Level 2 repumps')
#from MM_eightLevel_2repumps_AnalysisFunctions import PerformExperiment_8levels, GenerateNoisyCPT, SmoothNoisyCPT
import matplotlib.pyplot as plt
import time
#from threeLevel_2repumps_AnalysisFunctions import MeasureRelativeFluorescenceFromCPT, IdentifyPolarizationCoincidences, RetrieveAbsoluteCoincidencesBetweenMaps, GetClosestIndex
import seaborn as sns
#C:\Users\Usuario\Nextcloud\G_liaf\liaf-TrampaAnular\Código General\EIT-CPT\Buenos Aires\Experiment Simulations\CPT scripts\Eight Level 2 repumps
ub = 9.27e-24 #magneton de bohr
h = 6.63e-34 #cte de planck
c = (ub/h)*1e-4 #en unidades de MHz/G
u = 2e6 #proportional to the magnetic field of around 5 G
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. #linewidth of the lasers, 0.1 MHz are the actual linewidths of both lasers
DopplerLaserLinewidth, ProbeLaserLinewidth = lw, lw #ancho de linea de los laseres
TempVec = [0e-3] #Temperature vector
alpha = 0 #angle between lasers, which is zero
#Polarization angles (we can keep it fixed in 90)
phidoppler, titadoppler = 0, 90
titaprobe = 90
phiprobe = 0
#este es el desfasaje exp(i.phi) de la componente de la polarizacion y respecto a la x. Con 1 la polarizacion es lineal
CircPr = 1 #this has to do with the circularity of the polarizations and since both are linear it is one
#Simulation parameters
center = -10
span = 200
freqMin = center-span*0.5
freqMax = center+span*0.5
freqStep = 2e-1
noiseamplitude = 0 #i dont know what it is
#parametros de saturacion de los laseres. g: doppler. p: probe (un rebombeo que scanea), r: repump (otro rebombeo fijo)
"""
Good case: sg=0.6, sp=9, DetDoppler=-15
"""
DetDoppler = -25 #nice range: -30 to 0
sgvec = [0.6] #nice range: 0.1 to 10 #g is for green but is the doppler
sp = 8 #nice range: 0.1 to 20 #p is for probe but is the repump
drivefreq=2*np.pi*22.135*1e6 #ignore it
#betavec = np.arange(0,1.1,0.1) #ignore it
betavec=[0] #ignore it
alphavec = [0] #ignore it
fig1, ax1 = plt.subplots()
FrequenciesVec = []
FluorescencesVec = []
for sg in sgvec:
for T in TempVec:
for alpha in alphavec:
for beta in betavec:
Frequencies, Fluorescence = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, beta, drivefreq, freqMin, freqMax, freqStep, circularityprobe=CircPr, plot=False, solvemode=1, detpvec=None)
FrequenciesVec.append(Frequencies)
FluorescencesVec.append(Fluorescence)
ax1.plot(Frequencies, [100*f for f in Fluorescence], label=fr'$\alpha={int(alpha*180/np.pi)}°$')
ax1.set_xlabel('Detuning Rebombeo (MHz)')
ax1.set_ylabel('Fluorescencia (AU)')
ax1.set_title(f'Sdop: {sg}, Spr: {sp}, Temp: {int(T*1e3)} mK')
#ax1.legend()
ax1.grid()
#%%
import seaborn as sns
paleta=sns.color_palette('mako')
plt.figure()
plt.plot(Frequencies, [100*f for f in Fluorescence], color=paleta[1], linewidth=3)
plt.grid()
plt.axvline(-25,color=paleta[2], linestyle='dashed')
plt.xlabel(r'$\Delta_2$ (MHz)', fontsize=25, fontname='STIXgeneral')
plt.ylabel('Fluorescence', fontsize=18, fontname='STIXgeneral')
#%%
#Este bloque ajusta a las curvas con un beta de micromocion de 0
from scipy.optimize import curve_fit
def FitEIT_MM(freqs, Temp):
BETA = 0
scale=1
offset=0
Detunings, Fluorescence = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, Temp, alpha, phidoppler, titadoppler, phiprobe, titaprobe, BETA, drivefreq, freqMin, freqMax, freqStep, circularityprobe=CircPr, plot=False, solvemode=1, detpvec=None)
ScaledFluo = [f*scale + offset for f in Fluorescence]
return ScaledFluo
TempMedidas = []
FittedEIT_fluosVec = []
for j in range(len(betavec)):
SelectedFluo = FluorescencesVec[j]
SelectedFreqs = FrequenciesVec[j]
popt_mm, pcov_mm = curve_fit(FitEIT_MM, SelectedFreqs, SelectedFluo, p0=[1e-3], bounds=((0), (10e-3)))
TempMedidas.append(1e3*popt_mm[2])
print(popt_mm)
FittedEIT_fluo = FitEIT_MM(SelectedFreqs, *popt_mm)
FittedEIT_fluosVec.append(FittedEIT_fluo)
plt.figure()
plt.plot(SelectedFreqs, SelectedFluo, 'o')
plt.plot(SelectedFreqs, FittedEIT_fluo)
plt.figure()
for i in range(len(FluorescencesVec)):
plt.plot(SelectedFreqs, FluorescencesVec[i], 'o', markersize=3)
plt.plot(SelectedFreqs, FittedEIT_fluosVec[i])
plt.figure()
plt.plot(betavec, TempMedidas, 'o', markersize=10)
plt.xlabel('Beta')
plt.ylabel('Temperatura medida (mK)')
plt.axhline(T*1e3, label='Temperatura real', linestyle='--', color='red')
plt.legend()
plt.grid()
\ No newline at end of file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 1 17:58:39 2020
@author: oem
"""
import os
import numpy as np
#os.chdir('/home/oem/Nextcloud/G_liaf/liaf-TrampaAnular/Código General/EIT-CPT/Buenos Aires/Experiment Simulations/CPT scripts/Eight Level 2 repumps')
from threeLevel_2repumps_AnalysisFunctions import CalculoTeoricoDarkResonances_8levels, GetMinimaInfo, GetPlotsofFluovsAngle_8levels, PerformExperiment_8levels, FindDRFrequencies, FindRelativeFluorescencesOfDR, GenerateNoisyCPT, SmoothNoisyCPT, GetFinalMaps, GenerateNoisyCPT_fixedRabi, GenerateNoisyCPT_fit
import matplotlib.pyplot as plt
import time
from threeLevel_2repumps_AnalysisFunctions import MeasureRelativeFluorescenceFromCPT, IdentifyPolarizationCoincidences, RetrieveAbsoluteCoincidencesBetweenMaps, GetClosestIndex
#C:\Users\Usuario\Nextcloud\G_liaf\liaf-TrampaAnular\Código General\EIT-CPT\Buenos Aires\Experiment Simulations\CPT scripts\Eight Level 2 repumps
ub = 9.27e-24
h = 6.63e-34
c = (ub/h)*1e-4 #en unidades de MHz/G
#u = 1e6
u = 33.5e6
B = (u/(2*np.pi))/c
#sg, sp = 0.6, 5 #parámetros de control, saturación del doppler y repump
#rabG, rabP = sg*gPS, sp*gPD #frecuencias de rabi
gPS, gPD, = 2*np.pi*21.58e6, 2*np.pi*1.35e6 #anchos de linea de las transiciones
lw = 0.1
DopplerLaserLinewidth, RepumpLaserLinewidth, ProbeLaserLinewidth = lw, lw, lw #ancho de linea de los laseres
DetDoppler = -36 #42
DetRepumpVec = [DetDoppler+29.6]
Tvec = [0.7] #temperatura en mK
alpha = 0*(np.pi/180) #angulo entre los láseres
phidoppler, titadoppler = 0, 90
phirepump, titarepump = 0, 0
phiprobe = 0
titaprobe = 90
#Calculo las resonancias oscuras teóricas
#ResonanciasTeoricas, DRPositivas = CalculoTeoricoDarkResonances_8levels(u/(2*np.pi*1e6), titadoppler, DetDoppler, DetRepump)
#Parametros de la simulacion cpt
center = -45
span = 80
freqMin = center-span*0.5
freqMax = center+span*0.5
""" parametros para tener espectros coherentes
freqMin = -56
freqMax = 14
"""
freqStep = 1e-1
noiseamplitude = 0
RelMinMedido0Vector = []
RelMinMedido1Vector = []
RelMinMedido2Vector = []
RelMinMedido3Vector = []
RelMinMedido4Vector = []
#Sr = np.arange(0, 10, 0.2)
#Sg = np.arange(0.01, 1, 0.05)
#Sp = np.arange(0.1, 6.1, 1)
#Sg = [0.6**2]
#Sp = [2.3**2]
Sg = [1.4]
Sp = [6]
Sr = [11]
i = 0
save = False
showFigures = True
if not showFigures:
plt.ioff()
else:
plt.ion()
fig1, ax1 = plt.subplots()
offsetx = 464
ax1.plot([f-offsetx for f in FreqsDR], CountsDR, 'o')
run = True
Scale = 730
Offset = 600 #600 para 20k cuentas aprox
MaxCoherenceValue = []
for sg in Sg:
for sp in Sp:
rabG, rabP = sg*gPS, sp*gPD
for Ti in Tvec:
T = Ti*1e-3
for DetRepump in DetRepumpVec:
print(T)
for sr in Sr:
rabR = sr*gPD
#MeasuredFreq, MeasuredFluo = GenerateNoisyCPT(rabG, rabR, rabP, gPS, gPD, DetDoppler, DetRepump, u, DopplerLaserLinewidth, RepumpLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, [titaprobe], phirepump, titarepump, freqMin, freqMax, freqStep, plot=False, solvemode=1, detpvec=None, noiseamplitude=noiseamplitude)
if run:
MeasuredFreq4, MeasuredFluo4 = GenerateNoisyCPT_fixedRabi(sg, sr, sp, gPS, gPD, DetDoppler, DetRepump, u, DopplerLaserLinewidth, RepumpLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, [titaprobe], phirepump, titarepump, freqMin, freqMax, freqStep, plot=False, solvemode=1, detpvec=None, noiseamplitude=noiseamplitude)
#SmoothFluo = SmoothNoisyCPT(MeasuredFluo, window=9, poly=2)
SmoothFluo4 = MeasuredFluo4
#Scale = max(BestC)/max([100*s for s in SmoothFluo4])
ax1.plot(MeasuredFreq4, [Scale*100*f + Offset for f in SmoothFluo4], label=f'Sr = {sr}')
ax1.axvline(DetDoppler, linestyle='--', linewidth=1)
#if sr != 0:
#ax1.axvline(DetRepump, linestyle='--', linewidth=1)
MaxCoherenceValue.append(np.max(SmoothFluo4))
#print(titaprobe)
ax1.set_xlabel('Detuning Rebombeo (MHz)')
ax1.set_ylabel('Fluorescencia (AU)')
ax1.set_title(f'B: {round(B, 2)} G, Sdop: {round(sg, 2)}, Sp: {round(sp, 2)}, Sr: {round(sr, 2)}, lw: {lw} MHz, T: {Ti} mK')
#ax1.set_ylim(0, 8)
#ax1.axvline(DetDoppler, linestyle='dashed', color='red', linewidth=1)
#ax1.axvline(DetRepump, linestyle='dashed', color='black', linewidth=1)
#ax1.set_title('Pol Doppler y Repump: Sigma+ Sigma-, Pol Probe: PI')
#ax1.legend()
ax1.grid()
print (f'{i+1}/{len(Sg)*len(Sp)}')
i = i + 1
if save:
plt.savefig(f'Mapa_plots_100k_1mk/CPT_SMSM_sdop{round(sg, 2)}_sp{round(sp, 2)}_sr{round(sr, 2)}.jpg')
ax1.legend()
"""
plt.figure()
plt.plot(Sr, MaxCoherenceValue, 'o')
plt.xlabel('Sr')
plt.ylabel('Coherence')
"""
"""
plt.figure()
plt.plot(MeasuredFreq, [100*f for f in SmoothFluo], color='darkred')
plt.xlabel('Desintonía 866 (MHz)')
plt.ylabel('Fluorescencia (A.U.)')
plt.axvline(-30, color='darkblue', linewidth=1.2, linestyle='--')
plt.yticks(np.arange(0.4, 1.8, 0.2))
plt.ylim(0.5, 1.6)
plt.grid()
plt.figure()
plt.plot(MeasuredFreq4, [100*f for f in SmoothFluo4], color='darkred')
plt.xlabel('Desintonía 866 (MHz)')
plt.ylabel('Fluorescencia (A.U.)')
plt.axvline(-30, color='darkblue', linewidth=1.2, linestyle='--')
plt.yticks(np.arange(0.8, 2.4, 0.4))
plt.grid()
"""
#%%
from scipy.optimize import curve_fit
T = 0.5e-3
sg = 0.7
sp = 6
sr = 0
DetDoppler = -14
DetRepump = 0
FitsSp = []
FitsOffset = []
Sg = [0.87]
def FitEIT(freqs, SP, offset):
MeasuredFreq, MeasuredFluo = GenerateNoisyCPT_fit(0.87, sr, SP, gPS, gPD, DetDoppler, DetRepump, u, DopplerLaserLinewidth, RepumpLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, [titaprobe], phirepump, titarepump, freqs, plot=False, solvemode=1, detpvec=None, noiseamplitude=noiseamplitude)
FinalFluo = [f*43000 + 2685 for f in MeasuredFluo]
return FinalFluo
freqs = [f-offsetx+32 for f in FreqsDR]
freqslong = np.arange(min(freqs), max(freqs)+freqs[1]-freqs[0], 0.1*(freqs[1]-freqs[0]))
popt, pcov = curve_fit(FitEIT, freqs, CountsDR, p0=[5, 700], bounds=(0, [10, 1e6]))
FitsSp.append(popt[0])
FitsOffset.append(popt[1])
print(popt)
FittedEIT = FitEIT(freqslong, *popt)
plt.figure()
plt.errorbar(freqs, CountsDR, yerr=2*np.sqrt(CountsDR), fmt='o', capsize=2, markersize=2)
plt.plot(freqslong, FitEIT(freqslong, *popt))
plt.title(f'Sdop: {round(popt[0], 2)}, Spr: {round(popt[1], 2)}, T: {T*1e3} mK, detDop: {DetDoppler} MHz')
np.savetxt('CPT_measured.txt', np.transpose([freqs, CountsDR]))
np.savetxt('CPT_fitted.txt', np.transpose([freqslong, FittedEIT]))
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