ZH: findks: let function determine shifts irrespective of sampling

This commit is contained in:
Eric Teunis de Boone 2023-04-28 16:37:35 +02:00
parent 581b83ac5b
commit 9f610ab2e7

View file

@ -20,7 +20,7 @@ import aa_generate_beacon as beacon
import lib import lib
from lib import rit from lib import rit
def find_best_sample_shifts_summing_at_location(test_loc, antennas, allowed_sample_shifts, dt=None, sample_shift_first_trace=0, plot_iteration_with_shifted_trace=None, fig_dir=None, fig_distinguish=None): def find_best_period_shifts_summing_at_location(test_loc, antennas, allowed_ks, period=1, dt=None, period_shift_first_trace=0, plot_iteration_with_shifted_trace=None, fig_dir=None, fig_distinguish=None):
""" """
Find the best sample_shift for each antenna by summing the antenna traces Find the best sample_shift for each antenna by summing the antenna traces
and seeing how to get the best alignment. and seeing how to get the best alignment.
@ -41,6 +41,9 @@ def find_best_sample_shifts_summing_at_location(test_loc, antennas, allowed_samp
else: else:
plot_iteration_with_shifted_trace = [] plot_iteration_with_shifted_trace = []
allowed_sample_shifts = np.rint(allowed_ks * period /dt).astype(int)
sample_shift_first_trace = np.rint(period_shift_first_trace * period/dt).astype(int)
# propagate to test location # propagate to test location
for i, ant in enumerate(antennas): for i, ant in enumerate(antennas):
aloc = [ant.x, ant.y, ant.z] aloc = [ant.x, ant.y, ant.z]
@ -338,8 +341,7 @@ if __name__ == "__main__":
# determine allowable ks per location # determine allowable ks per location
dt = ev.antennas[0].t_AxB[1] - ev.antennas[0].t_AxB[0] dt = ev.antennas[0].t_AxB[1] - ev.antennas[0].t_AxB[0]
allowed_sample_shifts = np.rint(allowed_ks/f_beacon /dt).astype(int) print("Checking k:", allowed_ks)
print("Checking:", allowed_ks, ": shifts :", allowed_sample_shifts)
## ##
## Determine grid positions ## Determine grid positions
@ -411,7 +413,9 @@ if __name__ == "__main__":
yy.append(y_+yoff) yy.append(y_+yoff)
# Find best k for each antenna # Find best k for each antenna
shifts, maximum = find_best_sample_shifts_summing_at_location(test_loc, ev.antennas, allowed_sample_shifts, dt=dt, fig_dir=tmp_fig_subdir, plot_iteration_with_shifted_trace=[ 5, len(ev.antennas)-1], fig_distinguish=f"run{r}.") shifts, maximum = find_best_period_shifts_summing_at_location(test_loc, ev.antennas, allowed_ks, period=1/f_beacon, dt=dt,
plot_iteration_with_shifted_trace=[ 5, len(ev.antennas)-1],
fig_dir=tmp_fig_subdir, fig_distinguish=f"run{r}.")
# Translate sample shifts back into period multiple k # Translate sample shifts back into period multiple k
ks = np.rint(shifts*f_beacon*dt) ks = np.rint(shifts*f_beacon*dt)