ZH: Allow the beacon's signal to decrease with distance

This commit is contained in:
Eric Teunis de Boone 2022-11-10 15:08:00 +01:00
parent 165a7c0361
commit 0966be97b9

View file

@ -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)