ZH: specify beacon_snr_fname

This commit is contained in:
Eric Teunis de Boone 2023-04-13 15:04:45 +02:00
parent 8dc2d3b7f0
commit aabdca4f98
10 changed files with 27 additions and 27 deletions

View file

@ -18,7 +18,7 @@ import lib
# {{{ vim marker # {{{ vim marker
tx_fname = 'tx.json' tx_fname = 'tx.json'
antennas_fname = 'antennas.hdf5' antennas_fname = 'antennas.hdf5'
snr_fname = 'snr.json' beacon_snr_fname = 'snr.json'
c_light = lib.c_light c_light = lib.c_light
def read_antenna_clock_repair_offsets(antennas, mode='all', freq_name=None): def read_antenna_clock_repair_offsets(antennas, mode='all', freq_name=None):

View file

@ -42,7 +42,7 @@ if __name__ == "__main__":
fname_dir = args.data_dir fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname) antennas_fname = path.join(fname_dir, beacon.antennas_fname)
tx_fname = path.join(fname_dir, beacon.tx_fname) tx_fname = path.join(fname_dir, beacon.tx_fname)
snr_fname = path.join(fname_dir, beacon.snr_fname) beacon_snr_fname = path.join(fname_dir, beacon.beacon_snr_fname)
# create fig_dir # create fig_dir
if fig_dir: if fig_dir:
@ -96,7 +96,7 @@ if __name__ == "__main__":
beacon_snrs = [ lib.signal_to_noise(myfilter(beacon_amp*ant.beacon), myfilter(ant.noise), samplerate=1/dt, signal_band=beacon_pb, noise_band=noise_pb) for i, ant in enumerate(antennas) ] beacon_snrs = [ lib.signal_to_noise(myfilter(beacon_amp*ant.beacon), myfilter(ant.noise), samplerate=1/dt, signal_band=beacon_pb, noise_band=noise_pb) for i, ant in enumerate(antennas) ]
# write mean and std to file # write mean and std to file
beacon.write_snr_file(snr_fname, beacon_snrs) beacon.write_snr_file(beacon_snr_fname, beacon_snrs)
fig, ax = plt.subplots(figsize=figsize) fig, ax = plt.subplots(figsize=figsize)
ax.set_title(f"Maximum Beacon/Noise SNR (N_samples:{N_samples:.1e})") ax.set_title(f"Maximum Beacon/Noise SNR (N_samples:{N_samples:.1e})")

View file

@ -51,7 +51,7 @@ if __name__ == "__main__":
#### ####
fname_dir = args.data_dir fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname) antennas_fname = path.join(fname_dir, beacon.antennas_fname)
snr_fname = path.join(fname_dir, beacon.snr_fname) beacon_snr_fname = path.join(fname_dir, beacon.beacon_snr_fname)
fig_dir = args.fig_dir # set None to disable saving fig_dir = args.fig_dir # set None to disable saving
@ -59,8 +59,8 @@ if __name__ == "__main__":
print("Antenna file cannot be found, did you try generating a beacon?") print("Antenna file cannot be found, did you try generating a beacon?")
sys.exit(1) sys.exit(1)
snrs = beacon.read_snr_file(snr_fname) beacon_snrs = beacon.read_snr_file(beacon_snr_fname)
snr_str = f"$\\langle SNR \\rangle$ = {snrs['mean']: .1e}" snr_str = f"$\\langle SNR \\rangle$ = {beacon_snrs['mean']: .1e}"
# read in antennas # read in antennas
with h5py.File(antennas_fname, 'a') as fp: with h5py.File(antennas_fname, 'a') as fp:

View file

