Merge branch '2022-10-06_group_meeting' into main

This commit is contained in:
Eric Teunis de Boone 2022-10-06 11:13:55 +02:00
commit 169842900d
7 changed files with 440 additions and 42 deletions

View file

@ -2,44 +2,117 @@
all: dist
dist: \
sine_beacon.pdf sine_beacon.png \
ttl_beacon.pdf ttl_beacon.png \
field_singleleft_time.pdf field_singleleft_time.png \
field_singleleft_phase.pdf field_singleleft_phase.png \
field_singlecenter_time.pdf field_singlecenter_time.png \
field_singlecenter_phase.pdf field_singlecenter_phase.png \
antenna_setup_four.pdf antenna_setup_four.png \
antenna_setup_three.pdf antenna_setup_three.png
single_beacon \
field_single \
field_three \
field_square \
antenna_setup \
#
dist-clean:
rm -v sine_beacon.*
rm -v ttl_beacon.*
rm -v field_singleleft_time.*
rm -v field_singleleft_phase.*
rm -v field_singlecenter_time.*
rm -v field_singlecenter_phase.*
rm -v field_single_left_time.*
rm -v field_single_left_phase.*
rm -v field_single_center_time.*
rm -v field_single_center_phase.*
rm -v field_three_left_time.*
rm -v field_three_left_phase.*
rm -v field_three_center_time.*
rm -v field_three_center_phase.*
rm -v field_square_all_time.*
rm -v field_square_all_phase.*
rm -v field_square_ref0_time.*
rm -v field_square_ref0_phase.*
beacon_spatial_time_difference_setup.pdf: src/beacon_spatial_time_difference_setup.py
$< $@
single_beacon: \
sine_beacon.pdf sine_beacon.png \
ttl_beacon.pdf ttl_beacon.png
sine_beacon.%: src/single_beacon.py
$< --periods 2 --no-grid --with-rates sine $@
ttl_beacon.%: src/single_beacon.py
$< --periods 2 --no-grid --with-rates ttl $@
field_singleleft_time.%: src/beacon_field.py
field_single: \
field_single_left_time.pdf field_single_left_time.png \
field_single_left_phase.pdf field_single_left_phase.png \
field_single_center_time.pdf field_single_center_time.png \
field_single_center_phase.pdf field_single_center_phase.png \
#
field_single_left_time.%: src/beacon_field.py
$< --time $@ single-left
field_singleleft_phase.%: src/beacon_field.py
field_single_left_phase.%: src/beacon_field.py
$< --phase $@ single-left
field_singlecenter_time.%: src/beacon_field.py
field_single_center_time.%: src/beacon_field.py
$< --time $@ single-center
field_singlecenter_phase.%: src/beacon_field.py
field_single_center_phase.%: src/beacon_field.py
$< --phase $@ single-center
field_three: \
field_three_left_time.pdf field_three_left_time.png \
field_three_left_phase.pdf field_three_left_phase.png \
field_three_center_time.pdf field_three_center_time.png \
field_three_center_phase.pdf field_three_center_phase.png \
#
field_three_left_time.%: src/beacon_field.py
$< --time $@ three-left
field_three_left_phase.%: src/beacon_field.py
$< --phase $@ three-left
field_three_center_time.%: src/beacon_field.py
$< --time $@ three-center
field_three_center_phase.%: src/beacon_field.py
$< --phase $@ three-center
field_square: \
field_square_all_time.pdf field_square_all_time.png \
field_square_all_phase.pdf field_square_all_phase.png \
field_square_ref0_time.pdf field_square_ref0_time.png \
field_square_ref0_phase.pdf field_square_ref0_phase.png \
field_square_all_time_zoomtx.pdf field_square_all_time_zoomtx.png \
field_square_all_phase_zoomtx.pdf field_square_all_phase_zoomtx.png \
field_square_ref0_time_zoomtx.pdf field_square_ref0_time_zoomtx.png \
field_square_ref0_phase_zoomtx.pdf field_square_ref0_phase_zoomtx.png \
#
field_square_ref0_time.%: src/beacon_field.py
$< --time $@ square --ref 0
field_square_ref0_phase.%: src/beacon_field.py
$< --phase $@ square --ref 0
field_square_all_time.%: src/beacon_field.py
$< --time $@ square
field_square_all_phase.%: src/beacon_field.py
$< --phase $@ square
field_square_ref0_time_zoomtx.%: src/beacon_field.py
$< --time $@ square --ref 0 --zoom tx
field_square_ref0_phase_zoomtx.%: src/beacon_field.py
$< --phase $@ square --ref 0 --zoom tx
field_square_all_time_zoomtx.%: src/beacon_field.py
$< --time $@ square --zoom tx
field_square_all_phase_zoomtx.%: src/beacon_field.py
$< --phase $@ square --zoom tx
antenna_setup: \
antenna_setup_four.pdf antenna_setup_four.png \
antenna_setup_three.pdf antenna_setup_three.png \
#
antenna_setup_four.%: src/four_antenna_setup.py
$< $@
antenna_setup_three.%: src/four_antenna_setup.py
$< --no-extra $@
antenna_setup_two.%: src/four_antenna_setup.py
$< --no-extra $@ 2

