mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-12-22 11:33:32 +01:00
ZH: fixup to a478a27
snr file
This commit is contained in:
parent
0c9599973d
commit
a22f57093b
2 changed files with 15 additions and 3 deletions
|
@ -18,6 +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'
|
||||||
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):
|
||||||
|
@ -49,6 +50,17 @@ def read_antenna_clock_repair_offsets(antennas, mode='all', freq_name=None):
|
||||||
|
|
||||||
return time_offsets
|
return time_offsets
|
||||||
|
|
||||||
|
def write_snr_file(fname, snrs):
|
||||||
|
with open(fname, 'w') as fp:
|
||||||
|
return json.dump(
|
||||||
|
{'mean': np.mean(snrs), 'std': np.std(snrs), 'values': snrs},
|
||||||
|
fp
|
||||||
|
)
|
||||||
|
|
||||||
|
def read_snr_file(fname):
|
||||||
|
with open(fname, 'r') as fp:
|
||||||
|
return json.load(fp)
|
||||||
|
|
||||||
def write_tx_file(fname, tx, f_beacon, **kwargs):
|
def write_tx_file(fname, tx, f_beacon, **kwargs):
|
||||||
with open(fname, 'w') as fp:
|
with open(fname, 'w') as fp:
|
||||||
return json.dump(
|
return json.dump(
|
||||||
|
|
|
@ -42,6 +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)
|
||||||
|
|
||||||
# create fig_dir
|
# create fig_dir
|
||||||
if fig_dir:
|
if fig_dir:
|
||||||
|
@ -92,9 +93,8 @@ if __name__ == "__main__":
|
||||||
N_samples = len(antennas[0].beacon)
|
N_samples = len(antennas[0].beacon)
|
||||||
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) ]
|
||||||
|
|
||||||
with open(path.join(fname_dir, 'snr.txt'), 'w') as f:
|
# write mean and std to file
|
||||||
f.write('mean='+str(np.mean(beacon_snrs))+'\n')
|
beacon.write_snr_file(snr_fname, beacon_snrs)
|
||||||
f.write('std='+str(np.std(beacon_snrs))+'\n')
|
|
||||||
|
|
||||||
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})")
|
||||||
|
|
Loading…
Reference in a new issue