mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m.internship-documentation.git
synced 2024-11-22 15:03:35 +01:00
figure beacon_field: single/three baseline at 1.5km
This commit is contained in:
parent
169842900d
commit
d324b28f81
1 changed files with 52 additions and 27 deletions
|
@ -49,18 +49,21 @@ def phase(a,b,f=f_beacon,wrap=False):
|
||||||
|
|
||||||
return phase
|
return phase
|
||||||
|
|
||||||
def grid_plot(grid, text_dx=(0,0), ax=None, plot_kwargs={}, annot_kwargs={}):
|
def grid_plot(grid, text_dx=(0,0), ax=None, plot_kwargs={}, annot_kwargs={}, scaler=None):
|
||||||
if ax is None:
|
if ax is None:
|
||||||
ax = plt.gca()
|
ax = plt.gca()
|
||||||
|
|
||||||
|
if scaler is None:
|
||||||
|
scaler = 1
|
||||||
|
|
||||||
if not grid:
|
if not grid:
|
||||||
return
|
return
|
||||||
|
|
||||||
default_plot_kwargs=dict(color='k', marker='x', markersize=10, linestyle='None')
|
default_plot_kwargs=dict(color='k', marker='x', markersize=10, linestyle='None')
|
||||||
plot_kwargs = {**default_plot_kwargs, **plot_kwargs}
|
plot_kwargs = {**default_plot_kwargs, **plot_kwargs}
|
||||||
|
|
||||||
x = [a.x for a in grid]
|
x = [a.x/scaler for a in grid]
|
||||||
y = [a.y for a in grid]
|
y = [a.y/scaler for a in grid]
|
||||||
l = [a.name for a in grid]
|
l = [a.name for a in grid]
|
||||||
ax.plot(x, y, **plot_kwargs)
|
ax.plot(x, y, **plot_kwargs)
|
||||||
|
|
||||||
|
@ -116,13 +119,29 @@ def plot_field(
|
||||||
ref_ant=None, plot_phase=None, mask=None,
|
ref_ant=None, plot_phase=None, mask=None,
|
||||||
color_label='$\\left( t - \\tau \\right)^2$',
|
color_label='$\\left( t - \\tau \\right)^2$',
|
||||||
ax=None, bin_type='square', colorbar=True,
|
ax=None, bin_type='square', colorbar=True,
|
||||||
grid_kwargs={},
|
grid_kwargs={}, scaler=None,
|
||||||
**scatter_kwargs
|
**scatter_kwargs
|
||||||
):
|
):
|
||||||
|
|
||||||
if ax is None:
|
if ax is None:
|
||||||
ax = plt.gca()
|
ax = plt.gca()
|
||||||
ax.set_xlabel('x')
|
ax.set_xlabel('x [m]')
|
||||||
ax.set_ylabel('y')
|
ax.set_ylabel('y [m]')
|
||||||
|
|
||||||
|
max_xx, max_yy = max(xx), max(yy)
|
||||||
|
|
||||||
|
if max_xx > 1e3 or max_yy > 1e3:
|
||||||
|
ax.set_xlabel('x [km]')
|
||||||
|
ax.set_ylabel('y [km]')
|
||||||
|
scaler = 1e3
|
||||||
|
|
||||||
|
dxx = xx[-1] - xx[0]
|
||||||
|
dyy = yy[-1] - yy[0]
|
||||||
|
if scaler is None:
|
||||||
|
scaler = 1
|
||||||
|
else:
|
||||||
|
xx = np.array(xx)/scaler
|
||||||
|
yy = np.array(yy)/scaler
|
||||||
|
|
||||||
default_scatter_kwargs = {}
|
default_scatter_kwargs = {}
|
||||||
default_scatter_kwargs['cmap'] = 'Spectral_r'
|
default_scatter_kwargs['cmap'] = 'Spectral_r'
|
||||||
|
@ -133,7 +152,8 @@ def plot_field(
|
||||||
if plot_phase is None:
|
if plot_phase is None:
|
||||||
pass
|
pass
|
||||||
elif plot_phase:
|
elif plot_phase:
|
||||||
default_scatter_kwargs['vmax'] = len(ants)*np.pi
|
val_min = min(val)
|
||||||
|
default_scatter_kwargs['vmax'] = len(ants)*np.pi + val_min
|
||||||
pass
|
pass
|
||||||
|
|
||||||
scatter_kwargs = {**default_scatter_kwargs, **scatter_kwargs}
|
scatter_kwargs = {**default_scatter_kwargs, **scatter_kwargs}
|
||||||
|
@ -152,18 +172,18 @@ def plot_field(
|
||||||
grid_text_kwargs = {**grid_text_kwargs, **grid_kwargs['text_kwargs']}
|
grid_text_kwargs = {**grid_text_kwargs, **grid_kwargs['text_kwargs']}
|
||||||
|
|
||||||
if tx:
|
if tx:
|
||||||
grid_plot([tx], text_dx=(20, 0), ax=ax, plot_kwargs=grid_plot_kwargs, annot_kwargs=grid_text_kwargs)
|
grid_plot([tx], text_dx=(dxx *0/scaler, 0), ax=ax, plot_kwargs=grid_plot_kwargs, annot_kwargs=grid_text_kwargs, scaler=scaler)
|
||||||
|
|
||||||
if len(ants) > 3:
|
if len(ants) > 3:
|
||||||
grid_text_kwargs = None
|
grid_text_kwargs = None
|
||||||
|
|
||||||
grid_plot(ants, text_dx=(20, 0), ax=ax, plot_kwargs=grid_plot_kwargs, annot_kwargs=grid_text_kwargs)
|
grid_plot(ants, text_dx=(dxx*0/scaler, 0), ax=ax, plot_kwargs=grid_plot_kwargs, annot_kwargs=grid_text_kwargs, scaler=scaler)
|
||||||
|
|
||||||
title = ''
|
title = ''
|
||||||
if len(ants) == 1:
|
if len(ants) == 1:
|
||||||
title += "Single Antenna\n"
|
title += "Single Antenna"
|
||||||
elif len(ants) == 2:
|
elif len(ants) == 2:
|
||||||
title += "Single Baseline\n"
|
title += "Single Baseline"
|
||||||
else:
|
else:
|
||||||
if len(ants) == 3:
|
if len(ants) == 3:
|
||||||
title += "Three Baseline"
|
title += "Three Baseline"
|
||||||
|
@ -176,9 +196,10 @@ def plot_field(
|
||||||
if ref_ant is not None:
|
if ref_ant is not None:
|
||||||
title += " with Reference antenna={}".format(ref_ant.name)
|
title += " with Reference antenna={}".format(ref_ant.name)
|
||||||
|
|
||||||
|
if plot_phase:
|
||||||
title += "\n"
|
title += "\n"
|
||||||
|
|
||||||
title += "f=${}$MHz".format(f_beacon/1e6)
|
title += "f=${}$MHz".format(f_beacon/1e6)
|
||||||
|
|
||||||
ax.set_title(title)
|
ax.set_title(title)
|
||||||
|
|
||||||
|
@ -214,6 +235,9 @@ def triangular_grid(dx=1, N_x=10, dy=None, N_y=None, x_start=0, y_start=0):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
km = 1e3#m
|
||||||
|
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
import os.path as path
|
import os.path as path
|
||||||
|
|
||||||
|
@ -231,33 +255,33 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.fname is not None and path.isdir(args.fname):
|
if args.fname is not None:
|
||||||
args.fname = path.join(args.fname, path.splitext(path.basename(__file__))[0]) # leave off extension
|
if path.isdir(args.fname):
|
||||||
|
args.fname = path.join(args.fname, path.splitext(path.basename(__file__))[0]) # leave off extension
|
||||||
if not path.splitext(args.fname)[1]:
|
if not path.splitext(args.fname)[1]:
|
||||||
args.fname = [ args.fname+ext for ext in ['.pdf', '.png'] ]
|
args.fname = [ args.fname+ext for ext in ['.pdf', '.png'] ]
|
||||||
|
|
||||||
args.plot_phase = args.phase or args.time
|
args.plot_phase = args.phase or args.time
|
||||||
del args.time, args.phase
|
del args.time, args.phase
|
||||||
|
|
||||||
if 'single' in args.type or 'three' in args.type: # single baseline
|
if 'single' in args.type or 'three' in args.type: # single baseline
|
||||||
### Field
|
### Field
|
||||||
x_low, x_high, N_x = -300, 300, 151
|
x_low, x_high, N_x = -5*km, 5*km, 151
|
||||||
y_low, y_high, N_y = -300, 300, 151
|
y_low, y_high, N_y = -5*km, 5*km, 151
|
||||||
|
|
||||||
### Geometry
|
### Geometry
|
||||||
ants = [
|
ants = [
|
||||||
Antenna(x=-50,y=0,z=0,name="a"),
|
Antenna(x=-.75*km,y=0,z=0,name="a"),
|
||||||
Antenna(x=50,y=0,z=0,name="b"),
|
Antenna(x=.75*km, y=0,z=0,name="b"),
|
||||||
]
|
]
|
||||||
|
|
||||||
if 'three' in args.type:
|
if 'three' in args.type:
|
||||||
ants.append(Antenna(x=0, y=-50,z=0, name='c'))
|
ants.append(Antenna(x=0, y=-.75*km*np.sqrt(2),z=0, name='c'))
|
||||||
|
|
||||||
if 'center' in args.type:
|
if 'center' in args.type:
|
||||||
tx = Antenna(x=-000,y=200,z=0,name="tx")
|
tx = Antenna(x=-000,y=4*km,z=0,name="tx")
|
||||||
else:
|
else:
|
||||||
tx = Antenna(x=-200,y=200,z=0,name="tx")
|
tx = Antenna(x=-4*km,y=4*km,z=0,name="tx")
|
||||||
|
|
||||||
elif args.type == 'square' or args.type == 'tri': # from grid definition
|
elif args.type == 'square' or args.type == 'tri': # from grid definition
|
||||||
### Field
|
### Field
|
||||||
|
@ -294,8 +318,8 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
if args.zoom != 'none': # tx zoom
|
if args.zoom != 'none': # tx zoom
|
||||||
if args.zoom == 'tx':
|
if args.zoom == 'tx':
|
||||||
x_low, x_high, N_x = tx.x - 40, tx.x + 40, 81
|
x_low, x_high, N_x = tx.x - 250, tx.x + 250, 151
|
||||||
y_low, y_high, N_y = -x_low, x_high, N_x
|
y_low, y_high, N_y = x_low, x_high, N_x
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError# args.zoom
|
raise NotImplementedError# args.zoom
|
||||||
|
|
||||||
|
@ -321,7 +345,8 @@ if __name__ == "__main__":
|
||||||
mask = None
|
mask = None
|
||||||
if plot_phase:
|
if plot_phase:
|
||||||
color_label='$\\sqrt{ \\sum_{(i,j)} \\left(\\Delta\\varphi_{ij}(x) - \\Delta \\varphi_{ij}\\right)^2}$'
|
color_label='$\\sqrt{ \\sum_{(i,j)} \\left(\\Delta\\varphi_{ij}(x) - \\Delta \\varphi_{ij}\\right)^2}$'
|
||||||
mask = abs(val) > np.pi
|
min_val = min(val)
|
||||||
|
mask = abs(val) > np.pi + min_val
|
||||||
else:
|
else:
|
||||||
color_label='$\\sqrt{ \\sum_{(i,j)} \\left(\Delta t_{ij}(x) - \\Delta t_{ij}\\right)^2}$ [ns]'
|
color_label='$\\sqrt{ \\sum_{(i,j)} \\left(\Delta t_{ij}(x) - \\Delta t_{ij}\\right)^2}$ [ns]'
|
||||||
val *= 1e9
|
val *= 1e9
|
||||||
|
|
Loading…
Reference in a new issue