\documentclass[../thesis.tex]{subfiles}

\graphicspath{
	{.}
	{../../figures/}
	{../../../figures/}
}

\begin{document}
\chapter{Single Sine Beacon Synchronisation and Radio Interferometry}
\label{sec:single_sine_sync}

As shown in Chapter~\ref{sec:disciplining}, both impulsive and sine beacon signals can synchronise air shower radio detectors to enable the interferometric reconstruction of extensive air showers.
\\
% period multiplicity/degeneracy
For the sine beacon, its periodicity might pose a problem depending on its frequency to fully synchronise two detectors.
This is expressed as the unknown period counter $\Delta k$ in \eqref{eq:synchro_mismatch_clocks_periodic}.
\Todo{copy equation here?}
\\
Since the clock defect in \eqref{eq:synchro_mismatch_clock} still applies, it can be resolved by declaring a shared time $\tTrueEmit$ common to the stations in some fashion (e.g.~a~pulse), and counting the cycles since $\tTrueEmit$ per station.
\\

% Same transmitter / Static setup
When the signal defining $\tTrueEmit$ is emitted from the same transmitter that sends out the beacon signal, the number of periods $k$ can be obtained directly from the signal.
If, however, this calibration signal is sent from a different location, the time delays for this signal are different from the time delays for the beacon.
In a static setup, these distances should be measured to have a time delay accuracy of less than one period of the beacon signal.\todo{reword sentence}
\\

% Dynamic setup
If measuring the distances to the required accuracy is not possible, a different method must be found to obtain the correct number of periods.
The total time delay in \eqref{eq:phase_diff_to_time_diff} contains a continuous term $\Delta t_\phase$ that can be determined from the beacon signal, and a discrete term $k T$ where $k$ is the unknown discrete quantity.
\\
Since $k$ is discrete, the best time delay might be determined from the calibration signal by calculating the correlation for discrete time delays $kT$.
\begin{equation}\label{eq:sine:dynamic_correlation}
\end{equation}
\Todo{write argmax correlation equation}
\\

\begin{figure}
	\begin{subfigure}{\textwidth}
		\includegraphics[width=\textwidth]{beacon/08_beacon_sync_timing_outline.pdf}
		\caption{
			Measure two waveforms at different antennas at approximately the same local time (clocks are not synchronised).
		}
		\label{fig:beacon_sync:timing_outline}
	\end{subfigure}
	\begin{subfigure}{\textwidth}
		\includegraphics[width=\textwidth]{beacon/08_beacon_sync_synchronised_outline.pdf}
		\caption{
			The beacon signal is used to remove time differences smaller than the beacon's period.
			The detector clocks are now an unknown amount of periods out of sync.
		}
		\label{fig:beacon_sync:syntonised}
	\end{subfigure}
	\begin{subfigure}{\textwidth}
		\includegraphics[width=\textwidth]{beacon/08_beacon_sync_synchronised_period_alignment.pdf}
		\caption{
			Lifting period degeneracy ($k=n-m=7$ periods) using the optimal overlap between impulsive signals.
			\Todo{note misaligned overlap due to different locations}
		}
		\label{fig:beacon_sync:period_alignment}
	\end{subfigure}
	\caption{
		Synchronisation scheme for two antennas using a continuous beacon and an impulsive signal, each emitted from a separate transmitter.
		Grey dashed lines indicate periods of the beacon (orange),
		full lines indicate the time of the impulsive signal (blue).
		\\
		\textit{Middle panel}: The beacon allows to resolve a small timing delay ($\Delta t_\phase$).
		\\
		\textit{Lower panel}: Expecting the impulsive signals to come from the same source, the overlap between the two impulsive signals is used to lift the period degeneracy ($k=n-m$).
	}
	\label{fig:beacon_sync:sine}
	\Todo{
		Redo figure without xticks and spines,
		rename $\Delta t_\phase$,
		also remove impuls time diff?
	}
\end{figure}


\section{Lifting the Period Degeneracy with an Air Shower}% <<<

% Airshower gives t0
In the case of radio detection of air showers, the very signal of the air shower itself can be used as the calibration signal.
This falls into the dynamic setup described previously where the best period $k$ is determined by correlating waveforms of two detectors with multiple time delays $kT$.
When doing the interferometric analysis, waveforms can only be delayed by an integer amount of periods, thereby giving discrete solutions to maximizing the itner\Todo{senetenec}
\\

