mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-13 01:53:31 +01:00
ZH: rename ant_group variables to h5ant
To better distinghuish whether this is an Antenna or a H5Group.
This commit is contained in:
parent
e57403e765
commit
dd9630f346
3 changed files with 37 additions and 32 deletions
|
@ -115,25 +115,25 @@ def append_antenna_hdf5(fname, antenna, columns = [], name='traces', prepend_tim
|
|||
if antenna.name in group:
|
||||
if not overwrite:
|
||||
raise NotImplementedError
|
||||
ant_group = group[antenna.name]
|
||||
h5ant = group[antenna.name]
|
||||
else:
|
||||
ant_group = group.create_group(antenna.name)
|
||||
h5ant = group.create_group(antenna.name)
|
||||
|
||||
ant_attrs = ant_group.attrs
|
||||
ant_attrs['x'] = antenna.x
|
||||
ant_attrs['y'] = antenna.y
|
||||
ant_attrs['z'] = antenna.z
|
||||
ant_attrs['name'] = antenna.name
|
||||
h5ant_attrs = h5ant.attrs
|
||||
h5ant_attrs['x'] = antenna.x
|
||||
h5ant_attrs['y'] = antenna.y
|
||||
h5ant_attrs['z'] = antenna.z
|
||||
h5ant_attrs['name'] = antenna.name
|
||||
|
||||
for k,v in attrs_dict.items():
|
||||
ant_attrs[k] = v
|
||||
h5ant_attrs[k] = v
|
||||
|
||||
if name in ant_group:
|
||||
if name in h5ant:
|
||||
if not overwrite:
|
||||
raise NotImplementedError
|
||||
del ant_group[name]
|
||||
del h5ant[name]
|
||||
|
||||
dset = ant_group.create_dataset(name, (len(columns) + 1*prepend_time, len(columns[0])), dtype='f')
|
||||
dset = h5ant.create_dataset(name, (len(columns) + 1*prepend_time, len(columns[0])), dtype='f')
|
||||
|
||||
if prepend_time:
|
||||
dset[0] = antenna.t
|
||||
|
|
|
@ -13,11 +13,11 @@ import os.path as path
|
|||
|
||||
from copy import deepcopy as copy
|
||||
|
||||
from earsim import REvent, Antenna
|
||||
|
||||
import aa_generate_beacon as beacon
|
||||
|
||||
import lib
|
||||
from lib.earsim import REvent, Antenna
|
||||
|
||||
|
||||
clocks_fname = 'clocks.csv'
|
||||
|
||||
|
@ -62,24 +62,24 @@ if __name__ == "__main__":
|
|||
|
||||
# modify time values of each antenna
|
||||
for i, name in enumerate(group.keys()):
|
||||
ant_group = group[name]
|
||||
h5ant = group[name]
|
||||
clk_offset = clock_offsets[i]
|
||||
|
||||
if 'traces' not in ant_group.keys():
|
||||
if 'traces' not in h5ant.keys():
|
||||
print(f"Antenna file corrupted? no 'traces' in {name}")
|
||||
sys.exit(1)
|
||||
|
||||
ant_attrs = ant_group.attrs
|
||||
if 'clock_offset' in ant_attrs:
|
||||
tmp_offset = ant_attrs['clock_offset']
|
||||
h5ant_attrs = h5ant.attrs
|
||||
if 'clock_offset' in h5ant_attrs:
|
||||
tmp_offset = h5ant_attrs['clock_offset']
|
||||
if remake_clock_offsets:
|
||||
ant_group['traces'][0, :] -= tmp_offset
|
||||
h5ant['traces'][0, :] -= tmp_offset
|
||||
else:
|
||||
clock_offsets[i] = tmp_offset
|
||||
continue
|
||||
|
||||
ant_attrs['clock_offset'] = clk_offset
|
||||
ant_group['traces'][0, :] += clk_offset
|
||||
h5ant_attrs['clock_offset'] = clk_offset
|
||||
h5ant['traces'][0, :] += clk_offset
|
||||
|
||||
# save to simple csv
|
||||
np.savetxt(clocks_fname, clock_offsets)
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
#!/usr/bin/env python3
|
||||
# vim: fdm=indent ts=4
|
||||
|
||||
"""
|
||||
Find beacon phases in antenna traces
|
||||
And save these to a file
|
||||
"""
|
||||
|
||||
import h5py
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
@ -60,15 +65,15 @@ if __name__ == "__main__":
|
|||
|
||||
# Determine frequency and phase
|
||||
for i, name in enumerate(group.keys()):
|
||||
ant_group = group[name]
|
||||
h5ant = group[name]
|
||||
|
||||
# use E_AxB only instead of polarisations
|
||||
if True:
|
||||
if 'E_AxB' not in ant_group.keys():
|
||||
if 'E_AxB' not in h5ant.keys():
|
||||
print(f"Antenna does not have 'E_AxB' in {name}")
|
||||
sys.exit(1)
|
||||
|
||||
traces = ant_group['E_AxB']
|
||||
traces = h5ant['E_AxB']
|
||||
|
||||
t_trace = traces[0]
|
||||
test_traces = [ traces[1] ]
|
||||
|
@ -76,11 +81,11 @@ if __name__ == "__main__":
|
|||
|
||||
# use separate polarisations
|
||||
else:
|
||||
if 'traces' not in ant_group.keys():
|
||||
if 'traces' not in h5ant.keys():
|
||||
print(f"Antenna file corrupted? no 'traces' in {name}")
|
||||
sys.exit(1)
|
||||
|
||||
traces = ant_group['traces']
|
||||
traces = h5ant['traces']
|
||||
t_trace = traces[0]
|
||||
|
||||
if True:
|
||||
|
@ -103,7 +108,7 @@ if __name__ == "__main__":
|
|||
else:
|
||||
# Testing
|
||||
freqs = [f_beacon]
|
||||
t0 = ant_group.attrs['t0']
|
||||
t0 = h5ant.attrs['t0']
|
||||
|
||||
phases = [ 2*np.pi*t0*f_beacon ]
|
||||
amps = [ 3e-7 ]
|
||||
|
@ -126,13 +131,13 @@ if __name__ == "__main__":
|
|||
myt = np.linspace(min(traces[0]), max(traces[0]), 10*len(traces[0]))
|
||||
ax.plot(t_trace, traces[-1], marker='.', label='trace')
|
||||
ax.plot(myt, lib.sine_beacon(frequency, myt, amplitude=amplitude, phase=phase), ls='dashed', label='simulated')
|
||||
ax.set_title(f"Beacon at antenna {ant_group}\nF:{frequency}, P:{phase}, A:{amplitude}")
|
||||
ax.set_title(f"Beacon at antenna {h5ant}\nF:{frequency}, P:{phase}, A:{amplitude}")
|
||||
ax.legend()
|
||||
|
||||
ant_group.attrs['beacon_freq'] = frequency
|
||||
ant_group.attrs['beacon_phase_measured'] = phase
|
||||
ant_group.attrs['beacon_amplitude'] = amplitude
|
||||
ant_group.attrs['beacon_orientation'] = orientation
|
||||
h5ant_group.attrs['beacon_freq'] = frequency
|
||||
h5ant_group.attrs['beacon_phase_measured'] = phase
|
||||
h5ant_group.attrs['beacon_amplitude'] = amplitude
|
||||
h5ant_group.attrs['beacon_orientation'] = orientation
|
||||
|
||||
found_data[i] = frequency, phase, amplitude
|
||||
|
||||
|
|
Loading…
Reference in a new issue