mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-13 01:53:31 +01:00
ZH: rename beacon_phase to beacon_phase_measured
Also reorganises lib.py slightly
This commit is contained in:
parent
6523128871
commit
1e6c6ad4fd
5 changed files with 29 additions and 19 deletions
|
@ -9,6 +9,12 @@ beacon:
|
|||
clocks:
|
||||
./ab_modify_clocks.py
|
||||
|
||||
phases:
|
||||
./ba_beacon_phases.py
|
||||
|
||||
period_multiples:
|
||||
./bb_beacon_multiples.py
|
||||
|
||||
dist-clean:
|
||||
rm -f ZH_airshower/antennas.hdf5
|
||||
rm -f ZH_airshower/clocks.csv
|
||||
|
|
|
@ -42,7 +42,7 @@ def read_tx_file(fname):
|
|||
|
||||
return tx, f_beacon
|
||||
|
||||
def read_beacon_hdf5(fname, traces_key='traces'):
|
||||
def read_beacon_hdf5(fname, traces_key='traces', raise_exception=True):
|
||||
with h5py.File(fname, 'r') as h5:
|
||||
tx_attrs = h5['tx'].attrs
|
||||
f_beacon = tx_attrs.get('f_beacon')
|
||||
|
@ -54,12 +54,17 @@ def read_beacon_hdf5(fname, traces_key='traces'):
|
|||
for k, ant in h5['antennas'].items():
|
||||
mydict = { k:ant.attrs.get(k) for k in ['x', 'y', 'z', 'name'] }
|
||||
antenna = Antenna(**mydict)
|
||||
antenna.t = ant[traces_key][0]
|
||||
antenna.Ex = ant[traces_key][1]
|
||||
antenna.Ey = ant[traces_key][2]
|
||||
antenna.Ez = ant[traces_key][3]
|
||||
if len(ant[traces_key]) > 4:
|
||||
antenna.beacon = ant[traces_key][4]
|
||||
|
||||
if traces_key not in ant:
|
||||
if raise_exception:
|
||||
raise ValueError("Traces_key not in file")
|
||||
else:
|
||||
antenna.t = ant[traces_key][0]
|
||||
antenna.Ex = ant[traces_key][1]
|
||||
antenna.Ey = ant[traces_key][2]
|
||||
antenna.Ez = ant[traces_key][3]
|
||||
if len(ant[traces_key]) > 4:
|
||||
antenna.beacon = ant[traces_key][4]
|
||||
|
||||
if ant.attrs:
|
||||
antenna.attrs = {**ant.attrs}
|
||||
|
|
|
@ -71,7 +71,7 @@ if __name__ == "__main__":
|
|||
|
||||
if not True:
|
||||
# only take the Beacon trace
|
||||
test_traces = traces[4]
|
||||
test_traces = [traces[4]]
|
||||
orients = ['B']
|
||||
else:
|
||||
test_traces = traces[1:]
|
||||
|
@ -112,7 +112,7 @@ if __name__ == "__main__":
|
|||
ax.legend()
|
||||
|
||||
ant_group.attrs['beacon_freq'] = frequency
|
||||
ant_group.attrs['beacon_phase'] = phase
|
||||
ant_group.attrs['beacon_phase_measured'] = phase
|
||||
ant_group.attrs['beacon_amplitude'] = amplitude
|
||||
ant_group.attrs['beacon_orientation'] = orientation
|
||||
|
||||
|
|
|
@ -7,12 +7,19 @@ from numpy.polynomial import Polynomial
|
|||
|
||||
from earsim import Antenna
|
||||
|
||||
""" Beacon utils """
|
||||
def sine_beacon(f, t, t0=0, amplitude=1, baseline=0, phase=0):
|
||||
"""
|
||||
Return a sine appropriate as a beacon
|
||||
"""
|
||||
return amplitude * np.sin(2*np.pi*f*(t+t0) + phase) + baseline
|
||||
|
||||
def phase_mod(phase, low=np.pi):
|
||||
"""
|
||||
Modulo phase such that it falls within the
|
||||
interval $[-low, 2\pi - low)$.
|
||||
"""
|
||||
return (phase + low) % (2*np.pi) - low
|
||||
|
||||
def distance(x1, x2):
|
||||
"""
|
||||
|
@ -38,7 +45,7 @@ def beacon_from(tx, rx, f, t=0, t0=0, c_light=3e8, radiate_rsq=True, amplitude=1
|
|||
|
||||
return sine_beacon(f, t, t0=t0, amplitude=amplitude,**kwargs)
|
||||
|
||||
|
||||
""" Fourier """
|
||||
def ft_corr_vectors(freqs, time):
|
||||
"""
|
||||
Get the cosine and sine terms for freqs at time.
|
||||
|
@ -94,14 +101,6 @@ def phase_field_from_tx(x, y, tx, f_beacon, c_light=3e8, t0=0, wrap_phase=True,
|
|||
return phase, (np.repeat(xs, len(ys), axis=0), np.repeat(ys, len(xs[0]), axis=1))
|
||||
|
||||
|
||||
def phase_mod(phase, low=np.pi):
|
||||
"""
|
||||
Modulo phase such that it falls within the
|
||||
interval $[-low, 2\pi - low)$.
|
||||
"""
|
||||
return (phase + low) % (2*np.pi) - low
|
||||
|
||||
|
||||
def find_beacon_in_traces(
|
||||
traces,
|
||||
t_trace,
|
||||
|
|
|
@ -28,7 +28,7 @@ if __name__ == "__main__":
|
|||
if True:
|
||||
beacon_frequencies = np.array([ant.attrs['beacon_freq'] for ant in antennas])
|
||||
beacon_amplitudes = np.array([ant.attrs['beacon_amplitude'] for ant in antennas])
|
||||
beacon_phases = np.array([lib.phase_mod(ant.attrs['beacon_phase']) for ant in antennas])
|
||||
beacon_phases = np.array([lib.phase_mod(ant.attrs['beacon_phase_measured']) for ant in antennas])
|
||||
else:
|
||||
subtitle = " Phases from t0"
|
||||
beacon_frequencies = np.array([ f_beacon for ant in antennas ])
|
||||
|
|
Loading…
Reference in a new issue