ZH: matrix: improve SNR vs time res plot

This commit is contained in:
Eric Teunis de Boone 2023-04-13 12:40:01 +02:00
parent 68e272a5dc
commit 8dc2d3b7f0

View file

@ -126,6 +126,7 @@ if __name__ == "__main__":
ax.set_ylabel('Time Accuracy $\\sigma(t)$ [ns]')
# group per directories per N
dirkeys = []
if True:
import re
@ -140,18 +141,23 @@ if __name__ == "__main__":
dirdict[m].append(d)
dirkeys = list(dirdict.keys())
dirlist = dirdict.values()
# plot data directories as one group
else:
dirlist = [args.data_directories]
for dirlist in dirlist:
for i, dirlist in enumerate(dirlist):
f_beacon, snrs, time_residuals = read_snr_directories(dirlist)
if dirkeys:
label = "N = " + dirkeys[i]
else:
label = None
# plot data
ax.plot(snrs*np.sqrt(np.pi/2), phase2time(time_residuals[:,1]), ls='none', marker='o')
ax.plot(snrs*np.sqrt(np.pi/2), phase2time(time_residuals[:,1]), ls='none', marker='o', label=label)
# Add secondary axis
if True:
@ -182,11 +188,11 @@ if __name__ == "__main__":
else: #linear
_snrs = np.linspace(_snr_min, _snr_max)
# Phasor Rice
# Random Phasor Sum
phasor_pdfs = np.array([phase_distribution(thetas, sigma, s) for s in _snrs ])
phasor_sigma = np.sqrt(np.array([variance(thetas, pdf) for pdf in phasor_pdfs]))
ax.plot(_snrs, phase2time(phasor_sigma), label='Rice')
ax.plot(_snrs, phase2time(phasor_sigma), label='Random Phasor Sum')
if True: # plot a pdf
fig2, ax2 = plt.subplots()
@ -207,6 +213,13 @@ if __name__ == "__main__":
if not True or ax.get_xscale() != 'log':
ax.set_xlim(0, 100)
# Set horizontal line at 1 ns
if True:
ax.axhline(1, ls='--', alpha=0.8, color='g')
if True:
ax.grid()
if args.fig_dir:
fig.tight_layout()
fig.savefig(path.join(args.fig_dir, "time_res_vs_snr.pdf"))