mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-12-22 11:33:32 +01:00
ZH: small unassorted tweaks
This commit is contained in:
parent
bb776d358c
commit
7df39cf6ab
3 changed files with 18 additions and 9 deletions
|
@ -85,7 +85,7 @@ def init_antenna_hdf5(fname, tx = None, f_beacon = None):
|
||||||
|
|
||||||
return fname
|
return fname
|
||||||
|
|
||||||
def append_antenna_hdf5(fname, antenna, columns = [], name='traces', prepend_time=True, overwrite=True):
|
def append_antenna_hdf5(fname, antenna, columns = [], name='traces', prepend_time=True, overwrite=True, attrs_dict={}):
|
||||||
if not overwrite:
|
if not overwrite:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@ -111,6 +111,9 @@ def append_antenna_hdf5(fname, antenna, columns = [], name='traces', prepend_tim
|
||||||
ant_attrs['z'] = antenna.z
|
ant_attrs['z'] = antenna.z
|
||||||
ant_attrs['name'] = antenna.name
|
ant_attrs['name'] = antenna.name
|
||||||
|
|
||||||
|
for k,v in attrs_dict.items():
|
||||||
|
ant_attrs[k] = v
|
||||||
|
|
||||||
if name in ant_group:
|
if name in ant_group:
|
||||||
if not overwrite:
|
if not overwrite:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
@ -141,7 +144,7 @@ if __name__ == "__main__":
|
||||||
tx = Antenna(x=-20e3,y=0,z=0,name='tx') # m
|
tx = Antenna(x=-20e3,y=0,z=0,name='tx') # m
|
||||||
dist = lib.distance(tx, Antenna(x=0, y=0, z=0))
|
dist = lib.distance(tx, Antenna(x=0, y=0, z=0))
|
||||||
|
|
||||||
ampl = dist**2
|
ampl = max(1, dist**2)
|
||||||
|
|
||||||
beacon_amplitudes *= ampl
|
beacon_amplitudes *= ampl
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# vim: fdm=indent ts=4
|
||||||
"""
|
"""
|
||||||
Library for this simulation
|
Library for this simulation
|
||||||
"""
|
"""
|
||||||
|
@ -5,8 +6,11 @@ import numpy as np
|
||||||
|
|
||||||
from earsim import Antenna
|
from earsim import Antenna
|
||||||
|
|
||||||
def sine_beacon(f, t, t0=0, amplitude=1, baseline=0):
|
def sine_beacon(f, t, t0=0, amplitude=1, baseline=0, phase=0):
|
||||||
return amplitude * np.sin(2*np.pi*f*(t-t0)) + baseline
|
"""
|
||||||
|
Return a sine appropriate as a beacon
|
||||||
|
"""
|
||||||
|
return amplitude * np.cos(2*np.pi*f*(t+t0) + phase) + baseline
|
||||||
|
|
||||||
|
|
||||||
def distance(x1, x2):
|
def distance(x1, x2):
|
||||||
|
@ -27,6 +31,8 @@ def beacon_from(tx, rx, f, t=0, t0=0, c_light=3e8, radiate_rsq=True, amplitude=1
|
||||||
t0 = t0 + dist/c_light
|
t0 = t0 + dist/c_light
|
||||||
|
|
||||||
if radiate_rsq:
|
if radiate_rsq:
|
||||||
|
if np.isclose(dist, 0):
|
||||||
|
dist = 1
|
||||||
amplitude *= 1/(dist**2)
|
amplitude *= 1/(dist**2)
|
||||||
|
|
||||||
return sine_beacon(f, t, t0=t0, amplitude=amplitude,**kwargs)
|
return sine_beacon(f, t, t0=t0, amplitude=amplitude,**kwargs)
|
||||||
|
|
|
@ -31,7 +31,7 @@ def plot_antenna_Efields(antenna, ax=None, plot_Ex=True, plot_Ey=True, plot_Ez=T
|
||||||
|
|
||||||
return ax
|
return ax
|
||||||
|
|
||||||
def plot_antenna_geometry(antennas, ax=None, log_max=False, plot_names=True, plot_max_values=True,**kwargs):
|
def plot_antenna_geometry(antennas, ax=None, plot_names=True, plot_max_values=True, log_max=False, colors=None,**kwargs):
|
||||||
"""Show the max values at each antenna."""
|
"""Show the max values at each antenna."""
|
||||||
default_kwargs = dict(
|
default_kwargs = dict(
|
||||||
cmap='Spectral_r'
|
cmap='Spectral_r'
|
||||||
|
@ -50,10 +50,10 @@ def plot_antenna_geometry(antennas, ax=None, log_max=False, plot_names=True, plo
|
||||||
|
|
||||||
if log_max:
|
if log_max:
|
||||||
max_vals = np.log10(max_vals)
|
max_vals = np.log10(max_vals)
|
||||||
else:
|
|
||||||
max_vals = None
|
|
||||||
|
|
||||||
sc = ax.scatter(x, y, c=max_vals, **kwargs)
|
colors = max_vals
|
||||||
|
|
||||||
|
sc = ax.scatter(x, y, c=colors, **kwargs)
|
||||||
|
|
||||||
if plot_max_values:
|
if plot_max_values:
|
||||||
fig = ax.get_figure()
|
fig = ax.get_figure()
|
||||||
|
@ -67,7 +67,7 @@ def plot_antenna_geometry(antennas, ax=None, log_max=False, plot_names=True, plo
|
||||||
ax.set_xlabel("[m]")
|
ax.set_xlabel("[m]")
|
||||||
|
|
||||||
|
|
||||||
return ax
|
return ax, sc
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
fname = "ZH_airshower/mysim.sry"
|
fname = "ZH_airshower/mysim.sry"
|
Loading…
Reference in a new issue