mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-13 01:53:31 +01:00
Phasefield figure finalised, moving to documentation repository
This commit is contained in:
parent
911d5b7a54
commit
2bfdd922bb
1 changed files with 64 additions and 27 deletions
|
@ -1,5 +1,12 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
__doc__ = \
|
||||
"""
|
||||
Generate a figure showing a value combining
|
||||
the delays between a transmitter and a set of antennas
|
||||
"""
|
||||
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from itertools import chain, combinations, product
|
||||
|
@ -53,7 +60,6 @@ def grid_plot(grid, ax=None, **plot_kwargs):
|
|||
for x_,y_,l_ in zip(x,y,l):
|
||||
ax.annotate(l_,(x_,y_))
|
||||
|
||||
|
||||
def antenna_combinations(ants, ref_ant=None):
|
||||
if ref_ant is not None: # use only one reference antenna for the baselines
|
||||
ref = ref_ant
|
||||
|
@ -113,9 +119,6 @@ def plot_field(tx, ants, xx, yy, val, ax=None, ref_ant=None, color_label='$\\lef
|
|||
default_scatter_kwargs['vmax'] = len(ants)*np.pi
|
||||
#default_scatter_kwargs['cmap'] = 'gray'
|
||||
pass
|
||||
else:
|
||||
val *=1e9 # to ns
|
||||
default_scatter_kwargs['vmax'] = 100
|
||||
|
||||
scatter_kwargs = {**default_scatter_kwargs, **scatter_kwargs}
|
||||
|
||||
|
@ -131,7 +134,6 @@ def plot_field(tx, ants, xx, yy, val, ax=None, ref_ant=None, color_label='$\\lef
|
|||
|
||||
return ax
|
||||
|
||||
|
||||
def square_grid(dx=1, N_x=10, dy=None, N_y=None, x_start=0, y_start=0):
|
||||
N_y = N_x if N_y is None else N_y
|
||||
dy = dx if dy is None else dy
|
||||
|
@ -154,36 +156,60 @@ def triangular_grid(dx=1, N_x=10, dy=None, N_y=None, x_start=0, y_start=0):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from argparse import ArgumentParser
|
||||
import os.path as path
|
||||
|
||||
###
|
||||
### Field
|
||||
###
|
||||
x_low, x_high, N_x = -1203, 300, 81
|
||||
y_low, y_high, N_y = -x_low, -x_high, N_x
|
||||
parser = ArgumentParser(description=__doc__)
|
||||
parser.add_argument("fname", metavar="path/to/figure[/]", nargs="?", help="Location for generated figure, will append __file__ if a directory. If not supplied, figure is shown.")
|
||||
|
||||
###
|
||||
### Geometry
|
||||
###
|
||||
tx = Antenna(x=-800,y=300,z=0,name="tx")
|
||||
|
||||
if True: # single baseline
|
||||
parser.add_argument("type", choices=['single-left', 'single-center', 'square', 'tri', 'preset'])
|
||||
|
||||
|
||||
command_group = parser.add_mutually_exclusive_group(required=True)
|
||||
command_group.add_argument('--time', help='Use the time difference for the field', action='store_false')
|
||||
command_group.add_argument('--phase', help='Use wrapped phase for the field', action='store_true')
|
||||
|
||||
parser.add_argument('--ref', dest='ref_ant', metavar='ref_antenna', help='Number of antenna to use as reference')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.fname is not None and path.isdir(args.fname):
|
||||
args.fname = path.join(args.fname, path.splitext(path.basename(__file__))[0] + ".pdf")
|
||||
|
||||
args.plot_phase = args.phase or args.time
|
||||
del args.time, args.phase
|
||||
|
||||
|
||||
if 'single' in args.type: # single baseline
|
||||
### Field
|
||||
x_low, x_high, N_x = -300, 300, 81
|
||||
y_low, y_high, N_y = -300, 300, 81
|
||||
|
||||
### Geometry
|
||||
ants = [
|
||||
Antenna(x=-50,y=0,z=0,name="a"),
|
||||
Antenna(x=50,y=0,z=0,name="b"),
|
||||
]
|
||||
|
||||
tx = Antenna(x=-000,y=200,z=0,name="tx")
|
||||
if args.type == 'single-center':
|
||||
tx = Antenna(x=-000,y=200,z=0,name="tx")
|
||||
else:
|
||||
tx = Antenna(x=-200,y=200,z=0,name="tx")
|
||||
|
||||
x_low, x_high, N_x = -300, 300, 81
|
||||
y_low, y_high, N_y = -300, 300, 81
|
||||
elif args.type == 'square' or args.type == 'tri': # from grid definition
|
||||
### Field
|
||||
x_low, x_high, N_x = -1800, 1800, 161
|
||||
y_low, y_high, N_y = -x_low, -x_high, N_x
|
||||
|
||||
elif not True: # from grid definition
|
||||
### Geometry
|
||||
tx = Antenna(x=-800,y=300,z=0,name="tx")
|
||||
x_start, dx, ant_N_x = 0, 50, 2
|
||||
y_start, dy, ant_N_y = 0, dx, ant_N_x
|
||||
|
||||
if not True: # square grid
|
||||
if args.type == 'square': # square grid
|
||||
grid_func = square_grid
|
||||
elif True: # triangular
|
||||
elif args.type == 'tri': # triangular
|
||||
grid_func = triangular_grid
|
||||
|
||||
grid = grid_func(dx=dx, dy=dy, N_x=ant_N_x, N_y=ant_N_y, x_start=x_start, y_start=y_start)
|
||||
|
@ -191,6 +217,12 @@ if __name__ == "__main__":
|
|||
|
||||
ants = [ Antenna(x=x,y=y,z=0,name=i) for i, (x,y) in enumerate(grid) ]
|
||||
else:
|
||||
### Field
|
||||
x_low, x_high, N_x = -400, 400, 161
|
||||
y_low, y_high, N_y = -x_low, -x_high, N_x
|
||||
|
||||
### Geometry
|
||||
tx = Antenna(x=-300,y=300,z=0,name="tx")
|
||||
ants = [
|
||||
Antenna(x=100,y=0,z=0,name="a"),
|
||||
Antenna(x=0,y=-50,z=0,name="b"),
|
||||
|
@ -201,13 +233,12 @@ if __name__ == "__main__":
|
|||
###
|
||||
### Options
|
||||
###
|
||||
plot_phase = True
|
||||
ref_ant = None
|
||||
plot_phase = args.plot_phase
|
||||
ref_ant = args.ref_ant
|
||||
|
||||
|
||||
ant_combi = antenna_combinations(ants, ref_ant=ref_ant)
|
||||
|
||||
print("Antenna Combinations calculated")
|
||||
|
||||
xs = np.linspace(x_low, x_high, N_x)
|
||||
ys = np.linspace(y_low, y_high, N_y)
|
||||
|
||||
|
@ -218,13 +249,15 @@ if __name__ == "__main__":
|
|||
mask = abs(val) > np.pi
|
||||
|
||||
|
||||
kwargs = {}
|
||||
if plot_phase:
|
||||
color_label='$\\sqrt{ \\sum \\left(\\varphi(x) - \\Delta \\varphi\\right)^2}$'
|
||||
else:
|
||||
color_label='$\\sqrt{ \\sum \\left(t(x) - \\Delta t\\right)^2}$ [ns]'
|
||||
val *= 1e9
|
||||
kwargs['vmax'] = 100
|
||||
|
||||
ax = plot_field(tx, ants, xx, yy, val, ax=None, ref_ant=ref_ant, mask=mask, color_label=color_label)
|
||||
ax = plot_field(tx, ants, xx, yy, val, ax=None, ref_ant=ref_ant, mask=mask, color_label=color_label, **kwargs)
|
||||
|
||||
# if plot_phase:
|
||||
# N_lowest = np.min(len(ant_combi)-1, 10)
|
||||
|
@ -233,4 +266,8 @@ if __name__ == "__main__":
|
|||
# print(lowest_idx)
|
||||
# print(val[lowest_idx])
|
||||
# print( list(zip(np.array(xx)[lowest_idx], np.array(yy)[lowest_idx])) )
|
||||
plt.show()
|
||||
|
||||
if args.fname is not None:
|
||||
plt.savefig(args.fname)
|
||||
else:
|
||||
plt.show()
|
||||
|
|
Loading…
Reference in a new issue