% simulation of proton E15 on 10x10 antenna
To test the idea of combining a single sine beacon with an air shower, we simulate a set of recordings of one air shower that also contains a beacon signal.
\\
We let \gls{ZHAires} run a simulation of a $10^{16}\eV$ proton on a grid of 10x10 antennas with a spacing of $?$\,meters (see Figure~\ref{fig:single:proton}).\Todo{verify numbers in paragraph}
Each antenna recorded a waveform of a length of $N$ samples with a sample rate of $1\GHz$.
Figure~\ref{fig:single:proton_waveform} shows the earliest and latest waveforms recorded by the antennas with their true time.
\\
%% add beacon
We introduce a sine beacon ($\fbeacon = 51.53\MHz$) at a distance of approximately $75\mathrm{\,km}$ northwest of the array.
The distance between the antenna and the transmitter results in a phase offset with which the beacon is received at each antenna.
\footnote{The beacon's amplitude is also dependent on the distance. Altough simulated, the effect has not been incorporated in the analysis; it is neglible for the considered distance and the simulated grid}
To be able to distinghuish the beacon and the air shower later in the analysis, the beacon is recorded over a longer period, both prepending and appending times to the air shower waveform's time.\Todo{rephrase}
\\
The final waveform of an antenna (see Figure~\ref{fig:single:annotated_waveform}) is then constructed by adding its beacon and air shower waveforms and bandpassing with relevant frequencies (here $30$ and $80\MHz$ are taken by default).
Of course, a gaussian white noise component can be introduced to the waveform as a simple noise model.
\\

\begin{figure}
	\begin{subfigure}{0.47\textwidth}
		\includegraphics[width=\textwidth]{ZH_simulation/array_geometry_shower_amplitude.pdf}
		\caption{}
		\label{fig:single:proton_grid}
	\end{subfigure}
	\begin{subfigure}{0.47\textwidth}
		\includegraphics[width=\textwidth]{ZH_simulation/first_and_last_simulated_traces.pdf}
		\caption{}
		\label{fig:single:proton_waveform}
	\end{subfigure}
	\caption{
		\textit{Left:}
		The 10x10 antenna grid used for recording the air shower.
		Colours indicate the maximum electric field recorded at the antenna.
		\textit{Right:}
		Example of the earliest and latest recorded air shower waveforms in the array as simulated by ZHAires.
	}
	\label{fig:single:proton}
\end{figure}


\begin{figure}
	\includegraphics[width=0.5\textwidth]{ZH_simulation/ba_measure_beacon_phase.py.A74.no_mask.zoomed.pdf}
	\caption{
		Excerpt of a fully simulated waveform containing the air shower, the beacon and noise.
	}
	\label{fig:single:annotated_full_waveform}
\end{figure}

% randomise clocks
After the creation of the antenna waveforms, the clocks are randomised up to $30\ns$ by sampling a gaussian distribution.
At a beacon period of $\sim 20\ns$, this ensures that multiple antennas have clock defects of at least one beacon period.
This in turn allows for synchronisation mismatches of more than one beacon period.
Additionally, it falls in the order of magnitude of clock defects that were found in \gls{AERA}\cite{PierreAuger:2015aqe}.
\\

% separate air shower from beacon
To correctly recover the beacon from the waveform, the air shower must first be masked.
In Figure~\ref{fig:single:annotated_full_waveform} it is readily identified as the peak.
Since the beacon can be recorded for much longer than the air shower signal, a relatively large window (here 500 samples) around the maximum of the trace can be designated as the air shower's signal.
% measure beacon phase, remove distance phase
The remaining waveform is fed into a \gls{DTFT} to measure the beacon's phase $\pMeas$ and amplitude.
\\
The beacon affects the measured air shower signal in the frequency domain.
Because the beacon parameters are recovered from the \gls{DTFT}, we can subtract the beacon from the full waveform in the time domain to reconstruct the air shower signal.
\\
The (small) clock defect $\tSmallClock$ is then finally calculated from the beacon's phase $\pMeas$ by subtracting the phase $\pProp$ introduced by the propagation from the transmitter.
\\
% introduce air shower
From the above, we now have a set of air shower waveforms with corresponding clock defects smaller than one beacon period $T$.
Shifting the waveforms to remove these small clocks defects, we are left with resolving the correct number of periods $k$ per waveform.
\\

\subsection{k-finding}

% unknown origin of air shower signal
The shower axis and thus the origin of the air shower signal here are not fully resolved yet.\Todo{qualify?}
This means that the unknown propagation time delays for the air shower $\tProp$ affect the alignment of the signals in Figure~\ref{fig:beacon_sync:period_alignment} in addition to the unknown clock period defects $kT$.
As such, both this origin and the clock defects $kT$ have to be found simultaneously.
\\
% radio interferometry
If the antennas had been fully synchronised, radio interferometry as introduced in Section~\ref{sec:interferometry} would have been applied to find the origin of the air shower signal, thus resolving the shower axis.
Still, a rough estimate of the shower axis might be made using this or other techniques.
\\
In the case of synchronisation mismatches, the approach must be modified to both zoom in on the shower axis and finding the remaining synchronisation defects $kT$.
This is accomplished in a two-step process by zooming in on the shower axis while optimising the interferometric signal wherein each waveform of the array is allowed to shift by some amount of periods.
\\

\begin{figure}
	\centering
	\includegraphics[width=0.8\textwidth]{ZH_simulation/findks/ca_period_from_shower.py.run0.i1.kfind.zoomed.peak.pdf}
	\caption{
		Finding the maximum correlation for integer period shifts (up to $k=3$) between two waveforms recording the same (simulated) air shower.
		Randomising the antenna clocks up to $30\ns$ and $\fbeacon = 51.53\MHz$ corresponds to at most $3$ periods of time difference between two waveforms.
		\Todo{location origin}
	}
	\label{fig:single:k-correlation}
\end{figure}

At each location, after removing propagation delays, a waveform and a reference waveform are summed with a restricted time delay $kT$ ($\left| k\right| \leq 3$ in Figure~\ref{fig:single:k-correlation}) to find the maximum amplitude of this combined trace.
The time delay corresponding to the highest maximum amplitude is taken as a proxy to maximizing the interferometric signal.
The reference waveform here is taken to be the waveform with the highest maximum.\Todo{why}
\footnote{
	Note that one could opt for selecting the best time delay using a correlation method instead of the maximum of the summed waveforms.
	However, for simplicity and ease of computation, this has not been implemented.
}
%\Todo{incomplete p}
%As shown in Figure~\ref{fig:single:annotated_full_waveform}, the air shower signal has a length in the order of a few nanoseconds.
%Since it is this peak that is of interest, it would have been possible to cut the waveforms such to only correlate the peaks.
\\

% 
This amplitude optimisation is iterated over the grid (see Figure~\ref{fig:findks:maxima}) resulting in a grid measurement with a set of period defects $k$ and the corresponding maximum amplitude of the total sum of the shifted waveforms per location.
Here, we take the true period defects to be best approximated by the set of $k$'s belonging to the overall maximum amplitude.
\\

The second step then consists of measuring the interferometric power on the same grid after shifting the waveforms with the previously obtained period defects (see Figure~\ref{fig:findks:reconstruction}).
Afterwards, a new grid is constructed zooming in on the power maximum and the process is repeated (Figures~\ref{fig:findks:maxima:zoomed} and \ref{fig:findks:reconstruction:zoomed}) until the set of period defects does not change.
\\
Typically, grid spacings below $v/\fbeacon$ (here roughly $6\mathrm{\,meters}$) will not show large deviations from the set.\Todo{rephrase or remove}


\begin{figure}
	\begin{subfigure}{0.45\textwidth}
		\includegraphics[width=\textwidth]{ZH_simulation/findks/ca_period_from_shower.py.maxima.run0.pdf}
		\caption{
			Combined amplitude maxima near shower axis
		}
		\label{fig:findks:maxima}
	\end{subfigure}
	\hfill
	\begin{subfigure}{0.45\textwidth}
		\includegraphics[width=\textwidth]{ZH_simulation/findks/ca_period_from_shower.py.reconstruction.run0.power.pdf}
		\caption{
			Power measurement near shower axis with the $k$s belonging to the overall maximum of the amplitude maxima.
			\Todo{indicate maximum in plot, square figure}
		}
		\label{fig:findks:reconstruction}
	\end{subfigure}
	\\
	\begin{subfigure}{0.45\textwidth}
		\includegraphics[width=\textwidth]{ZH_simulation/findks/ca_period_from_shower.py.maxima.run1.pdf}
		\caption{
			Maxima near shower axis, zoomed to the location in \ref{fig:findks:reconstruction} with the highest amplitude.
		}
		\label{fig:findks:maxima:zoomed}
	\end{subfigure}
	\hfill
	\begin{subfigure}{0.45\textwidth}
		\includegraphics[width=\textwidth]{ZH_simulation/findks/ca_period_from_shower.py.reconstruction.run1.power.pdf}
		\caption{
			Power measurement of new grid.
		}
		\label{}
	\end{subfigure}
	\caption{
		Iterative $k$-finding algorithm:
		First, in the \textit{upper left pane}, find the set of period shifts $k$ per point that returns the highest maximum amplitude.
		Second, in the \textit{upper right pane}, perform the interferometric reconstruction with this set of period shifts.
		Finally, in the \textit{lower panes}, zooming in on the maximum power of the reconstruction, repeat the steps until the set of period shifts does not change.
		\Todo{axis labels alike power measurement}
	}
	\label{fig:findks}
\end{figure}

\section{Result}

In Figure~\ref{fig:simu:sine:periods}, the effect of various stages of array synchronisation on the alignment of the waveforms is shown.


\begin{figure}
	\begin{subfigure}{0.45\textwidth}
		\includegraphics[width=\textwidth]{radio_interferometry/trace_overlap/on-axis/dc_grid_power_time_fixes.py.repair_none.axis.trace_overlap.repair_none.pdf}
		\caption{
			Randomised clocks
		}
		\label{fig:simu:sine:period:repair_none}
	\end{subfigure}
	\hfill
	\begin{subfigure}{0.45\textwidth}
		\includegraphics[width=\textwidth]{radio_interferometry/trace_overlap/on-axis/dc_grid_power_time_fixes.py.repair_phases.axis.trace_overlap.repair_phases.pdf}
		\caption{
			Clock syntonisation
		}
		\label{fig:simu:sine:period:repair_phases}
	\end{subfigure}
	\\
	\begin{subfigure}{0.45\textwidth}
		\includegraphics[width=\textwidth]{radio_interferometry/trace_overlap/on-axis/dc_grid_power_time_fixes.py.no_offset.axis.trace_overlap.no_offset.pdf}
		\caption{
			True clocks
		}
		\label{fig:simu:sine:periods:no_offset}
	\end{subfigure}
	\hfill
	\begin{subfigure}{0.45\textwidth}
		\includegraphics[width=\textwidth]{radio_interferometry/trace_overlap/on-axis/dc_grid_power_time_fixes.py.repair_full.axis.trace_overlap.repair_full.pdf}
		\caption{
			Fully resolved clocks
		}
		\label{fig:simu:sine:periods:repair_full}
	\end{subfigure}
	\caption{
		Trace overlap for a position on the true shower axis for different stages of array synchronisation.
		\Todo{x-axis relative to reference waveform}
	}
	\label{fig:simu:sine:periods}
\end{figure}


\begin{figure}
	\begin{subfigure}{0.45\textwidth}
		\includegraphics[width=\textwidth]{radio_interferometry/dc_grid_power_time_fixes.py.X400.repair_none.scale4d.pdf}
		\caption{
			Randomised clocks
		}
		\label{fig:grid_power:repair_none}
	\end{subfigure}
	\hfill
	\begin{subfigure}{0.45\textwidth}
		\includegraphics[width=\textwidth]{radio_interferometry/dc_grid_power_time_fixes.py.X400.repair_phases.scale4d.pdf}
		\caption{
			Clock syntonisation
		}
		\label{fig:grid_power:repair_phases}
	\end{subfigure}
	\\
	\begin{subfigure}{0.5\textwidth}
		\includegraphics[width=\textwidth]{radio_interferometry/dc_grid_power_time_fixes.py.X400.no_offset.scale4d.pdf}
		\caption{
			True clocks
		}
		\label{fig:grid_power:no_offset}
	\end{subfigure}
	\hfill
	\begin{subfigure}{0.5\textwidth}
		\includegraphics[width=\textwidth]{radio_interferometry/dc_grid_power_time_fixes.py.X400.repair_all.scale4d.pdf}
		\caption{
			Full resolved clocks
		}
		\label{fig:grid_power:repair_full}
	\end{subfigure}
	\caption{
		Power measurements near the simulation axis with varying degrees of clock deviations.
		\Todo{square brackets labels}
	}
	\label{fig:grid_power_time_fixes}
\end{figure}
% >>>
\end{document}
