diff --git a/airshower_beacon_simulation/dc_grid_power_time_fixes.py b/airshower_beacon_simulation/dc_grid_power_time_fixes.py index 57af6af..49066ec 100755 --- a/airshower_beacon_simulation/dc_grid_power_time_fixes.py +++ b/airshower_beacon_simulation/dc_grid_power_time_fixes.py @@ -18,7 +18,6 @@ import aa_generate_beacon as beacon import lib from lib import rit - def save_overlapping_traces_figure(test_location, ev, N_plot = 30, wx=200, title_extra=None, fname_distinguish='', fig_dir=None, **fig_kwargs): P, t_, a_, a_sum, t_sum = rit.pow_and_time(test_location, ev, dt=1) @@ -28,7 +27,8 @@ def save_overlapping_traces_figure(test_location, ev, N_plot = 30, wx=200, title axs.set_ylabel("Amplitude [$\\mu V/m$]") if True: text_loc = (0.02, 0.95) - axs.text(*text_loc, '[' + ', '.join(['{:.1g}'.format(x) for x in test_location]) + ']', ha='left', transform=axs.transAxes) + shower_plane_location = rit.location_to_shower_plane(test_location, ev=ev) + axs.text(*text_loc, '[' + ', '.join(['{:.1g}'.format(x) for x in shower_plane_location]) + ']', ha='left', transform=axs.transAxes) a_max = [ np.amax(ant.E_AxB) for ant in ev.antennas ] power_sort_idx = np.argsort(a_max) diff --git a/airshower_beacon_simulation/lib/rit.py b/airshower_beacon_simulation/lib/rit.py index db0ae45..821a4ef 100644 --- a/airshower_beacon_simulation/lib/rit.py +++ b/airshower_beacon_simulation/lib/rit.py @@ -22,6 +22,32 @@ atm = AtmoCal() from matplotlib import cm +def location_to_shower_plane(loc, u=None, ev=None): + if ev is not None: + uAxB = ev.uAxB + uAxAxB = ev.uAxAxB + uA = ev.uA + else: + uAxB, uAxAxB, uA = u + + return np.dot(loc, uAxB), np.dot(loc, uAxAxB), np.dot(loc, uA) + +def shower_plane_to_location( x, dXref=0, u=None, ev=None): + if len(x) == 2: + x, y = x + else: + x, y, dXref = x + + if ev is not None: + uAxB = ev.uAxB + uAxAxB = ev.uAxAxB + uA = ev.uA + else: + uAxB, uAxAxB, uA = u + + return x * uAxB + y * uAxAxB + dXref * uA + + def set_pol_and_bp(e,low=0.03,high=0.08): for ant in e.antennas: E = [np.dot(e.uAxB,[ex,ey,ez]) for ex,ey,ez in zip(ant.Ex,ant.Ey,ant.Ez)]