From ecc79a8c91859c01811f85387c12660cce3423a9 Mon Sep 17 00:00:00 2001 From: Eric Teunis de Boone Date: Thu, 8 Dec 2022 15:22:27 +0100 Subject: [PATCH] ZH: period_from_shower sort by maxima Start by correlating the strongest signals --- .../ca_period_from_shower.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/simulations/airshower_beacon_simulation/ca_period_from_shower.py b/simulations/airshower_beacon_simulation/ca_period_from_shower.py index 40714b2..c772e90 100755 --- a/simulations/airshower_beacon_simulation/ca_period_from_shower.py +++ b/simulations/airshower_beacon_simulation/ca_period_from_shower.py @@ -28,6 +28,7 @@ def find_best_sample_shifts_summing_at_location(test_loc, antennas, allowed_samp t_ = [] t_min = 1e9 t_max = -1e9 + a_maxima = [] if dt is None: dt = antennas[0].t_AxB[1] - antennas[0].t_AxB[0] @@ -41,12 +42,18 @@ def find_best_sample_shifts_summing_at_location(test_loc, antennas, allowed_samp t__ = np.subtract(ant.t_AxB, delta) t_.append(t__) a_.append(ant.E_AxB) + a_maxima.append(max(ant.E_AxB)) if t__[0] < t_min: t_min = t__[0] if t__[-1] > t_max: t_max = t__[-1] + # sort traces with descending maxima + sort_idx = np.argsort(a_maxima)[::-1] + t_ = [ t_[i] for i in sort_idx ] + a_ = [ a_[i] for i in sort_idx ] + # Interpolate and find best sample shift max_neg_shift = 0 #np.min(allowed_sample_shifts) * dt max_pos_shift = 0 #np.max(allowed_sample_shifts) * dt @@ -92,6 +99,11 @@ def find_best_sample_shifts_summing_at_location(test_loc, antennas, allowed_samp fig.savefig(path.join(fig_dir, __file__ + '.loc{:.1f}-{:.1f}-{:.1f}'.format(*test_loc) + f'.i{i}{fig_distinguish}.pdf')) plt.close(fig) + # sort by antenna (undo sorting by maximum) + undo_sort_idx = np.argsort(sort_idx) + + best_sample_shifts = best_sample_shifts[undo_sort_idx] + # Return ks return best_sample_shifts, np.max(a_sum)