@ -33,7 +33,7 @@ if __name__ == "__main__":
#### ####
fname_dir = args.data_dir fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname) antennas_fname = path.join(fname_dir, beacon.antennas_fname)
snr_fname = path.join(fname_dir, beacon.snr_fname) beacon_snr_fname = path.join(fname_dir, beacon.beacon_snr_fname)
fig_dir = args.fig_dir # set None to disable saving fig_dir = args.fig_dir # set None to disable saving
@ -157,8 +157,8 @@ if __name__ == "__main__":
## ##
## Histogram ## Histogram
## ##
snrs = beacon.read_snr_file(snr_fname) beacon_snrs = beacon.read_snr_file(beacon_snr_fname)
snr_str = f"$\\langle SNR \\rangle$ = {snrs['mean']: .1e}" snr_str = f"$\\langle SNR \\rangle$ = {beacon_snrs['mean']: .1e}"
fig = figlib.phase_comparison_figure( fig = figlib.phase_comparison_figure(
loc_c, loc_c,

View file

@ -34,7 +34,7 @@ if __name__ == "__main__":
fname_dir = args.data_dir fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname) antennas_fname = path.join(fname_dir, beacon.antennas_fname)
time_diffs_fname = 'time_diffs.hdf5' if False else antennas_fname time_diffs_fname = 'time_diffs.hdf5' if False else antennas_fname
snr_fname = path.join(fname_dir, beacon.snr_fname) beacon_snr_fname = path.join(fname_dir, beacon.beacon_snr_fname)
fig_dir = args.fig_dir # set None to disable saving fig_dir = args.fig_dir # set None to disable saving
@ -93,8 +93,8 @@ if __name__ == "__main__":
############################## ##############################
# Compare actual time shifts # # Compare actual time shifts #
############################## ##############################
snrs = beacon.read_snr_file(snr_fname) beacon_snrs = beacon.read_snr_file(beacon_snr_fname)
snr_str = f"$\\langle SNR \\rangle$ = {snrs['mean']: .1e}" snr_str = f"$\\langle SNR \\rangle$ = {beacon_snrs['mean']: .1e}"
actual_antenna_clock_phases = { a.name: -2*np.pi*a.attrs['clock_offset']*f_beacon for a in sorted(antennas, key=lambda a: int(a.name)) } actual_antenna_clock_phases = { a.name: -2*np.pi*a.attrs['clock_offset']*f_beacon for a in sorted(antennas, key=lambda a: int(a.name)) }

View file

@ -37,7 +37,7 @@ if __name__ == "__main__":
antennas_fname = path.join(fname_dir, beacon.antennas_fname) antennas_fname = path.join(fname_dir, beacon.antennas_fname)
time_diffs_fname = 'time_diffs.hdf5' if False else antennas_fname time_diffs_fname = 'time_diffs.hdf5' if False else antennas_fname
fig_dir = args.fig_dir # set None to disable saving fig_dir = args.fig_dir # set None to disable saving
snr_fname = path.join(fname_dir, beacon.snr_fname) beacon_snr_fname = path.join(fname_dir, beacon.beacon_snr_fname)
basenames, time_diffs, f_beacons, clock_phase_diffs, k_periods = beacon.read_baseline_time_diffs_hdf5(time_diffs_fname) basenames, time_diffs, f_beacons, clock_phase_diffs, k_periods = beacon.read_baseline_time_diffs_hdf5(time_diffs_fname)
@ -175,8 +175,8 @@ if __name__ == "__main__":
############################## ##############################
# Compare actual time shifts # # Compare actual time shifts #
############################## ##############################
snrs = beacon.read_snr_file(snr_fname) beacon_snrs = beacon.read_snr_file(beacon_snr_fname)
snr_str = f"$\\langle SNR \\rangle$ = {snrs['mean']: .1e}" snr_str = f"$\\langle SNR \\rangle$ = {beacon_snrs['mean']: .1e}"
actual_antenna_time_shifts = { a.name: a.attrs['clock_offset'] for a in sorted(antennas, key=lambda a: int(a.name)) } actual_antenna_time_shifts = { a.name: a.attrs['clock_offset'] for a in sorted(antennas, key=lambda a: int(a.name)) }

View file

@ -190,7 +190,7 @@ if __name__ == "__main__":
antennas_fname = path.join(fname_dir, beacon.antennas_fname) antennas_fname = path.join(fname_dir, beacon.antennas_fname)
time_diffs_fname = 'time_diffs.hdf5' if not True else antennas_fname time_diffs_fname = 'time_diffs.hdf5' if not True else antennas_fname
tx_fname = path.join(fname_dir, beacon.tx_fname) tx_fname = path.join(fname_dir, beacon.tx_fname)
snr_fname = path.join(fname_dir, beacon.snr_fname) beacon_snr_fname = path.join(fname_dir, beacon.beacon_snr_fname)
## This is a file indicating whether the k-finding algorithm was ## This is a file indicating whether the k-finding algorithm was
## stopped early. This happens when the ks do not change between ## stopped early. This happens when the ks do not change between
@ -211,8 +211,8 @@ if __name__ == "__main__":
# .. patch in our antennas # .. patch in our antennas
ev.antennas = antennas ev.antennas = antennas
# read in snr information # read in snr information
snrs = beacon.read_snr_file(snr_fname) beacon_snrs = beacon.read_snr_file(beacon_snr_fname)
snr_str = f"$\\langle SNR \\rangle$ = {snrs['mean']: .1e}" snr_str = f"$\\langle SNR \\rangle$ = {beacon_snrs['mean']: .1e}"
# For now only implement using one freq_name # For now only implement using one freq_name
freq_names = antennas[0].beacon_info.keys() freq_names = antennas[0].beacon_info.keys()

View file

@ -32,7 +32,7 @@ if __name__ == "__main__":
fname_dir = args.data_dir fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname) antennas_fname = path.join(fname_dir, beacon.antennas_fname)
time_diffs_fname = 'time_diffs.hdf5' if not True else antennas_fname time_diffs_fname = 'time_diffs.hdf5' if not True else antennas_fname
snr_fname = path.join(fname_dir, beacon.snr_fname) beacon_snr_fname = path.join(fname_dir, beacon.beacon_snr_fname)
# create fig_dir # create fig_dir
if fig_dir: if fig_dir:
@ -42,8 +42,8 @@ if __name__ == "__main__":
_, tx, antennas = beacon.read_beacon_hdf5(antennas_fname) _, tx, antennas = beacon.read_beacon_hdf5(antennas_fname)
# Read in snr info # Read in snr info
snrs = beacon.read_snr_file(snr_fname) beacon_snrs = beacon.read_snr_file(beacon_snr_fname)
snr_str = f"$\\langle SNR \\rangle$ = {snrs['mean']: .1e}" snr_str = f"$\\langle SNR \\rangle$ = {beacon_snrs['mean']: .1e}"
# For now only implement using one freq_name # For now only implement using one freq_name
freq_names = antennas[0].beacon_info.keys() freq_names = antennas[0].beacon_info.keys()

