Pulse: show residuals in SNR vs accuracy plot: WIP

This commit is contained in:
Eric Teunis de Boone 2023-05-17 20:23:03 +02:00
parent cc4b545260
commit c8ac1fa50e

View file

@ -506,9 +506,11 @@ if __name__ == "__main__":
# #
# Find time accuracies as a function of signal strength # Find time accuracies as a function of signal strength
# #
time_accuracies = np.zeros((len(template_dts), len(snr_factors))) time_residuals_data = []
mask_counts = np.zeros_like(time_accuracies)
for l, template_dt in tqdm(enumerate(template_dts)): for a, template_dt in tqdm(enumerate(template_dts)):
time_residuals_data.append(np.zeros( (len(snr_factors), 3, N_residuals)))# res, snr, masked
# Create the template # Create the template
# This is sampled at a lower samplerate than the interpolation template # This is sampled at a lower samplerate than the interpolation template
@ -526,26 +528,29 @@ if __name__ == "__main__":
print()# separating tqdm print()# separating tqdm
print()# separating tqdm print()# separating tqdm
# Make a plot of the time residuals wrong_peak_condition = lambda t_res: abs(t_res) > antenna_dt*4
if N_residuals > 1: mask = wrong_peak_condition(time_residuals)
# Save directly to large data array
time_residuals_data[a][k] = time_residuals, snrs, ~mask
# Make a plot of the time residuals <<<
if True and N_residuals > 1:
for i in range(1 + cut_wrong_peak_matches): for i in range(1 + cut_wrong_peak_matches):
mask_count = 0 mask_count = 0
if i==1: # if cut_wrong_peak_matches: if i==1: # if cut_wrong_peak_matches:
wrong_peak_condition = lambda t_res: abs(t_res) > antenna_dt*4
mask = wrong_peak_condition(time_residuals)
mask_count = np.count_nonzero(mask) mask_count = np.count_nonzero(mask)
print("Masking {} residuals".format(mask_count))
time_residuals = time_residuals[~mask] time_residuals = time_residuals[~mask]
# None masked
if not mask_count: if not mask_count:
continue continue
time_accuracies[l, k] = np.std(time_residuals) # All masked
mask_counts[l, k] = mask_count if not len(time_residuals):
continue
hist_kwargs = dict(bins='sqrt', density=False, alpha=0.8, histtype='step') hist_kwargs = dict(bins='sqrt', density=False, alpha=0.8, histtype='step')
fig, ax = plt.subplots() fig, ax = plt.subplots()
@ -614,8 +619,11 @@ if __name__ == "__main__":
if True: if True:
plt.close(fig) plt.close(fig)
# >>> End of plot
#
# SNR time accuracy plot # SNR time accuracy plot
#
if True: if True:
threshold_markers = ['^', 'v', '8', 'o'] threshold_markers = ['^', 'v', '8', 'o']
mask_thresholds = [np.inf, N_residuals*0.5, N_residuals*0.1, 1, 0] mask_thresholds = [np.inf, N_residuals*0.5, N_residuals*0.1, 1, 0]