ZH: total time_diffs saved to file

This commit is contained in:
Eric-Teunis de Boone 2022-11-24 14:47:29 +01:00
parent 0ffdee4496
commit 8da9d55c56
3 changed files with 60 additions and 34 deletions

View file

@ -200,16 +200,26 @@ def find_beacon_in_traces(
return frequencies, phases, amplitudes
def coherence_sum_maxima(ref_x, y, k_step=1):
def coherence_sum_maxima(ref_x, y, k_step=1, k_start=0, k_end=None, periodic=True):
"""
Use the maximum of a coherent sum to determine
the best number of samples to move
"""
max_k = int( len(ref_x) )
ks = np.arange(0, max_k, step=k_step)
N_samples = int( len(ref_x) )
k_end = N_samples if k_end is None or k_end > max_k else k_end
ks = np.arange(k_start, k_end, step=k_step)
maxima = np.empty(len(ks))
if periodic is False:
# prepend zeros
N_zeros = N_samples
preshift = 0 # only required for testing purposes
ref_x = np.pad(ref_x, (N_zeros-0,0), 'constant')
y = np.pad(y, (N_zeros-preshift,preshift), 'constant')
for i,k in enumerate(ks, 0):
augmented_y = np.roll(y, k)
maxima[i] = max(ref_x + augmented_y)