ZH: beacon_periods script optional plotting/saving

This commit is contained in:
Eric Teunis de Boone 2022-11-25 11:04:15 +01:00
parent 9d15a066d3
commit dd00aebe3b

View file

@ -16,11 +16,13 @@ if __name__ == "__main__":
fname = "ZH_airshower/mysim.sry"
show_plots = True
save_result = True
ref_ant_id = None # leave None for all baselines
####
fname_dir = path.dirname(fname)
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
time_diffs_fname = antennas_fname
# Read in antennas from file
f_beacon, tx, antennas = beacon.read_beacon_hdf5(antennas_fname)
@ -45,6 +47,9 @@ if __name__ == "__main__":
# and True phase differences
time_diffs = np.empty( (len(baselines), 3) )
for i, base in enumerate(baselines):
if i%50==0:
print(i, "out of", len(baselines))
# which traces to keep track of
traces = [ base[0].E_AxB, base[1].E_AxB ]
@ -102,7 +107,7 @@ if __name__ == "__main__":
delta_t_beacon = phases_diff/(2*np.pi*f_beacon)
# Do we make it shared plot with both the
# Do we make it a shared plot with both the
# signal and the beacon?
beacons = None
if True:
@ -153,16 +158,18 @@ if __name__ == "__main__":
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())
if False:
if False:
fig.savefig(__file__ + f"_i{i}_k{k_period}_zoomed_out.pdf")
ax.set_xlim(base[0].t[0]-1/f_beacon, base[0].t[0] + 5/f_beacon)
if True:
fig.savefig(__file__ + f"_i{i}_k{k_period}_zoomed_out.pdf")
ax.set_xlim(base[0].t[0]-1/f_beacon, base[0].t[0] + 5/f_beacon)
fig.savefig(__file__ + f"_i{i}_k{k_period}.pdf")
# Save integer periods to antennas
beacon.write_baseline_time_diffs_hdf5(antennas_fname, baselines, time_diffs[:,0], time_diffs[:,1], time_diffs[:,2])
fig.savefig(__file__ + f"_i{i}_k{k_period}.pdf")
# Report back to CLI
print("Period Multiples resolved and written to ", antennas_fname)
print("Period Multiples resolved from", antennas_fname)
if save_result:
# Save integer periods to antennas
beacon.write_baseline_time_diffs_hdf5(time_diffs_fname, baselines, time_diffs[:,0], time_diffs[:,1], time_diffs[:,2])
print("Timediffs saved to", time_diffs_fname)
plt.show()