View file

@ -49,16 +49,24 @@ def phase(a,b,f=f_beacon,wrap=False):
return phase
def grid_plot(grid, ax=None, **plot_kwargs):
def grid_plot(grid, text_dx=(0,0), ax=None, plot_kwargs={}, annot_kwargs={}):
if ax is None:
ax = plt.gca()
if not grid:
return
default_plot_kwargs=dict(color='k', marker='x', markersize=10, linestyle='None')
plot_kwargs = {**default_plot_kwargs, **plot_kwargs}
x = [a.x for a in grid]
y = [a.y for a in grid]
l = [a.name for a in grid]
ax.plot(x,y,'kx', **plot_kwargs)
for x_,y_,l_ in zip(x,y,l):
ax.annotate(l_,(x_,y_))
ax.plot(x, y, **plot_kwargs)
if annot_kwargs is not None:
for x_,y_,l_ in zip(x,y,l):
ax.annotate(l_,(x_,y_), xytext=(x_+text_dx[0], y_+text_dx[0]), **annot_kwargs)
def antenna_combinations(ants, ref_ant=None):
if ref_ant is not None: # use only one reference antenna for the baselines
@ -108,10 +116,13 @@ def plot_field(
ref_ant=None, plot_phase=None, mask=None,
color_label='$\\left( t - \\tau \\right)^2$',
ax=None, bin_type='square', colorbar=True,
grid_kwargs={},
**scatter_kwargs
):
if ax is None:
ax = plt.gca()
ax.set_xlabel('x')
ax.set_ylabel('y')
default_scatter_kwargs = {}
default_scatter_kwargs['cmap'] = 'Spectral_r'
@ -127,11 +138,49 @@ def plot_field(
scatter_kwargs = {**default_scatter_kwargs, **scatter_kwargs}
grid_plot([tx] + ants, ax=ax)
if ref_ant is not None:
ax.set_title("Single baseline\n reference antenna={}, f={}MHz".format(ref_ant.name, f_beacon/1e6))
if tx or ants:
grid_plot_kwargs = dict(marker='X', color='w', alpha=0.8, markeredgecolor='k', markeredgewidth=1)
grid_text_kwargs = dict(
fontsize='large',
color='k',
bbox=dict(boxstyle='Round', alpha=0.5, facecolor='w')
)
if 'plot_kwargs' in grid_kwargs:
grid_plot_kwargs = {**grid_plot_kwargs, **grid_kwargs['plot_kwargs']}
if 'text_kwargs' in grid_kwargs:
grid_text_kwargs = {**grid_text_kwargs, **grid_kwargs['text_kwargs']}
if tx:
grid_plot([tx], text_dx=(20, 0), ax=ax, plot_kwargs=grid_plot_kwargs, annot_kwargs=grid_text_kwargs)
if len(ants) > 3:
grid_text_kwargs = None
grid_plot(ants, text_dx=(20, 0), ax=ax, plot_kwargs=grid_plot_kwargs, annot_kwargs=grid_text_kwargs)
title = ''
if len(ants) == 1:
title += "Single Antenna\n"
elif len(ants) == 2:
title += "Single Baseline\n"
else:
ax.set_title("All baselines\n f={} MHz".format(f_beacon/1e6))
if len(ants) == 3:
title += "Three Baseline"
else:
if ref_ant is not None:
title += "MultiBaseline"
else:
title += "All Baselines"
if ref_ant is not None:
title += " with Reference antenna={}".format(ref_ant.name)
title += "\n"
title += "f=${}$MHz".format(f_beacon/1e6)
ax.set_title(title)
if bin_type == 'hex': # hexbin
sc = ax.hexbin(xx, yy, C=val, **scatter_kwargs)
@ -170,27 +219,28 @@ if __name__ == "__main__":
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.")
parser.add_argument("type", choices=['single-left', 'single-center', 'square', 'tri', 'preset'])
parser.add_argument("type", choices=['single-left', 'single-center','three-left', 'three-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')
parser.add_argument('--ref', dest='ref_ant', metavar='ref_antenna', type=int, help='Number of antenna to use as reference')
parser.add_argument('--max-rms', dest='max_rms', metavar='max_rms', type=float, help='Maximum rms to show in colorbar', default=True)
parser.add_argument('--zoom', choices=['none', 'tx'], help='Zoom to object', default='none')
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.fname = path.join(args.fname, path.splitext(path.basename(__file__))[0]) # leave off extension
if not path.splitext(args.fname)[1]:
args.fname = [ args.fname+ext for ext in ['.pdf', '.png'] ]
args.plot_phase = args.phase or args.time
del args.time, args.phase
if 'single' in args.type: # single baseline
if 'single' in args.type or 'three' in args.type: # single baseline
### Field
x_low, x_high, N_x = -300, 300, 151
y_low, y_high, N_y = -300, 300, 151
@ -201,7 +251,10 @@ if __name__ == "__main__":
Antenna(x=50,y=0,z=0,name="b"),
]
if args.type == 'single-center':
if 'three' in args.type:
ants.append(Antenna(x=0, y=-50,z=0, name='c'))
if 'center' in args.type:
tx = Antenna(x=-000,y=200,z=0,name="tx")
else:
tx = Antenna(x=-200,y=200,z=0,name="tx")
@ -213,7 +266,7 @@ if __name__ == "__main__":
### Geometry
tx = Antenna(x=-800,y=300,z=0,name="tx")
x_start, dx, ant_N_x = 0, 50, 2
x_start, dx, ant_N_x = 0, 50, 3
y_start, dy, ant_N_y = 0, dx, ant_N_x
if args.type == 'square': # square grid
@ -239,11 +292,21 @@ if __name__ == "__main__":
Antenna(x=125,y=180,z=0,name="d"),
]
if args.zoom != 'none': # tx zoom
if args.zoom == 'tx':
x_low, x_high, N_x = tx.x - 40, tx.x + 40, 81
y_low, y_high, N_y = -x_low, x_high, N_x
else:
raise NotImplementedError# args.zoom
###
### Options
###
plot_phase = args.plot_phase
ref_ant = args.ref_ant
if args.ref_ant is not None:
ref_ant = ants[args.ref_ant]
else:
ref_ant = None
ant_combi = antenna_combinations(ants, ref_ant=ref_ant)
@ -257,18 +320,20 @@ if __name__ == "__main__":
kwargs = {}
mask = None
if plot_phase:
color_label='$\\sqrt{ \\sum \\left(\\varphi(x) - \\Delta \\varphi\\right)^2}$'
color_label='$\\sqrt{ \\sum_{(i,j)} \\left(\\Delta\\varphi_{ij}(x) - \\Delta \\varphi_{ij}\\right)^2}$'
mask = abs(val) > np.pi
else:
color_label='$\\sqrt{ \\sum \\left(t(x) - \\Delta t\\right)^2}$ [ns]'
color_label='$\\sqrt{ \\sum_{(i,j)} \\left(\Delta t_{ij}(x) - \\Delta t_{ij}\\right)^2}$ [ns]'
val *= 1e9
kwargs['vmax'] = 100
if args.max_rms:
kwargs['vmax'] = 100 if args.max_rms is True else args.max_rms
if not True:
mask = abs(val) > 1.1*kwargs['vmax']
if mask is not None:
ax = plot_field([], [], xx, yy, val, cmap='Greys', colorbar=False)
ax = plot_field([], [], xx, yy, val, cmap='Greys', colorbar=False, alpha=0.5)
ax = plot_field(tx, ants, xx, yy, val, ref_ant=ref_ant, mask=mask, color_label=color_label, **kwargs)
@ -281,6 +346,10 @@ if __name__ == "__main__":
# print( list(zip(np.array(xx)[lowest_idx], np.array(yy)[lowest_idx])) )
if args.fname is not None:
plt.savefig(args.fname)
if isinstance(args.fname, str):
args.fname = [args.fname]
for fname in args.fname:
plt.savefig(fname)
else:
plt.show()

