ZH: optional trace extender (WIP)

This commit is contained in:
Eric Teunis de Boone 2022-12-05 14:35:35 +01:00
parent 2ffec6a10b
commit 2ef87343f5
3 changed files with 28 additions and 10 deletions

View file

@ -264,7 +264,7 @@ if __name__ == "__main__":
low_bp = 30e-3 # GHz
high_bp = 80e-3 # GHz
beacon_amplitudes = 1e-6*np.array([1e5, 0, 0]) # mu V/m
beacon_amplitudes = 1e-6*np.array([1e3, 0, 0]) # mu V/m
beacon_radiate_rsq = True # beacon_amplitude is repaired for distance to 0,0,0
# modify beacon power to be beacon_amplitude at 0,0,0
@ -303,15 +303,30 @@ if __name__ == "__main__":
# make beacon per antenna
for i, antenna in enumerate(ev.antennas):
if False: # modify trace lengths
N_samples = len(antenna.t)
new_N = 2*N_samples
dt = antenna.t[1] - antenna.t[0]
new_t = np.arange(0, new_N)*dt + antenna.t[0]
antenna.t = new_t
# TODO:trace extrapolation?
antenna.Ex = np.pad(antenna.Ex, (0, new_N-N_samples), mode='constant', constant_values=0)
antenna.Ey = np.pad(antenna.Ey, (0, new_N-N_samples), mode='constant', constant_values=0)
antenna.Ez = np.pad(antenna.Ez, (0, new_N-N_samples), mode='constant', constant_values=0)
t0 = 0
c_light = 3e8*1e-9 # m/ns
if False:
t0 = lib.distance(tx, antenna)/3e8 * 1e9 # ns
# precalculate t0
# set c_light=np.inf to suppress the time delay
# in the function call
t0 = lib.distance(tx, antenna)/c_light
c_light = np.inf
else:
t0 = 0
c_light = 3e8*1e-9 # m/ns
beacon = lib.beacon_from(tx, antenna, f_beacon, antenna.t, t0=t0, c_light=c_light, radiate_rsq=beacon_radiate_rsq)
traces = np.array([antenna.Ex, antenna.Ey, antenna.Ez, beacon])
# add to relevant polarisation
@ -323,8 +338,9 @@ if __name__ == "__main__":
append_antenna_hdf5( antennas_fname, antenna, traces, name='traces', prepend_time=True, attrs_dict=dict(t0=t0))
# Save E field in E_AxB
E = [np.dot(ev.uAxB,[ex,ey,ez]) for ex,ey,ez in zip(traces[0], traces[1], traces[2])]
E_AxB = [np.dot(ev.uAxB,[ex,ey,ez]) for ex,ey,ez in zip(traces[0], traces[1], traces[2])]
t_AxB = antenna.t
append_antenna_hdf5( antennas_fname, antenna, [E], name='E_AxB', prepend_time=True)
append_antenna_hdf5( antennas_fname, antenna, [t_AxB, E_AxB], name='E_AxB', prepend_time=False)
print("Antenna HDF5 file written as " + str(antennas_fname))

View file

@ -19,7 +19,7 @@ if __name__ == "__main__":
from os import path
import sys
max_clock_offset = 100 if len(sys.argv) < 1 else int(sys.argv[1]) # ns
max_clock_offset = 100 if len(sys.argv) < 2 else int(sys.argv[1]) # ns
remake_clock_offsets = True
seed = 12345

View file

@ -42,7 +42,9 @@ def geometry_time(dist, x2=None, c_light=3e8):
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
# suppress extra time delay from distance
if c_light is not None and np.isfinite(c_light):
t0 = t0 + dist/c_light
if radiate_rsq:
if np.isclose(dist, 0):