mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-12-22 03:23:34 +01:00
Pulse finding for multiple SNR
This commit is contained in:
parent
81b3502de5
commit
a011aee28e
1 changed files with 241 additions and 211 deletions
|
@ -136,9 +136,9 @@ if __name__ == "__main__":
|
|||
bp_freq = (30e-3, 80e-3) # GHz
|
||||
template_dt = 5e-2 # ns
|
||||
template_length = 500 # ns
|
||||
noise_sigma_factor = 1e-1 # amplitude factor
|
||||
|
||||
N_residuals = 50*3 if len(sys.argv) < 2 else int(sys.argv[1])
|
||||
noise_factors = [1e-4, 3e-4, 1e-3, 3e-3, 1e-2, 3e-2, 1e-1, 3e-1, 5e-1, 7e-1] # amplitude factor
|
||||
|
||||
antenna_dt = 2 # ns
|
||||
antenna_timelength = 2048 # ns
|
||||
|
@ -176,6 +176,9 @@ if __name__ == "__main__":
|
|||
if True:
|
||||
plt.close(fig)
|
||||
|
||||
time_accuracies = np.zeros(len(noise_factors))
|
||||
for k, noise_sigma_factor in tqdm(enumerate(noise_factors)):
|
||||
print() #separating tqdm
|
||||
#
|
||||
# Find difference between true and templated times
|
||||
#
|
||||
|
@ -193,6 +196,8 @@ if __name__ == "__main__":
|
|||
antenna.peak_sample = antenna_peak_sample
|
||||
antenna.peak_time = antenna.dt * antenna.peak_sample
|
||||
antenna.signal = antenna_bp(antenna.signal, *bp_freq, antenna.dt)
|
||||
print(f"Antenna Peak Time: {antenna.peak_time}")
|
||||
print(f"Antenna Peak Sample: {antenna.peak_sample}")
|
||||
|
||||
else: # Sample the template at some offset
|
||||
antenna.peak_time = antenna_timelength * ((0.8 - 0.2) *rng.random(1) + 0.2)
|
||||
|
@ -204,11 +209,8 @@ if __name__ == "__main__":
|
|||
|
||||
antenna.peak_sample = antenna.peak_time/antenna.dt
|
||||
antenna_true_signal = antenna.signal
|
||||
true_time_offset = antenna.peak_time - template.peak_time
|
||||
|
||||
if do_plots:
|
||||
print(f"Antenna Peak Time: {antenna.peak_time}")
|
||||
print(f"Antenna Peak Sample: {antenna.peak_sample}")
|
||||
true_time_offset = antenna.peak_time - template.peak_time
|
||||
|
||||
if False: # flip polarisation
|
||||
antenna.signal *= -1
|
||||
|
@ -251,7 +253,7 @@ if __name__ == "__main__":
|
|||
# restore
|
||||
axs[0].set_xlim(*old_xlims)
|
||||
|
||||
if False:
|
||||
if True:
|
||||
plt.close(fig)
|
||||
|
||||
axs2 = None
|
||||
|
@ -365,11 +367,13 @@ if __name__ == "__main__":
|
|||
fig.tight_layout()
|
||||
fig.savefig('figures/11_corrs.pdf')
|
||||
|
||||
if False:
|
||||
if True:
|
||||
plt.close(fig)
|
||||
|
||||
print()# separating tqdm
|
||||
# Make a plot of the time residuals
|
||||
if len(time_residuals) > 1:
|
||||
time_accuracies[k] = np.std(time_residuals)
|
||||
|
||||
hist_kwargs = dict(bins='sqrt', density=False, alpha=0.8, histtype='step')
|
||||
fig, ax = plt.subplots()
|
||||
|
@ -424,6 +428,32 @@ if __name__ == "__main__":
|
|||
|
||||
ax.text( *(0.02, 0.95), text_str, fontsize=12, ha='left', va='top', transform=ax.transAxes)
|
||||
|
||||
fig.savefig("figures/11_time_residual_hist.pdf")
|
||||
fig.savefig("figures/11_time_residual_hist_{noise_sigma_factor: .1e}.pdf")
|
||||
|
||||
if True:
|
||||
plt.close(fig)
|
||||
|
||||
# SNR time accuracy plot
|
||||
if True:
|
||||
fig, ax = plt.subplots()
|
||||
ax.set_title("Template matching SNR vs time accuracy")
|
||||
ax.set_xlabel("Signal to Noise Factor")
|
||||
ax.set_ylabel("Time Accuracy [ns]")
|
||||
|
||||
if True:
|
||||
ax.set_xscale('log')
|
||||
ax.set_yscale('log')
|
||||
|
||||
# plot the values
|
||||
ax.plot(1/np.asarray(noise_factors), time_accuracies, ls='none', marker='o')
|
||||
|
||||
|
||||
# Set horizontal line at 1 ns
|
||||
if True:
|
||||
ax.axhline(1, ls='--', alpha=0.8, color='g')
|
||||
ax.grid()
|
||||
|
||||
fig.tight_layout()
|
||||
fig.savefig("figures/11_time_res_vs_snr.pdf")
|
||||
|
||||
plt.show()
|
||||
|
|
Loading…
Reference in a new issue