View file

@ -63,7 +63,7 @@ def antenna_baselines(antennas):
return combinations(antennas, 2)
def plot_four_antenna_geometry(tx, ants, extra_ant=None, ax=None, line_kwargs={}, scatter_kwargs={}, scatter_zorder=5):
def plot_four_antenna_geometry(tx, ants, extra_ant=None, ax=None, line_kwargs={}, scatter_kwargs={}, scatter_zorder=5, annotate_td=True):
default_line_kwargs = dict( color='grey', lw=3, alpha=0.7)
default_scatter_kwargs = dict( color='grey', s=200)
@ -88,9 +88,19 @@ def plot_four_antenna_geometry(tx, ants, extra_ant=None, ax=None, line_kwargs={}
# Lines connecting Tx and ants
tmp_line_kwargs = line_kwargs
tmp_line_kwargs['linestyle'] = '--'
for ant in ants:
ax.plot([tx.x, ant.x], [tx.y, ant.y], **tmp_line_kwargs)
if annotate_td:
annot_kwargs = dict(va='bottom', ha='center')
dx, dy = 0, 0.1
x = (tx.x + ant.x)/2 + dx
y = (tx.y + ant.y)/2 + dy
ax.annotate(f'$t_{{d{ant.name}}}$', (x,y), **annot_kwargs)
# Lines due to all Antennas (including extra_ant)
if extra_ant is not None:
line_offset = 0.08*np.array([1,1])
@ -111,6 +121,7 @@ def plot_four_antenna_geometry(tx, ants, extra_ant=None, ax=None, line_kwargs={}
# Lines internal to ants triangle
tmp_line_kwargs = line_kwargs
tmp_line_kwargs['color'] = 'green'
tmp_line_kwargs['linestyle'] = '-'
tmp_line_kwargs['alpha'] = 0.7
for j, ant_pair in enumerate(combinations(ants,2)):
a, b = ant_pair[0], ant_pair[1]
@ -129,6 +140,7 @@ if __name__ == "__main__":
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.")
parser.add_argument('num_ant', help='Number of antennas to show 2, 3', default=3, type=int)
parser.add_argument("--no-extra", dest='extra', action='store_false', help='Disable the extra (fourth) antenna')
args = parser.parse_args()
@ -144,6 +156,9 @@ if __name__ == "__main__":
Antenna(name='3', x=1, y= 3, t0=10 ),
]
if args.num_ant < 3:
ants = [ants[0], ants[1]]
if args.extra:
extra_ant = Antenna(name='4', x=4, y=-1, t0=-6)
all_ants = ants + [extra_ant]

View file

@ -0,0 +1,208 @@
\documentclass[showdate=false]{beamer}
\usepackage[british]{babel}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage[backend=bibtex,style=trad-plain]{biblatex}
\usepackage{graphicx}
\graphicspath{{.}{../../figures/}}
\usepackage{todo}
\addbibresource{../../../bibliotheca/bibliography.bib}
% Disable Captions
\setbeamertemplate{caption}{\raggedright\small\insertcaption\par}
% Show Section overview at beginning of section
%\AtBeginSection[]
%{
% \begin{frame}<beamer>{Table of Contents}
% \tableofcontents[currentsection, currentsubsection, sectionstyle=show/shaded, subsectionstyle=hide]
% \end{frame}
%}
% no to navigation, yes to frame numbering
\beamertemplatenavigationsymbolsempty
\setbeamerfont{page number in head/foot}{size=\normalsize}
\setbeamertemplate{footline}[frame number]
\title[Beacon Timing]{Enhancing Timing Accuracy using Beacons}
\date{Oct 06, 2022}
\author{E.T. de Boone}
\begin{document}
\frame{\titlepage}
\begin{frame}{Enhancing time accuracy}
\begin{block}{}
Goal: $\sigma_t < 1\mathrm{ns}$
(enabling Radio Interferometry)
\end{block}
\begin{block}{Strategy}
\begin{itemize}
\item Simulating beacons
\item Characterising GNSS (GRAND)
\end{itemize}
\end{block}
\begin{block}{Current Timing Methods}
\begin{itemize}
\item GNSS (online) (GPS: $\sigma_t \leq 30 \mathrm{ns}$ $@95\%$ of the time)
\item Beacon (online/offline)
\end{itemize}
\end{block}
\end{frame}
% Antenna Setup
\section{Beacon}
\begin{frame}{Antenna Setup}
\begin{block}{}
Local time $i$ due to time delay $t_{\mathrm{d}i}$ and clock skew $\sigma_i$\\
\end{block}
\begin{figure}
\includegraphics<1>[width=0.8\textwidth]{beacon/antenna_setup_two.pdf}
\includegraphics<2>[width=0.8\textwidth]{beacon/antenna_setup_three.pdf}
\includegraphics<3->[width=0.8\textwidth]{beacon/antenna_setup_four.pdf}
\vspace{-2cm}
\end{figure}
\begin{equation*}
\Delta t'_{12} = t'_1 - t'_2 = \Delta t_{\mathrm{d}12} + \sigma_{12}
\end{equation*}
\onslide<2->\begin{equation*}
\sigma_{12} + \sigma_{23} + \sigma_{31} = 0
\end{equation*}
\end{frame}
\begin{frame}{Beacon properties}
%\Todo{Pulse vs Sine and why choose one over the other}
%Pulse:
% online only
% direct measurement of \sigma_i
%Sine:
% online and offline
% measurement of phase
% removable if f appropriate
%\begin{table}
% \centering
% \begin{tabular}{r|l|l}
% & Pulse & Sine \\
% \hline \\
% on/offline & online & online + offline \\
% measurement & $t'_i (= t_i + \sigma_i)$ & $\varphi'_i (= 2\pi (\frac{t'_i}{T}\mod 1))$ \\
% resolving & requires high sampling rate & tracelength dependent \\
% removable from trace & unsure & if $f$ appropriate \\
% \end{tabular}
%\end{table}
\begin{columns}[t]
\begin{column}{.45\textwidth}
\begin{block}{Pulse}
\begin{itemize}
\item online
\item $t'_i$ {\small $(= t_i + \sigma_i)$}
\item resolving requires high sampling rate
\end{itemize}
\end{block}
\end{column}
\hfill
\begin{column}{.45\textwidth}
\begin{block}{Sine}
\begin{itemize}
\item online + offline
\item $\varphi'_i$ {\small $(= 2\pi (ft'_i\mod 1))$}
\item resolving is tracelength dependent
\item removable from physics if $f$ appropriate
\end{itemize}
\end{block}
\end{column}
\end{columns}
\end{frame}
\subsection{Pulse}
\begin{frame}{Beacon: Pulse (single baseline)}
\begin{figure}
\includegraphics<1>[width=\textwidth]{beacon/field_single_center_time.pdf}
\includegraphics<2>[width=\textwidth]{beacon/field_single_left_time.pdf}
\end{figure}
\end{frame}
\begin{frame}{Beacon: Pulse (3 baselines)}
\begin{figure}
\includegraphics<1>[width=\textwidth]{beacon/field_three_center_time.pdf}
\includegraphics<2>[width=\textwidth]{beacon/field_three_left_time.pdf}
\end{figure}
\end{frame}
\begin{frame}{Beacon: Pulse (multi baseline)}
\begin{figure}
\includegraphics<1>[width=\textwidth]{beacon/field_square_ref0_time.pdf}
\includegraphics<2>[width=\textwidth]{beacon/field_square_all_time.pdf}
\end{figure}
\end{frame}
\subsection{Sine}
\begin{frame}{Beacon: Sine (single baseline)}
\begin{figure}
\includegraphics<1>[width=\textwidth]{beacon/field_single_center_phase.pdf}
\includegraphics<2>[width=\textwidth]{beacon/field_single_left_phase.pdf}
\end{figure}
\end{frame}
\begin{frame}{Beacon: Sine (3 baseline)}
\begin{figure}
\includegraphics<1>[width=\textwidth]{beacon/field_three_center_phase.pdf}
\includegraphics<2>[width=\textwidth]{beacon/field_three_left_phase.pdf}
\end{figure}
\end{frame}
\begin{frame}{Beacon: Sine (multi baseline reference antenna)}
\begin{figure}
\includegraphics<1>[width=\textwidth]{beacon/field_square_ref0_phase.pdf}
\includegraphics<2>[width=\textwidth]{beacon/field_square_ref0_phase_zoomtx.pdf}
\end{figure}
\end{frame}
\begin{frame}{Beacon: Sine (all baselines)}
\begin{figure}
\includegraphics<1>[width=\textwidth]{beacon/field_square_all_phase.pdf}
\includegraphics<2>[width=\textwidth]{beacon/field_square_all_phase_zoomtx.pdf}
\end{figure}
\end{frame}
\subsection{Solving Sine Beacon}
\begin{frame}{Beacon: Sine: Two traces}
\begin{equation*}
t'_i = (\frac{\varphi'_i}{2\pi} + n_i)T = A_i + B_i
\end{equation*}
\begin{figure}
\includegraphics[width=1\textwidth]{beacon/08_beacon_sync_timing_outline.pdf}
\end{figure}
\begin{align*}
\Delta t_{ij} &= (A_j + B_j) - (A_i + B_i) + \Delta t_\varphi \\
&= \Delta A_{ij} + \Delta t_\varphi + k_{ij}T\\
\end{align*}
\end{frame}
\begin{frame}{Beacon: Sine: Two traces: Discrete solutions}
\begin{figure}
\includegraphics<1>[width=1\textwidth]{beacon/08_beacon_sync_timing_outline.pdf}
\includegraphics<2>[width=1\textwidth]{beacon/08_beacon_sync_synchronised_period_alignment.pdf}
\end{figure}
\begin{figure}
\includegraphics[width=1\textwidth]{beacon/08_beacon_sync_coherent_sum.pdf}
\end{figure}
\end{frame}
\begin{frame}{Work in Progress}
\begin{block}{Repeat analysis on simulated airshower (without noise)}
\begin{enumerate}
\item Add beacon to each antenna
\item Assign clock offsets
\end{enumerate}
then determine the relative offsets between the antennas
\end{block}
\end{frame}
\end{document}

View file

@ -0,0 +1,24 @@
# vim:ft=make
-include config.mk
.PHONY: all clean dist-clean
### Variables
MAIN_SRC ?= main.tex
TEXENGINE ?= latexmk --pdf
MAIN_TARGET = $(patsubst %.tex,%.pdf,$(MAIN_SRC))
### Targets
all: $(MAIN_TARGET)
dist: all clean
$(MAIN_TARGET): $(MAIN_SRC)
$(TEXENGINE) $^
dist-clean: clean
@rm -vf *.pdf *.eps *.dvi *.ps
clean:
@rm -vf *.dat *.log *.out *.aux *.nav *.snm *.toc *.vrb *~ *.fls *.fdb_latexmk *-blx.bib *.bbl *.blg *.run.xml

View file

@ -0,0 +1,8 @@
# Short Presentation on current status (Beacon)
Mostly to show what I've been doing uptil now.
### Outline
* Timing Mechanisms (GNSS, Beacon)
* Geometry of testing Tx and Antennas

View file

@ -0,0 +1 @@
MAIN_SRC=2022-10-06_CRHEP.tex