diff --git a/simulations/airshower_beacon_simulation/lib.py b/simulations/airshower_beacon_simulation/lib.py index 2fb0c48..b5e1a81 100644 --- a/simulations/airshower_beacon_simulation/lib.py +++ b/simulations/airshower_beacon_simulation/lib.py @@ -5,8 +5,8 @@ import numpy as np from earsim import Antenna -def sine_beacon(f, t, t0=0, amplitude=1): - return amplitude * np.sin(2*np.pi*f*(t-t0)) +def sine_beacon(f, t, t0=0, amplitude=1, baseline=0): + return amplitude * np.sin(2*np.pi*f*(t-t0)) + baseline def distance(x1, x2): @@ -22,8 +22,11 @@ def distance(x1, x2): return np.sqrt( np.sum( (x1-x2)**2 ) ) -def beacon_from(tx, rx, f, t=0, t0=0, c_light=3e8, **kwargs): - dist = distance(tx,rx)/c_light +def beacon_from(tx, rx, f, t=0, t0=0, c_light=3e8, radiate_rsq=True, amplitude=1,**kwargs): + dist = distance(tx,rx) t0 = t0 + dist/c_light - return sine_beacon(f, t, t0=t0, **kwargs) + if radiate_rsq: + amplitude *= 1/(dist**2) + + return sine_beacon(f, t, t0=t0, amplitude=amplitude,**kwargs)