Loading analisis/plots/20210714_CalibrationsTests/Calibration_tests.py +60 −2 Changes for analisis/plots/20210714_CalibrationsTests/Calibration_tests.py: 60 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -56,33 +56,91 @@ plt.ylabel('Amplitud Artiq') plt.xlabel("Voltaje fotodiodo (V)") plt.legend() #%% def RemoveZeros(calib, freqs): i, j = 0, 1 new_calib = calib while i < len(calib): if new_calib[0] == 0: new_calib = new_calib[1:] i = i + 1 else: init_len = len(new_calib) final_calib = new_calib while j < init_len: if final_calib[-1] == 0: final_calib = final_calib[:-1] j = j + 1 else: if j == 1: return (i, j), freqs[i:], final_calib else: return (i, j), freqs[i:-j+1], final_calib lista = [0, 1, 0, 1, 0, 0, 1, 1, 0, 0] freqs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] tupla, new_freqs, calib = RemoveZeros(lista, freqs) print(new_freqs) print(calib) #%% i = 15 interpolations = [] interpolations_g = [] for i in range(len(PD_T)): PD = np.array(PD_T[i][0])[0] amps = Calibration_amps f = interpolate.interp1d(PD, amps, kind='quadratic') g = interpolate.interp1d(amps, PD, kind='quadratic') xs = np.arange(min(PD), max(PD), 1e-4) interpolations.append(f) interpolations_g.append(g) Calibration_PD_value = 0.2 Calibs = [] for fi in interpolations: try: Calibs.append(fi(0.2)) Calibs.append(float(fi(Calibration_PD_value))) except: Calibs.append(0) plt.plot(freqs, Calibs, 'o') fig, ax1 = plt.subplots() ax2 = ax1.twinx() ax1.plot([f*1e-6 for f in freqs], Calibs, 'o', label='Amplitudes a setear') EffectivePD = [] for i in range(len(Calibs)): try: EffectivePD.append(interpolations_g[i](Calibs[i])) except: EffectivePD.append(0) ax2.plot([f*1e-6 for f in freqs], EffectivePD, 'ro', label='Potencia') ax1.set_xlabel('Frecuencia (MHz)') ax1.set_ylabel('Amplitudes') ax2.set_ylabel('Potencia PD (V)') fig.legend() h = interpolate.interp1d(freqs, Calibs, kind='quadratic') xs2 = np.arange(min(freqs), max(freqs), 1e5) plt.figure() plt.plot(freqs, Calibs, 'o') plt.plot(xs2, h(xs2)) Loading Loading
analisis/plots/20210714_CalibrationsTests/Calibration_tests.py +60 −2 Changes for analisis/plots/20210714_CalibrationsTests/Calibration_tests.py: 60 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -56,33 +56,91 @@ plt.ylabel('Amplitud Artiq') plt.xlabel("Voltaje fotodiodo (V)") plt.legend() #%% def RemoveZeros(calib, freqs): i, j = 0, 1 new_calib = calib while i < len(calib): if new_calib[0] == 0: new_calib = new_calib[1:] i = i + 1 else: init_len = len(new_calib) final_calib = new_calib while j < init_len: if final_calib[-1] == 0: final_calib = final_calib[:-1] j = j + 1 else: if j == 1: return (i, j), freqs[i:], final_calib else: return (i, j), freqs[i:-j+1], final_calib lista = [0, 1, 0, 1, 0, 0, 1, 1, 0, 0] freqs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] tupla, new_freqs, calib = RemoveZeros(lista, freqs) print(new_freqs) print(calib) #%% i = 15 interpolations = [] interpolations_g = [] for i in range(len(PD_T)): PD = np.array(PD_T[i][0])[0] amps = Calibration_amps f = interpolate.interp1d(PD, amps, kind='quadratic') g = interpolate.interp1d(amps, PD, kind='quadratic') xs = np.arange(min(PD), max(PD), 1e-4) interpolations.append(f) interpolations_g.append(g) Calibration_PD_value = 0.2 Calibs = [] for fi in interpolations: try: Calibs.append(fi(0.2)) Calibs.append(float(fi(Calibration_PD_value))) except: Calibs.append(0) plt.plot(freqs, Calibs, 'o') fig, ax1 = plt.subplots() ax2 = ax1.twinx() ax1.plot([f*1e-6 for f in freqs], Calibs, 'o', label='Amplitudes a setear') EffectivePD = [] for i in range(len(Calibs)): try: EffectivePD.append(interpolations_g[i](Calibs[i])) except: EffectivePD.append(0) ax2.plot([f*1e-6 for f in freqs], EffectivePD, 'ro', label='Potencia') ax1.set_xlabel('Frecuencia (MHz)') ax1.set_ylabel('Amplitudes') ax2.set_ylabel('Potencia PD (V)') fig.legend() h = interpolate.interp1d(freqs, Calibs, kind='quadratic') xs2 = np.arange(min(freqs), max(freqs), 1e5) plt.figure() plt.plot(freqs, Calibs, 'o') plt.plot(xs2, h(xs2)) Loading