Skip to content
Saturation_Measurements.py 5.27 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 = """000002843-IR_Saturation.h5
000002844-IR_Saturation.h5
000002845-IR_Saturation.h5
000002846-IR_Saturation.h5
000002847-IR_Saturation.h5
000002848-IR_Saturation.h5
000002849-IR_Saturation.h5
000002850-IR_Saturation.h5
000002851-IR_Saturation.h5
000002852-IR_Saturation.h5
000002853-IR_Saturation.h5
000002854-IR_Saturation.h5
000002855-IR_Saturation.h5
000002856-IR_Saturation.h5
000002857-IR_Saturation.h5
000002858-IR_Saturation.h5
000002859-IR_Saturation.h5
000002860-IR_Saturation.h5
000002861-IR_Saturation.h5
000002862-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, 0.02, 0.04, 0.06, 0.08, 0.10, 0.12, 0.14, 0.16, 0.18, 0.20, 0.22, 0.24, 0.26, 0.28, 0.30, 0.32, 0.34, 0.35]
    powers = [0, 0.08, 1.7, 8.4, 25.5, 58.5, 114, 194, 297, 416, 550, 705, 867, 1016, 1148, 1285, 1385, 1463, 1501]
    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))

#%%    

#C:\Users\Usuario\Documents\artiq\artiq_experiments\analisis\plots\20210824_SaturacionTransiciones\Data_IR

IR_powers_vec = []
IR_fluorescence_vec = []


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 = 8

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=(4e3, 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()

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.xlim(-30, 300)
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
#g23 = 2*np.pi*23.05*1e6
radius = np.sqrt(12*c*c*2/(hbar*(w_866**3)*g23*factor))
print(f'Diametro: {2*radius*1e6} um')

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(-4, 100)
plt.ylim(-0.5, 4)
plt.xlabel('Potencia (uW)')
plt.ylabel('Sat Parameter DP')
plt.grid()
#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')