From 5ccba0158ca49e9fac6c3d9639b3ab65c97dbc2f Mon Sep 17 00:00:00 2001 From: Eric Teunis de Boone Date: Wed, 1 Feb 2023 17:10:20 +0100 Subject: [PATCH] ZH: gridpower with time offsets zooms on some shifted traces --- .../dc_grid_power_time_fixes.py | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/simulations/airshower_beacon_simulation/dc_grid_power_time_fixes.py b/simulations/airshower_beacon_simulation/dc_grid_power_time_fixes.py index 2372ac8..585f080 100755 --- a/simulations/airshower_beacon_simulation/dc_grid_power_time_fixes.py +++ b/simulations/airshower_beacon_simulation/dc_grid_power_time_fixes.py @@ -194,19 +194,49 @@ if __name__ == "__main__": power_sort_idx = np.argsort(a_max) N_plot = 30 - for i, idx in enumerate(power_sort_idx): + for i, idx in enumerate(reversed(power_sort_idx)): if i > N_plot: break - - alpha = max(0.7, 1/len(a_)) - axs.plot(t_[idx], a_[idx], color='r', alpha=alpha) + alpha = max(0.4, 1/len(a_)) + + axs.plot(t_[idx], a_[idx], color='r', alpha=alpha, lw=2) if fig_dir: fig.tight_layout() + fig.savefig(path.join(fig_dir, path.basename(__file__) + f'.trace_overlap.{case}.pdf')) fig.savefig(path.join(fig_dir, path.basename(__file__) + f'.trace_overlap.{case}.png'), transparent=True) + # Take center between t_low and t_high + if True: + orig_xlims = axs.get_xlim() + + if not True: # t_high and t_low from strongest signal + t_low = np.min(t_[power_sort_idx[-1]]) + t_high = np.max(t_[power_sort_idx[-1]]) + else: # take t_high and t_low from plotted signals + a = [np.min(t_[idx]) for idx in power_sort_idx[-N_plot:]] + axs.plot(a, [0]*N_plot, 'gx', ms=10) + t_low = np.nanmin(a) + b = [np.max(t_[idx]) for idx in power_sort_idx[-N_plot:]] + axs.plot(b, [0]*N_plot, 'b+', ms=10) + t_high = np.nanmax(b) + + center_x = (t_high - t_low)/2 + t_low + wx = 200 + + low_xlim = max(orig_xlims[0], center_x - wx) + high_xlim = min(orig_xlims[1], center_x + wx) + + axs.set_xlim(low_xlim, high_xlim) + fig.savefig(path.join(fig_dir, path.basename(__file__) + f'.trace_overlap.zoomed.{case}.pdf')) + fig.savefig(path.join(fig_dir, path.basename(__file__) + f'.trace_overlap.zoomed.{case}.png'), transparent=True) + + + if True: + continue + # Measure power on grid for scalename, scale in scales.items(): wx, wy = scale, scale @@ -223,3 +253,7 @@ if __name__ == "__main__": if fig_dir: fig.tight_layout() fig.savefig(path.join(fig_dir, path.basename(__file__) + f'.X{X}.{case}.{scalename}.pdf')) + + if args.show_plots: + plt.show() +