ZH: nicefy some output + CLI

This commit is contained in:
Eric Teunis de Boone 2022-11-25 17:46:02 +01:00
parent c567d5190b
commit 6c0ae17b07
4 changed files with 9 additions and 10 deletions

View file

@ -22,7 +22,7 @@ if __name__ == "__main__":
allow_frequency_fitting = False
read_frequency_from_file = True
use_AxB_trace = True
use_AxB_trace = True if len(sys.argv) < 2 else bool(int(sys.argv[1]))
use_beacon_trace = True # only applicable if AxB = False
show_plots = True

View file

@ -28,7 +28,7 @@ def antenna_true_phases(tx, antennas, freq_name, c_light=3e8):
geom_time = lib.geometry_time(tx, ant, c_light=c_light)
geom_phase = geom_time * 2*np.pi*f_beacon
true_phases[i] = lib.phase_mod(lib.phase_mod(measured_phase) - lib.phase_mod(geom_phase))
true_phases[i] = lib.phase_mod( lib.phase_mod(geom_phase) - lib.phase_mod(measured_phase))
return true_phases
@ -67,7 +67,7 @@ if __name__ == "__main__":
# Remove the phase from one antenna
# this is a free parameter
# (only required for absolute timing)
if False:
if True:
if True: # just take the first phase
minimum_phase = -1*true_phases[0]
else: # take the minimum

View file

@ -87,7 +87,6 @@ if __name__ == "__main__":
# Plotting for one or two iterations
if show_plots and (i in [ 1, 57 ] or k_period > 3):
# More than three periods is quite much so report it
print('i',i,'k[T]',k_period, 'rest[ns]',t_rest, 'T[ns]',1/f_beacon, 'dT_coher[ns]', delta_t_coherence)
# Show correlation maxima plot
if not True:
@ -122,6 +121,8 @@ if __name__ == "__main__":
if beacons is None:
axs = [axs]
print('i',i,f"B({base[0].name},{base[1].name})", 'k[T]',k_period, 'rest[ns]',t_rest, 'T[ns]',1/f_beacon, 'dT_coher[ns]', delta_t_coherence, 'dT_beac[ns]', delta_t_beacon)
fig.suptitle(
", ".join([
f"$\\Delta$t_beacon [ns]: {delta_t_beacon:.2f}",
@ -146,7 +147,7 @@ if __name__ == "__main__":
l1 = axs[0].plot(base[0].t, traces[0], label=f'Ref: {base[0].name}', alpha=0.8)
l2 = axs[0].plot(base[1].t, traces[1], label=f'Orig: {base[1].name}', alpha=0.3, marker='+', ms=5)
axs[0].plot(base[0].t + k_period/f_beacon + t_rest, traces[1], label='Coherence', alpha=0.3, marker='x', ms=5)
l3 = axs[0].plot(base[1].t - delta_t_beacon +k_period/f_beacon, traces[1], label=f'$\\Delta t_{{\\sigma\\varphi}}$ + ($k={k_period:.0f}$)T', alpha=0.8)
l3 = axs[0].plot(base[1].t - delta_t_beacon +k_period/f_beacon, traces[1], label=f'$\\Delta t_{{\\varphi}}$ + ($k={k_period:.0f}$)T', alpha=0.8)
axs[0].legend(fancybox=True, framealpha=0.5)
@ -156,7 +157,7 @@ if __name__ == "__main__":
ax.set_title("Original Beacons")
ax.plot(base[0].t, beacons[0], label=f'Ref: {base[0].name}', alpha=0.8, color=l1[0].get_color())
ax.plot(base[1].t, beacons[1], label=f'Orig: {base[1].name}', alpha=0.3, marker='+', ms=5, color=l2[0].get_color())
ax.plot(base[1].t -delta_t_beacon +k_period/f_beacon, beacons[1], label=f'$\\Delta t_{{\\sigma\\varphi}}$ + ($k={k_period:.0f}$)T', alpha=0.8, color=l3[0].get_color())
ax.plot(base[1].t -delta_t_beacon +k_period/f_beacon, beacons[1], label=f'$\\Delta t_{{\\varphi}}$ + ($k={k_period:.0f}$)T', alpha=0.8, color=l3[0].get_color())
if False:
if False:

View file

@ -22,8 +22,9 @@ if __name__ == "__main__":
####
fname_dir = path.dirname(fname)
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
time_diffs_fname = antennas_fname
basenames, time_diffs, f_beacon, true_phase_diffs, k_periods = beacon.read_baseline_time_diffs_hdf5(antennas_fname)
basenames, time_diffs, f_beacon, true_phase_diffs, k_periods = beacon.read_baseline_time_diffs_hdf5(time_diffs_fname)
f_beacon, tx, antennas = beacon.read_beacon_hdf5(antennas_fname)
@ -53,6 +54,3 @@ if __name__ == "__main__":
ax.legend()
plt.show()