Skip to content
Saturation_Measurements_FixedAlignment.py 4.46 KiB
Newer Older
import h5py
import matplotlib.pyplot as plt
import numpy as np
import sys
import re
import ast
from scipy.optimize import curve_fit
import os
from scipy import interpolate

# Solo levanto algunos experimentos
Calib_Files_IR = """000003547-IR_Saturation.h5""" 

Calib_Files_UV = """000002865-UV_Saturation.h5
000002866-UV_Saturation.h5
000002867-UV_Saturation.h5
000002868-UV_Saturation.h5
000002869-UV_Saturation.h5
000002870-UV_Saturation.h5
000002871-UV_Saturation.h5
000002872-UV_Saturation.h5
000002873-UV_Saturation.h5
000002874-UV_Saturation.h5
000002875-UV_Saturation.h5"""

#carpeta pc nico labo escritorio:
#C:\Users\Usuario\Documents\artiq\artiq_experiments\analisis\plots\20210824_SaturacionTransiciones\Data_UV
#C:\Users\Usuario\Documents\artiq\artiq_experiments\analisis\plots\20210824_SaturacionTransiciones\Data_IR

def SeeKeys(files):
    for i, fname in enumerate(files.split()):
        data = h5py.File(fname, 'r') # Leo el h5: Recordar que nuestros datos estan en 'datasets'
        print(fname)
        print(list(data['datasets'].keys()))

def ConvertIRampstoPower(amp):
    amps = [0.01, 0.03, 0.05, 0.07, 0.09, 0.11, 0.13, 0.15, 0.17, 0.19, 0.21, 0.23, 0.25, 0.27, 0.29, 0.31, 0.33, 0.35]
    powers = [0, 0.22, 1.42, 5.1, 13.13, 27, 48, 78, 116, 161, 211, 261, 310, 363, 412, 448, 486, 516]
    f = interpolate.interp1d(amps, powers)
    return f(amp)


def SaturationCurve(p, F0, a, det):
    return 0.5*F0*a*p*(1/(1+a*p+4*((det**2)/(g23**2))))

def SaturationCurve_detzero(p, F0, a):
    return 0.5*F0*a*p*(1/(1+a*p))

#%%    

IR_powers_vec = []
IR_fluorescence_vec = []

#C:\Users\Usuario\Documents\artiq\artiq_experiments\analisis\plots\20210906_SaturacionTransiciones_MejorAlineacion\Data_IR

for i, fname in enumerate(Calib_Files_IR.split()):
    print(i)
    #print(fname)
    data = h5py.File(fname, 'r') # Leo el h5: Recordar que nuestros datos estan en 'datasets'
    #print(list(data['datasets'].keys()))
    meas = np.array(data['datasets']['measurements_IR_sat'])
    IR_fluorescence_vec.append(meas)
    IR_meas_amps = np.array(data['datasets']['IR_amps'])
    IR_meas_powers = [ConvertIRampstoPower(amp) for amp in IR_meas_amps]
    IR_powers_vec.append(IR_meas_powers)
    

#%%
#Calculo el coeficiente de proporcionalidad entre S y Pot
j = 0

def SaturationCurve_detzero(p, F0, a):
    return 0.5*F0*a*p*(1/(1+a*p))

IR_powers_vec_W = [p*1e-6 for p in IR_powers_vec[j]]

popt, pcov = curve_fit(SaturationCurve_detzero, IR_powers_vec_W, IR_fluorescence_vec[j], p0=(2e3, 5e4))

plt.figure()
plt.plot([popt[1]*p for p in IR_powers_vec_W], IR_fluorescence_vec[j], 'o')
plt.plot([popt[1]*p for p in IR_powers_vec_W], [SaturationCurve_detzero(p, popt[0], popt[1]) for p in IR_powers_vec_W])
plt.xlabel('Sat Parameter DP')
plt.ylabel('counts')
plt.title('Detuning = 0 MHz')
plt.grid()


plt.figure()
plt.plot([1e6*p for p in IR_powers_vec_W], IR_fluorescence_vec[j], 'o')
plt.plot([1e6*p for p in IR_powers_vec_W], [SaturationCurve_detzero(p, popt[0], popt[1]) for p in IR_powers_vec_W])
plt.xlabel('Potencia (uW)')
plt.ylabel('counts')
plt.title('Detuning = 0 MHz')
plt.grid()


print(popt)

factor = popt[1]

w_866 = 2*np.pi*346e12
w_397 = 2*np.pi*755e12

c=3e8
hbar = 1.05e-34

g21, g23 = 2*np.pi*21.58e6, 2*np.pi*1.35e6

g23b = 2*np.pi*23.05*1e6

radius = np.sqrt(6*c*c*2/(hbar*(w_866**3)*g23*factor))
print(f'Diametro: {2*radius*1e6} um')

print(f'Isat: {(2/(factor*np.pi*(radius**2)))*1e3/1e4} mW/cm2')

plt.figure()
plt.plot([p*1e6 for p in IR_powers_vec_W], [popt[1]*p for p in IR_powers_vec_W], 'o')
plt.xlim(-10, 100)
plt.ylim(-1, 5)
#plt.xlabel()
#%%
#Calculo el coeficiente de proporcionalidad entre S y Pot
j = 16

w_866 = 2*np.pi*346e12
w_397 = 2*np.pi*755e12

c=3e8
hbar = 1.05e-34

g21, g23 = 2*np.pi*21.58e6, 2*np.pi*1.35e6

g23 = 2*np.pi*23.05*1e6

def SaturationCurve(p, F0, det):
    return 0.5*F0*factor*p*(1/(1+factor*p+4*((det**2)/(g23**2))))


IR_powers_vec_W = [p*1e-6 for p in IR_powers_vec[j]]

popt, pcov = curve_fit(SaturationCurve, IR_powers_vec_W, IR_fluorescence_vec[j], p0=(4e3, 2e7))

plt.figure()
plt.plot([factor*p for p in IR_powers_vec_W], IR_fluorescence_vec[j], 'o', label=f'Det: {round(1e-6*popt[1]/(2*np.pi), 1)} MHz')
plt.plot([factor*p for p in IR_powers_vec_W], [SaturationCurve(p, popt[0], popt[1]) for p in IR_powers_vec_W])
plt.xlabel('Sat Parameter DP')
plt.ylabel('counts')
plt.legend()
plt.grid()

#factor = popt[1]

print(f'Detuning: {1e-6*popt[1]/(2*np.pi)} MHz')

#radius = np.sqrt(12*c*c/(hbar*(w_866**3)*g23*factor))
#print(f'Diametro: {2*radius*1e6} um')