mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-12-22 03:23:34 +01:00
ZH: slight tweak of view_ant0.py
This commit is contained in:
parent
afe1a23150
commit
8b1fd14ab9
1 changed files with 26 additions and 19 deletions
|
@ -6,7 +6,7 @@ import matplotlib.pyplot as plt
|
||||||
from earsim import REvent
|
from earsim import REvent
|
||||||
|
|
||||||
|
|
||||||
def plot_antenna_Efields(antenna, ax=None, plot_Ex=True, plot_Ey=True, plot_Ez=True, **kwargs):
|
def plot_antenna_Efields(antenna, ax=None, plot_Ex=True, plot_Ey=True, plot_Ez=True, label_append="",**kwargs):
|
||||||
"""Show waveforms from an antenna"""
|
"""Show waveforms from an antenna"""
|
||||||
if ax is None:
|
if ax is None:
|
||||||
ax = plt.gca()
|
ax = plt.gca()
|
||||||
|
@ -18,11 +18,11 @@ def plot_antenna_Efields(antenna, ax=None, plot_Ex=True, plot_Ey=True, plot_Ez=T
|
||||||
i = antenna.name
|
i = antenna.name
|
||||||
|
|
||||||
if plot_Ex:
|
if plot_Ex:
|
||||||
ax.plot(antenna.t, antenna.Ex, label="E{x}".format(x='x', i=i), **kwargs)
|
ax.plot(antenna.t, antenna.Ex, label=f"E{{x}}{label_append}".format(x='x', i=i), **kwargs)
|
||||||
if plot_Ey:
|
if plot_Ey:
|
||||||
ax.plot(antenna.t, antenna.Ey, label="E{x}".format(x='y', i=i), **kwargs)
|
ax.plot(antenna.t, antenna.Ey, label=f"E{{x}}{label_append}".format(x='y', i=i), **kwargs)
|
||||||
if plot_Ez:
|
if plot_Ez:
|
||||||
ax.plot(antenna.t, antenna.Ez, label="E{x}".format(x='z', i=i), **kwargs)
|
ax.plot(antenna.t, antenna.Ez, label=f"E{{x}}{label_append}".format(x='z', i=i), **kwargs)
|
||||||
|
|
||||||
ax.set_xlabel("[ns]")
|
ax.set_xlabel("[ns]")
|
||||||
ax.set_ylabel("[$\mu$V/m]")
|
ax.set_ylabel("[$\mu$V/m]")
|
||||||
|
@ -31,33 +31,37 @@ def plot_antenna_Efields(antenna, ax=None, plot_Ex=True, plot_Ey=True, plot_Ez=T
|
||||||
|
|
||||||
return ax
|
return ax
|
||||||
|
|
||||||
def plot_antenna_max_values(antennas, ax=None, log_max=False, plot_names=True, **kwargs):
|
def plot_antenna_geometry(antennas, ax=None, log_max=False, plot_names=True, plot_max_values=True,**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'
|
||||||
)
|
)
|
||||||
|
|
||||||
kwargs = {**default_kwargs, **kwargs}
|
kwargs = {**default_kwargs, **kwargs}
|
||||||
|
|
||||||
x = [ a.x for a in antennas ]
|
x = [ a.x for a in antennas ]
|
||||||
y = [ a.y for a in antennas ]
|
y = [ a.y for a in antennas ]
|
||||||
|
|
||||||
max_vals = np.asarray([ np.max([np.max(a.Ex), np.max(a.Ey), np.max(a.Ez)]) for a in antennas ])
|
|
||||||
|
|
||||||
if log_max:
|
|
||||||
max_vals = np.log10(max_vals)
|
|
||||||
|
|
||||||
|
|
||||||
if ax is None:
|
if ax is None:
|
||||||
ax = plt.gca()
|
ax = plt.gca()
|
||||||
|
|
||||||
|
if plot_max_values:
|
||||||
|
max_vals = np.asarray([ np.max([np.max(a.Ex), np.max(a.Ey), np.max(a.Ez)]) for a in antennas ])
|
||||||
|
|
||||||
|
if log_max:
|
||||||
|
max_vals = np.log10(max_vals)
|
||||||
|
else:
|
||||||
|
max_vals = None
|
||||||
|
|
||||||
sc = ax.scatter(x, y, c=max_vals, **kwargs)
|
sc = ax.scatter(x, y, c=max_vals, **kwargs)
|
||||||
fig = ax.get_figure()
|
|
||||||
fig.colorbar(sc, ax=ax, label="[$\mu$V/m]")
|
if plot_max_values:
|
||||||
|
fig = ax.get_figure()
|
||||||
|
fig.colorbar(sc, ax=ax, label="[$\mu$V/m]")
|
||||||
|
|
||||||
if plot_names:
|
if plot_names:
|
||||||
[ ax.annotate(a.name, (a.x, a.y), ha='center',va='center') for a in antennas ]
|
[ ax.annotate(a.name, (a.x, a.y), ha='center',va='center') for a in antennas ]
|
||||||
|
|
||||||
ax.set_title("Maximum E field at each antenna")
|
ax.set_title("Maximum E field at each antenna")
|
||||||
ax.set_ylabel("[m]")
|
ax.set_ylabel("[m]")
|
||||||
ax.set_xlabel("[m]")
|
ax.set_xlabel("[m]")
|
||||||
|
@ -71,10 +75,13 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
ev = REvent(fname)
|
ev = REvent(fname)
|
||||||
|
|
||||||
fig, ax1 = plt.subplots()
|
if True:
|
||||||
plot_antenna_Efields(ev.antennas[i], ax=ax1)
|
fig, ax1 = plt.subplots()
|
||||||
|
plot_antenna_Efields(ev.antennas[i], ax=ax1)
|
||||||
|
|
||||||
fig2, ax2 = plt.subplots()
|
if True:
|
||||||
plot_antenna_max_values(ev.antennas, ax=ax2)
|
fig2, ax2 = plt.subplots()
|
||||||
|
plot_antenna_geometry(ev.antennas, ax=ax2, plot_max_values=True, plot_names=False)
|
||||||
|
ax2.set_aspect('equal', 'datalim')
|
||||||
|
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
Loading…
Reference in a new issue