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
#os.chdir('/home/nico/Documents/artiq_experiments/analisis/plots/20221017_IonStatistics')
def expo(T, tau, N0, C):
global T0
return N0*np.exp(-(T-T0)/tau) + C
def pow_from_amp(amp):
"""Paso de amplitud urukul a potencia medida por Nico"""
# Forma altamente ineficiente de hacer esto, pero me salio asi
amplitudes_UV = np.flip(np.array([0.08, 0.10, 0.12, 0.14, 0.16, 0.18, 0.20, 0.22, 0.24, 0.26, 0.28, 0.30]))
assert amp in amplitudes_UV
potencias_UV = np.flip(np.array([4, 10, 19, 32, 49, 71, 96, 125, 155, 183, 208, 229]))
return potencias_UV[np.where(amplitudes_UV == amp)][0]
"""
plt.plot(amplitudes_UV, potencias_UV, 'ko-', lw=0.2)
plt.xlabel("Amplitud Urukul")
plt.ylabel("Potencia /uW")
plt.grid()
"""
#%%
BINW = 10e-9
T0 = 0.0e-6
Stat_Heigths = []
Stat_Bins = []
OnOff_Heights = []
OnOff_Bins = []
for i, fname in enumerate(Stat_files[0:3]):
#print(i)
#print(fname)
data = h5py.File('Data/00000'+str(fname)+'-IonStatistics.h5', 'r')
counts = np.array(data['datasets']['counts'])
bines = np.arange(counts.min(), counts.max()+BINW, BINW)
heigs, binsf = np.histogram(counts, bines[bines>T0])
Stat_Heigths.append(heigs)
Stat_Bins.append(binsf)
for i, fname in enumerate(Stat_files[3:6]):
#print(i)
#print(fname)
try:
data = h5py.File('Data/00000'+str(fname)+'-SingleLine.h5', 'r')
except:
data = h5py.File('Data/00000'+str(fname)+'-StationaryFluo.h5', 'r')
counts = np.array(data['datasets']['counts'])
bines = np.arange(counts.min(), counts.max()+BINW, BINW)
heigs, binsf = np.histogram(counts, bines[bines>T0])
OnOff_Heights.append(heigs)
OnOff_Bins.append(binsf)
#plt.figure()
#plt.plot(Stat_Bins[0][:-1], Stat_Heigths[0])
colors1=sns.color_palette("rocket", 10)
colors2=sns.color_palette("mako", 10)
color2 = colors2[1]
color3 = colors2[4]
color1 = colors2[8]
bins1 = np.arange(150,300, 1)
bins2 = np.arange(0,50,1)
"""
FIGURA ESTADISTICA POISSON
"""
fig,ax=plt.subplots(1,2,gridspec_kw={'width_ratios': [1, 1]},figsize=(6.5,3.))
#plt.figure(figsize = (9,3.5))
ax[1].hist(Stat_Heigths[0], bins=bins1, histtype='step',density = True,color = color1,linewidth=2, alpha = 0.6)#,label = 'BG')
ax[1].hist(Stat_Heigths[1], bins=bins2, histtype='step',density = True,color = color2,linewidth=2, alpha = 0.6)#,label = 'UV laser')
ax[1].hist(Stat_Heigths[2], bins=bins3, histtype='step',density = True,color = color3,linewidth=2, alpha = 0.6)#,label = 'Ion')
poisson1= sts.poisson.pmf(bins1,np.mean(Stat_Heigths[0]))
poisson2= sts.poisson.pmf(bins2,np.mean(Stat_Heigths[1]))
poisson3= sts.poisson.pmf(bins3,np.mean(Stat_Heigths[2]))
ax[1].plot(bins2+0.5,poisson2,color = color2,label = 'Señal de fondo',linewidth=1.5)
ax[1].plot(bins3+0.5,poisson3,color = color3,label = 'Láser UV',linewidth=1.5)
ax[1].plot(bins1+0.5,poisson1,color = color1,label = 'Ion',linewidth=1.5)
ax[1].legend(loc='upper right', prop={'size': 10})
ax[1].grid()
ax[1].set_xticks([0, 100, 200, 300])
ax[1].set_yticklabels([0,0.02, 0.04, 0.06, 0.08], fontsize=10)
ax[1].set_xlabel('Cuentas', fontsize=10)
ax[1].set_ylabel('Frecuencia de eventos', fontsize=10)
#plt.savefig('C:/Users/nicon/Nextcloud/Nico/Doctorado/Tesis/Tesis_doctorado/Chapters/figures/Cap5_poisson.pdf')
#poissoneidad = np.var(Stat_Heigths)/np.mean(Stat_Heigths)
#plt.title('Varianza/media = {:.4f}'.format(poissoneidad))
#plt.savefig('bg_laser_ion_stats.pdf',dpi = 600 )
name='fig01a'
"""
FIGURA BACKGROUND, ENCENDIDO AOM Y ENCENDIDO ION
"""
#plt.figure(figsize=(4.5,3))
ax[0].plot([s*1e6 for s in OnOff_Bins[1][:-1]],OnOff_Heights[1], color=color2,linewidth=3)
ax[0].plot([s*1e6 for s in OnOff_Bins[0][:-1]],[(OnOff_Heights[0][j]-OnOff_Heights[1][j])*3.13+OnOff_Heights[1][j] for j in range(len(OnOff_Heights[0]))], color=color3,linewidth=3)
ax[0].plot([s*1e6 for s in OnOff_Bins[2][:-1]],OnOff_Heights[2], color=color1,linewidth=3)
ax[0].set_xlim(0,1)
ax[0].grid()
ax[0].set_xlabel(r'Tiempo ($\mu$s)', fontsize=10)
ax[0].set_ylabel(r'Cuentas /10$~\mu$s',fontsize=10)
ax[0].set_xticks([0,0.2, 0.4, 0.6, 0.8, 1])
ax[0].set_yticks([0,5000, 10000])
ax[0].set_xticklabels([0,0.2, 0.4, 0.6, 0.8, 1], fontsize=10)
ax[0].set_yticklabels([0,5000, 10000], fontsize=10)
# plt.savefig('C:/Users/nicon/Nextcloud/Nico/Doctorado/Tesis/Tesis_doctorado/Chapters/figures/Cap5_statistics.pdf')
# plt.savefig('C:/Users/nicon/Nextcloud/Nico/Doctorado/Tesis/Tesis_doctorado/Chapters/figures/Cap5_statistics.pdf')
plt.savefig('C://Users//nicon//Nextcloud//Nico//Doctorado//Tesis//Tesis_doctorado//Chapters//figures//Cap4//Cap4_statistics.pdf')
#plt.savefig('/home/nico/Nextcloud/G_liaf/Publicaciones/Papers/2022 Transient Phenomena JOSA B/Figures/'+name+'.pdf')
#plt.savefig('/home/nico/Nextcloud/G_liaf/Publicaciones/Papers/2022 Transient Phenomena JOSA B/Figures/'+name+'_dump.svg')