mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-12-22 03:23:34 +01:00
ZH: rewrite read_beacon_hdf5 function
This commit is contained in:
parent
006a0903ab
commit
e57403e765
1 changed files with 32 additions and 27 deletions
|
@ -42,20 +42,26 @@ def read_tx_file(fname):
|
|||
|
||||
return tx, f_beacon
|
||||
|
||||
def read_beacon_hdf5(fname, traces_key='traces', raise_exception=True, read_AxB=True):
|
||||
def read_beacon_hdf5(fname, **h5ant_kwargs):
|
||||
with h5py.File(fname, 'r') as h5:
|
||||
tx_attrs = h5['tx'].attrs
|
||||
f_beacon = tx_attrs.get('f_beacon')
|
||||
|
||||
mydict = { k:tx_attrs.get(k) for k in ['x', 'y', 'z', 'name'] }
|
||||
tx = Antenna(**mydict)
|
||||
tx = Antenna_from_h5ant(h5['tx'], traces_key=None)
|
||||
f_beacon = tx.attrs['f_beacon']
|
||||
|
||||
antennas = []
|
||||
for k, h5ant in h5['antennas'].items():
|
||||
ant = Antenna_from_h5ant(h5ant, **h5ant_kwargs)
|
||||
|
||||
antennas.append(ant)
|
||||
|
||||
return f_beacon, tx, antennas
|
||||
|
||||
def Antenna_from_h5ant(h5ant, traces_key='traces', raise_exception=True, read_AxB=True):
|
||||
mydict = { k:h5ant.attrs.get(k) for k in ['x', 'y', 'z', 'name'] }
|
||||
ant = Antenna(**mydict)
|
||||
|
||||
if traces_key not in h5ant:
|
||||
if traces_key is None:
|
||||
pass
|
||||
elif traces_key not in h5ant:
|
||||
if raise_exception:
|
||||
raise ValueError("Traces_key not in file")
|
||||
else:
|
||||
|
@ -73,9 +79,8 @@ def read_beacon_hdf5(fname, traces_key='traces', raise_exception=True, read_AxB=
|
|||
if h5ant.attrs:
|
||||
ant.attrs = {**h5ant.attrs}
|
||||
|
||||
antennas.append(ant)
|
||||
return ant
|
||||
|
||||
return f_beacon, tx, antennas
|
||||
|
||||
def init_antenna_hdf5(fname, tx = None, f_beacon = None):
|
||||
with h5py.File(fname, 'w') as fp:
|
||||
|
|
Loading…
Reference in a new issue