From 354ec93a791929d2e7453ae22ce7e8f898cc5fbd Mon Sep 17 00:00:00 2001 From: Eric Teunis de Boone Date: Mon, 24 Apr 2023 13:12:53 +0200 Subject: [PATCH] Pulse timing: trace_resamplers paramater change --- simulations/11_pulsed_timing.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/simulations/11_pulsed_timing.py b/simulations/11_pulsed_timing.py index 499fe97..77c9840 100755 --- a/simulations/11_pulsed_timing.py +++ b/simulations/11_pulsed_timing.py @@ -106,7 +106,7 @@ def my_correlation(in1, template, lags=None): return corrs, (in1, template, lags) -def trace_upsampler(template_signal, trace, template_t, trace_t): +def trace_upsampler(trace, template_t, trace_t): template_dt = template.t[1] - template.t[0] trace_dt = trace_t[1] - trace_t[0] @@ -125,7 +125,7 @@ def trace_upsampler(template_signal, trace, template_t, trace_t): return upsampled_trace, upsampled_t -def template_downsampler(template_signal, trace, template_t, trace_t, offset): +def trace_downsampler(trace, template_t, trace_t, offset): pass @@ -138,7 +138,7 @@ if __name__ == "__main__": bp_freq = (30e-3, 80e-3) # GHz template_dt = 5e-2 # ns - template_length = 100 # ns + template_length = 500 # ns noise_sigma_factor = 1e0 # keep between 10 and 0.1 N_residuals = 50*3 if len(sys.argv) < 2 else int(sys.argv[1]) @@ -236,7 +236,7 @@ if __name__ == "__main__": axs2 = None if True: # upsampled trace - upsampled_trace, upsampled_t = trace_upsampler(template.signal, antenna.signal, template.t, antenna.t) + upsampled_trace, upsampled_t = trace_upsampler(antenna.signal, template.t, antenna.t) if do_plots: # Show upsampled traces fig2, axs2 = plt.subplots(1, sharex=True) @@ -337,14 +337,15 @@ if __name__ == "__main__": plt.close(fig) # Make a plot of the time residuals - fig, ax = plt.subplots() - ax.set_title("Template Correlation Lag finding") - ax.set_xlabel("Time Residual [ns]") - ax.set_ylabel("#") - ax.hist(time_residuals, bins='sqrt', density=False) + if len(time_residuals) > 1: + fig, ax = plt.subplots() + ax.set_title("Template Correlation Lag finding") + ax.set_xlabel("Time Residual [ns]") + ax.set_ylabel("#") + ax.hist(time_residuals, bins='sqrt', density=False) - ax.legend(title=f"template dt: {template.dt: .1e}ns\nantenna dt: {antenna.dt: .1e}ns") + ax.legend(title=f"template dt: {template.dt: .1e}ns\nantenna dt: {antenna.dt: .1e}ns") - fig.savefig("figures/11_time_residual_hist.pdf") + fig.savefig("figures/11_time_residual_hist.pdf") plt.show()