Analisis_Espectro_dummy.py 2.18 KB
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

# Solo levanto algunos experimentos
ALL_FILES = """000001853-IR_Scan.h5"""

#000001514-SingleLine.h5 #este tiene amplitud 0.08 que es muy poquito

BINW = 20e-9

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.array([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.array([5, 11, 20, 32, 47, 67, 86, 105, 120, 134, 144])
    return potencias_UV[np.where(amplitudes_UV == amp)][0]

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]))
potencias_UV = np.flip(np.array([4, 10, 19, 32, 49, 71, 96, 125, 155, 183, 208, 229]))
plt.plot(amplitudes_UV, potencias_UV, 'ko-', lw=0.2)
plt.xlabel("Amplitud Urukul")
plt.ylabel("Potencia /uW")
plt.grid()
#%%

## Mostrar corte de los histos:
# fig, ax = plt.subplots()
# ax.axvline(T0, color='k')

#os.chdir('/home/oem/Documentos/Doctorado/Artiq/Repositorio/artiq_experiments/artiq_master/results/2021-07-02/17')

#fig0, [ax0, ax1_a] = plt.subplots(1, 2)
#ax1_b = ax1_a.twinx()

allamps = np.array([])
allpows = np.array([])
alltaus = np.array([])
allN0 = np.array([])

for i, fname in enumerate(ALL_FILES.split()):
    print(i)
    print(fname)
    data = h5py.File(fname, '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.
    laser_UV_amp = data['datasets']['laser_UV_amp']
    laser_UV_freq = data['datasets']['laser_UV_freq']
    
    
    
    #print(laser_UV)
    measurements = np.array(data['datasets']['measurements'])
    freqs = np.array(data['datasets']['IR_frequencies'])
    n = np.array(data['datasets']['no_measures'])
    
    print(measurements)
    print(freqs)
    print(n)