View file

@ -54,7 +54,7 @@ if __name__ == "__main__":
antennas_fname = path.join(fname_dir, beacon.antennas_fname) antennas_fname = path.join(fname_dir, beacon.antennas_fname)
pickle_fname = path.join(fname_dir, 'res.pkl') pickle_fname = path.join(fname_dir, 'res.pkl')
tx_fname = path.join(fname_dir, beacon.tx_fname) tx_fname = path.join(fname_dir, beacon.tx_fname)
snr_fname = path.join(fname_dir, beacon.snr_fname) beacon_snr_fname = path.join(fname_dir, beacon.beacon_snr_fname)
# create fig_dir # create fig_dir
if fig_dir: if fig_dir:
@ -70,8 +70,8 @@ if __name__ == "__main__":
# .. patch in our antennas # .. patch in our antennas
ev.antennas = antennas ev.antennas = antennas
# Read in snr info # Read in snr info
snrs = beacon.read_snr_file(snr_fname) beacon_snrs = beacon.read_snr_file(beacon_snr_fname)
snr_str = f"$\\langle SNR \\rangle$ = {snrs['mean']: .1e}" snr_str = f"$\\langle SNR \\rangle$ = {beacon_snrs['mean']: .1e}"
# For now only implement using one freq_name # For now only implement using one freq_name
freq_names = antennas[0].beacon_info.keys() freq_names = antennas[0].beacon_info.keys()

View file

@ -123,7 +123,7 @@ if __name__ == "__main__":
antennas_fname = path.join(fname_dir, beacon.antennas_fname) antennas_fname = path.join(fname_dir, beacon.antennas_fname)
pickle_fname = path.join(fname_dir, 'res.pkl') pickle_fname = path.join(fname_dir, 'res.pkl')
tx_fname = path.join(fname_dir, beacon.tx_fname) tx_fname = path.join(fname_dir, beacon.tx_fname)
snr_fname = path.join(fname_dir, beacon.snr_fname) beacon_snr_fname = path.join(fname_dir, beacon.beacon_snr_fname)
# create fig_dir # create fig_dir
if fig_dir: if fig_dir:
@ -138,8 +138,8 @@ if __name__ == "__main__":
# .. patch in our antennas # .. patch in our antennas
ev.antennas = antennas ev.antennas = antennas
# Read in snr info # Read in snr info
snrs = beacon.read_snr_file(snr_fname) beacon_snrs = beacon.read_snr_file(beacon_snr_fname)
snr_str = f"$\\langle SNR \\rangle$ = {snrs['mean']: .1e}" snr_str = f"$\\langle SNR \\rangle$ = {beacon_snrs['mean']: .1e}"
## ##
## Setup grid ## Setup grid