2022-07-11 11:29:38 +02:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"# Beacon Sync\n",
|
|
|
|
"\n",
|
|
|
|
"Synchronise two delta peaks, by using an intermediate beacon that was sent out together with it."
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 1,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"import numpy as np\n",
|
|
|
|
"import matplotlib.pyplot as plt\n",
|
|
|
|
"import scipy.signal as signal\n",
|
2022-08-04 17:22:54 +02:00
|
|
|
"\n",
|
|
|
|
"import os\n",
|
|
|
|
"import sys\n",
|
|
|
|
"# Append parent directory to import path so lib can be found\n",
|
|
|
|
"sys.path.append(os.path.dirname(os.path.abspath(os.getcwd())))\n",
|
|
|
|
"from lib.util import *\n",
|
2022-08-05 12:16:19 +02:00
|
|
|
"from lib.plotting import *\n",
|
2022-08-05 14:39:28 +02:00
|
|
|
"from lib.timing import *\n"
|
2022-07-11 11:29:38 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 2,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2022-08-01 15:17:24 +02:00
|
|
|
"Beacon period [ns]: 14.285714285714285\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
"Beacon initial [ns]: 4.4\n",
|
|
|
|
"Beacon initial [phase]: 1.9352210746113125\n",
|
2022-08-05 14:26:40 +02:00
|
|
|
"Beacon initial [idx]: 2.2\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
"Beacon difference [ns]: 8.571428571428571\n",
|
|
|
|
"Beacon difference [phase]: 3.7699111843077517\n",
|
2022-08-05 18:09:47 +02:00
|
|
|
"Impulse offsets [ns]: [ 64. 178.]\n",
|
|
|
|
"Time difference Impulses [ns]: 113.99999999999999\n",
|
|
|
|
"Time difference Impulses [T]: 7.9799999999999995\n"
|
2022-07-11 11:29:38 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"us = 1e3 # ns\n",
|
|
|
|
"ns = 1/us # us\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"band = (30, 80) # MHz\n",
|
2022-08-05 14:26:40 +02:00
|
|
|
"samplerate = 500 # MHz\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
"timelength = 0.2 # us\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"\n",
|
|
|
|
"time = np.arange(0, timelength, 1/samplerate)\n",
|
|
|
|
"\n",
|
|
|
|
"# generate beacons\n",
|
|
|
|
"if True: # in-band\n",
|
|
|
|
" f_beacon = 70 # MHz\n",
|
|
|
|
"else: # under band\n",
|
|
|
|
" f_beacon = 20 # MHz\n",
|
|
|
|
"\n",
|
|
|
|
"beacon_amplitude = 0.1\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
"beacon_init_phase = time2phase(4.4*ns, f_beacon)\n",
|
|
|
|
"beacon_phase_offset = 1.2*np.pi\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"\n",
|
|
|
|
"beacons = np.array([\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
" beacon_amplitude * sin_delay(f_beacon, time, t_delay=0, phase=-beacon_init_phase),\n",
|
|
|
|
" beacon_amplitude * sin_delay(f_beacon, time, t_delay=0, phase=-beacon_init_phase-beacon_phase_offset)\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"])\n",
|
|
|
|
"\n",
|
2022-08-01 15:17:24 +02:00
|
|
|
"\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"# generate impulses\n",
|
|
|
|
"impulses = []\n",
|
|
|
|
"impulses_offsets = []\n",
|
2022-08-01 15:17:24 +02:00
|
|
|
"impulses_def_offsets = [\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
" (0.3*len(time),0.4*len(time)),\n",
|
2022-08-05 12:16:19 +02:00
|
|
|
" (0.5*len(time),0.9*len(time)),\n",
|
2022-08-01 15:17:24 +02:00
|
|
|
" ]# random offsets in interval\n",
|
2022-08-05 18:09:47 +02:00
|
|
|
"if True:\n",
|
2022-08-05 12:16:19 +02:00
|
|
|
" # freeze impulses\n",
|
|
|
|
" impulses_def_offsets = [\n",
|
2022-08-05 18:09:47 +02:00
|
|
|
" 0.064*samplerate,\n",
|
|
|
|
" 0.178*samplerate \n",
|
2022-08-05 12:16:19 +02:00
|
|
|
" ]\n",
|
|
|
|
" \n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"for i in range(2):\n",
|
|
|
|
" offset = None\n",
|
|
|
|
" if impulses_def_offsets:\n",
|
|
|
|
" if len(impulses_def_offsets) == 1:\n",
|
|
|
|
" offset = impulses_def_offsets[0]\n",
|
|
|
|
" else:\n",
|
|
|
|
" offset = impulses_def_offsets[i]\n",
|
|
|
|
" orig_imp, imp_offset = deltapeak(timelength, samplerate, offset=offset, peaklength=1)\n",
|
|
|
|
"\n",
|
2022-08-05 18:09:47 +02:00
|
|
|
" orig_imp[imp_offset] = 0.1\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
" ## Bandpass it\n",
|
|
|
|
" imp, _ = fft_bandpass(orig_imp, band, samplerate)\n",
|
|
|
|
" imp /= np.max(imp)\n",
|
|
|
|
" \n",
|
|
|
|
" impulses.append(imp)\n",
|
|
|
|
" impulses_offsets.append(imp_offset/samplerate)\n",
|
|
|
|
"\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
"impulses = np.array(impulses)\n",
|
|
|
|
"impulses_offsets = np.array(impulses_offsets)\n",
|
2022-08-01 15:17:24 +02:00
|
|
|
"print(\"Beacon period [ns]:\", 1/f_beacon/ns)\n",
|
|
|
|
"print(\"Beacon initial [ns]:\", phase2time(beacon_init_phase, f_beacon) /ns)\n",
|
|
|
|
"print(\"Beacon initial [phase]:\", beacon_init_phase)\n",
|
|
|
|
"print(\"Beacon initial [idx]:\", phase2time(beacon_init_phase, f_beacon)*samplerate)\n",
|
|
|
|
"print(\"Beacon difference [ns]:\", phase2time(beacon_phase_offset, f_beacon)/ns)\n",
|
|
|
|
"print(\"Beacon difference [phase]:\", beacon_phase_offset)\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"print(\"Impulse offsets [ns]:\", impulses_offsets[:,0]/ns)\n",
|
2022-08-04 17:22:54 +02:00
|
|
|
"print(\"Time difference Impulses [ns]: {}\".format( (impulses_offsets[1,0]-impulses_offsets[0,0])/ns ))\n",
|
|
|
|
"print(\"Time difference Impulses [T]: {}\".format( (impulses_offsets[1,0]-impulses_offsets[0,0])*f_beacon ))"
|
2022-07-11 11:29:38 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-08-05 12:16:19 +02:00
|
|
|
"execution_count": 3,
|
2022-07-11 11:29:38 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"full_signals = impulses + beacons"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-08-05 12:16:19 +02:00
|
|
|
"execution_count": 4,
|
2022-07-11 11:29:38 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
2022-08-05 18:09:47 +02:00
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAArkAAAEHCAYAAACqdl4sAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOzdd1hUV+L/8feZGXoT6YiCghQr2LuJJcUU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QkJ4f/ee5/Y+GSmXDkf82WPo9frO71NFwcDE0O92HAol6ev7lzfXkVRFEXpjdozu8KfgL8DOYCl7mUJjGh1JRtz8mQ1b7zxBgaDgaqqKj777LOejtSqyspKQJtf1haovF0vv7gMWVvN7jWfkfaHmwkNDT2v7c2K8uWvPyRxNK+MUB/XLkqpKIqiKD2rvbMrREgpL9hHZQQHO1FcXMy7777LsmXLCAwM5LnnnuvWx8m2V/3tBlsZKanydp2EhASeeuopcuJT6H/5PaR88QInT2ac93ZnRPnx1x+SWJ+cQ+h0VclVFEVRLgztqeRmAMXWDtJTfH3vAMDBwYEHHniAu+++m3fffZeffvqpV1Zyvbxsa3CQytt1fv75Z2bNvpyjI+5l7uhgnJ2duiRvvz5ORAW4syEll/umn1+r8Ln05v3bEpXXumwpry1lBZXX2lRe2yCklG0vIMS7QATwI1Bd/7qU8uXW1hkzZoyMjY3tqoyKotTZdiSPO97dy7sLxzAzyq/NZQ8cuASAmJjN59zuy2sPs3xTKvueno2
|
2022-07-11 11:29:38 +02:00
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 864x288 with 3 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"# Make a figure showing two signals with a beacon per signal\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
"colors = ['y','g']\n",
|
|
|
|
"multiplier_name = ['m','n']\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"fig, axes = plt.subplots(3,1, sharex=True, figsize=(12,4))\n",
|
|
|
|
"axes[-1].set_xlabel(\"Time [ns]\")\n",
|
2022-08-01 15:17:24 +02:00
|
|
|
"axes[-1].set_yticks([],[])\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"for i in range(0, 2):\n",
|
2022-08-01 15:17:24 +02:00
|
|
|
" axes[i].set_yticks([],[])\n",
|
|
|
|
" axes[i].set_ylabel(\"Antenna {:d}\".format(i+1))\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
" axes[i].plot(time/ns, impulses[i])\n",
|
|
|
|
" axes[i].plot(time/ns, beacons[i], marker='.')\n",
|
2022-08-01 15:17:24 +02:00
|
|
|
" if not True:\n",
|
|
|
|
" axes[i].plot(time/ns, full_signals[i])\n",
|
|
|
|
"\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"\n",
|
|
|
|
"# indicate timing of pulses\n",
|
|
|
|
"for i, impulse_offset in enumerate(impulses_offsets):\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
" kwargs = dict(color=colors[i])\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
" [ax.axvline(impulse_offset/ns, **kwargs) for ax in (axes[i], axes[-1])]\n",
|
|
|
|
"\n",
|
2022-08-01 15:17:24 +02:00
|
|
|
"\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"# indicate timing of the beacons\n",
|
2022-08-01 15:17:24 +02:00
|
|
|
"# and annotate ticks and impulse widths\n",
|
|
|
|
"tmp_beacon_phases = beacon_init_phase + np.arange(0,2)*beacon_phase_offset\n",
|
2022-08-05 12:16:19 +02:00
|
|
|
"if True: # mod phases\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
" tmp_beacon_phases %= 2*np.pi\n",
|
|
|
|
"tmp_beacon_offsets = phase2time(tmp_beacon_phases, f_beacon)\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"A = np.empty(2)\n",
|
|
|
|
"B = np.empty(2)\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"for i in range(0,2):\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
" kwargs = dict(color=colors[i], ls=(0, (3,2)))\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
" tick_kwargs = dict(color='k', alpha=0.2)\n",
|
|
|
|
"\n",
|
|
|
|
" # indicate every period of the beacon\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
" beacon_ticks = tmp_beacon_offsets[i] + [(n)*1/f_beacon for n in range(1+int((time[-1] - time[0]) * f_beacon))]\n",
|
|
|
|
"\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
" [axes[i].axvline(tick/ns, **{**kwargs, **tick_kwargs}) for tick in beacon_ticks]\n",
|
|
|
|
"\n",
|
|
|
|
" # reference period in beacon\n",
|
2022-08-01 15:17:24 +02:00
|
|
|
" [ax.axvline(tmp_beacon_offsets[i]/ns, **kwargs) for ax in (axes[i], axes[-1])]\n",
|
|
|
|
"\n",
|
|
|
|
" # annotate width between impulse and closest beacon tick\n",
|
|
|
|
" # and closest beacon tick and reference tick\n",
|
|
|
|
" closest_beacon_tick_id = np.argmin(np.abs(beacon_ticks-impulses_offsets[i]))\n",
|
|
|
|
" if closest_beacon_tick_id != 0 and beacon_ticks[closest_beacon_tick_id] > impulses_offsets[i]:\n",
|
|
|
|
" closest_beacon_tick_id -= 1\n",
|
|
|
|
" closest_beacon_tick = beacon_ticks[closest_beacon_tick_id]\n",
|
|
|
|
"\n",
|
|
|
|
" annotate_width(axes[i], f\"$A_{i+1}$\", closest_beacon_tick/ns, impulses_offsets[i]/ns, 0.7)\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
" annotate_width(axes[i], f\"$B_{i+1}={multiplier_name[i]}T$\", closest_beacon_tick/ns, tmp_beacon_offsets[i]/ns, 0.4)\n",
|
|
|
|
"\n",
|
|
|
|
" A[i] = closest_beacon_tick - impulses_offsets[i]\n",
|
|
|
|
" B[i] = closest_beacon_tick - tmp_beacon_offsets[i]\n",
|
2022-08-01 15:17:24 +02:00
|
|
|
"\n",
|
|
|
|
"# annotate width between beacon reference periods\n",
|
|
|
|
"annotate_width(axes[-1], \"$t_\\phi$\", tmp_beacon_offsets[0]/ns, tmp_beacon_offsets[-1]/ns, 0.4)\n",
|
|
|
|
"\n",
|
|
|
|
"# annotate width between pulses\n",
|
|
|
|
"annotate_width(axes[-1], \"$\\Delta t$\", impulses_offsets[0]/ns, impulses_offsets[-1]/ns, 0.4)\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
"fig.show()\n",
|
|
|
|
"if False:\n",
|
2022-08-01 17:23:27 +02:00
|
|
|
" fname = 'figures/08_beacon_sync_timing_outline'\n",
|
|
|
|
"\n",
|
|
|
|
" # Dump figure\n",
|
|
|
|
" fig.savefig(fname +'.pdf')\n",
|
|
|
|
" \n",
|
|
|
|
" # Dump information into accompanying file\n",
|
|
|
|
" with open(fname + '.dat', 'w+') as fp:\n",
|
|
|
|
" fp.write(\"f_beacon = {}MHz\\n\".format(f_beacon))\n",
|
|
|
|
" fp.write(\"samplerate = {}\\n\".format(samplerate))\n",
|
|
|
|
" fp.write(\"band = {}MHz\\n\".format(band))\n",
|
|
|
|
" fp.write(\"timelength = {}us\\n\".format(timelength))\n",
|
|
|
|
" \n",
|
|
|
|
" fp.write(\"-\"*8 + \"\\n\")\n",
|
|
|
|
" fp.write(\"\\Delta t = {}ns\\n\".format( (impulses_offsets[1][0] - impulses_offsets[0][0])/ns ))\n",
|
|
|
|
" fp.write(\"t_phi = {}ns\\n\".format( (tmp_beacon_offsets[1]-tmp_beacon_offsets[0])/ns ))\n",
|
|
|
|
" fp.write(\"\\Delta A = {}ns\\n\".format( (A[1] - A[0])/ns ))\n",
|
|
|
|
" fp.write(\"kT = {}ns = {}T\\n\".format( (B[1]-B[0])/ns, (B[1]-B[0])*f_beacon ))\n",
|
|
|
|
" \n",
|
|
|
|
" fp.write(\"-\"*8 + \"\\n\")\n",
|
|
|
|
" fp.write(\"A_1 = {}ns\\n\".format( (A[0])/ns ))\n",
|
|
|
|
" fp.write(\"A_2 = {}ns\\n\".format( (A[1])/ns ))\n",
|
|
|
|
" fp.write(\"B_1 = {}ns = {}T\\n\".format( (B[0])/ns, (B[0]*f_beacon) ))\n",
|
|
|
|
" fp.write(\"B_2 = {}ns = {}T\\n\".format( (B[1])/ns, (B[1]*f_beacon) ))"
|
2022-08-01 17:03:26 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-08-05 12:16:19 +02:00
|
|
|
"execution_count": 5,
|
2022-08-01 17:03:26 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2022-08-05 18:09:47 +02:00
|
|
|
"\\Delta t = 113.99999999999999ns\n",
|
|
|
|
"\\Delta A = -5.428571428571415ns\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
"t_phi = 8.571428571428573ns\n",
|
2022-08-05 18:09:47 +02:00
|
|
|
"B_1 = 57.14285714285714ns = 4.0T\n",
|
|
|
|
"B_2 = 157.14285714285714ns = 11.0T\n",
|
|
|
|
"kT = 100.0ns = 7.0T\n"
|
2022-08-01 17:03:26 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"t_phi = (tmp_beacon_offsets[1]-tmp_beacon_offsets[0])\n",
|
|
|
|
"Delta_A = (A[1] - A[0])\n",
|
|
|
|
"\n",
|
|
|
|
"print(\"\\Delta t = {}ns\".format( (impulses_offsets[1][0] - impulses_offsets[0][0])/ns ))\n",
|
|
|
|
"print(\"\\Delta A = {}ns\".format( Delta_A/ns ))\n",
|
|
|
|
"print(\"t_phi = {}ns\".format( t_phi/ns ))\n",
|
|
|
|
"print(\"B_1 = {}ns = {}T\".format( (B[0])/ns, (B[0]*f_beacon) ))\n",
|
|
|
|
"print(\"B_2 = {}ns = {}T\".format( (B[1])/ns, (B[1]*f_beacon) ))\n",
|
|
|
|
"print(\"kT = {}ns = {}T\".format( (B[1]-B[0])/ns, (B[1]-B[0])*f_beacon ))\n",
|
|
|
|
"\n"
|
2022-08-01 15:17:24 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
2022-08-01 17:03:26 +02:00
|
|
|
"$\n",
|
2022-08-01 15:17:24 +02:00
|
|
|
"\\Delta t = (A_2 + B_2) - (A_1 + B_1) + t_\\phi\\\\\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
"\\quad = (A_2 - A_1) + (B_2 - B_1) + t_\\phi\\\\\n",
|
|
|
|
"\\quad = (A_2 - A_1) + (nT - mT) + t_\\phi\\\\\n",
|
2022-08-05 18:09:47 +02:00
|
|
|
"\\quad = \\Delta A + t_\\phi + (kT) \n",
|
2022-08-01 17:03:26 +02:00
|
|
|
"$\n",
|
|
|
|
"\n",
|
2022-08-04 17:22:54 +02:00
|
|
|
", where $\\Delta A < T$ and $k \\in \\mathbb{Z}$ and $t_\\phi$ is minimisable by synchronising the beacons.\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
"\n",
|
|
|
|
"Then $\\Delta t$ can be determined by iteratively summing the signals, changing $k$, and finding the $k$ belonging to the maximum of the sums."
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-08-05 12:16:19 +02:00
|
|
|
"execution_count": 6,
|
2022-08-01 17:03:26 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2022-08-08 10:49:17 +02:00
|
|
|
"Best k: 7\n",
|
|
|
|
"Maximum: 2.0\n"
|
2022-08-01 17:03:26 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": {
|
2022-08-08 10:49:17 +02:00
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAtkAAAErCAYAAAAL/58RAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90b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/s08BReYNyMlfa92ngbMsb802YCbBHZCXwP8McNrv5HwFngd4BfAILAoQb3MQRMAkfX2p9SSvWLZrKVUqpzfsgY82URsfCCw6+IyFvxaqG31wLwOgv4qjHmtIh8FPglYJ+I/BXw08aYi03sbztwwRjjLrnsPDDezGBX2vdq423mftfwfuBvjTFnG4zn/wZv4qN31jvfwJ1AFi8gV0qpgaSZbKWU6jBjjGOM+QJepvidwAXgbG1yXv2UMMZ8f237PzXGvBMvuDXAb9Tvao1dXQQmauUddTuB6RbG2mjfq463iXGt5v00zmIvHdMfGWMOr7LJAeDYCuUmSik1EDTIVkqpDhPPIWAYeBl4BlioTTKMiIglIvtF5O213tXvqrWfK+F13XBqd3UFuGmVXX0DyAMfE5FAre3de4HPNznOlfa94nibHNdK+/u7eFn2v1hr2zUcQEtFlFIDToNspZTqnC+KSA6vJvtXgR81xpwwxjh4we8BvBKHq8BngCReTfSv1y67DGwG/kXt/n4N+Hitc8jPLt+ZMaYCPADcX7v97wPvN8a80uR4G+57jfE2HJeIfEpEPrXG/n4U+IIxJtvk+FZyJxpkK6UGnOjRNqWUUkoppTpLM9lKKaWUUkp1mAb
|
2022-08-01 17:03:26 +02:00
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 864x288 with 1 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"# Make figure showing the sums depending on k\n",
|
|
|
|
"ref_impulse = impulses[0]\n",
|
|
|
|
"my_impulse = impulses[1]\n",
|
|
|
|
"\n",
|
|
|
|
"# remove 'already determined' offsets\n",
|
|
|
|
"if True:\n",
|
|
|
|
" # $t_\\phi$ offset\n",
|
|
|
|
" my_impulse = time_roll(my_impulse, samplerate, -t_phi)\n",
|
|
|
|
"\n",
|
2022-08-08 10:49:17 +02:00
|
|
|
"if True:\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
" # $\\Delta A$ offset\n",
|
2022-08-04 17:22:54 +02:00
|
|
|
" my_impulse = time_roll(my_impulse, samplerate, +Delta_A)\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
"\n",
|
2022-08-05 18:09:47 +02:00
|
|
|
"best_k, (ks, maxima) = beacon_integer_period(samplerate, f_beacon, ref_impulse, my_impulse)\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
"print(\"Best k: {:0g}\".format(best_k))\n",
|
|
|
|
"print(\"Maximum: {}\".format(maxima[np.where(ks == best_k)][0]))\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Make figure\n",
|
|
|
|
"fig, axes = plt.subplots(1, 1, sharex=True,figsize=(12,4))\n",
|
|
|
|
"if not hasattr(axes, 'ndim'):\n",
|
|
|
|
" axes = [axes]\n",
|
|
|
|
"\n",
|
2022-08-05 18:09:47 +02:00
|
|
|
"axes[0].set_title(\"Coherent sum of impulses with $kT$ offsets.\\nBest offset: ${:.0f}*T$\".format(best_k))\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
"axes[-1].set_xlabel(\"Time [ns]\")\n",
|
|
|
|
"\n",
|
|
|
|
"if not True:\n",
|
|
|
|
" i=0\n",
|
|
|
|
" axes[i].set_ylabel(\"Reference\")\n",
|
|
|
|
" axes[i].plot(time/ns, ref_impulse, label=\"reference\")\n",
|
|
|
|
" axes[i].plot(time/ns, my_impulse, label='impulse')\n",
|
|
|
|
" axes[i].legend()\n",
|
|
|
|
"\n",
|
2022-08-04 17:22:54 +02:00
|
|
|
"axes[-1].set_ylabel(\"Coherence Sum\")\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
"\n",
|
|
|
|
"best_maximum = np.max(maxima)\n",
|
|
|
|
"axes[-1].axhline(best_maximum, alpha=0.7)\n",
|
|
|
|
"\n",
|
|
|
|
"for i, k in enumerate(ks, 0):\n",
|
|
|
|
" sample_offset = int(k*1/f_beacon*samplerate)\n",
|
|
|
|
" augmented_impulses = np.roll(my_impulse, sample_offset)\n",
|
|
|
|
" \n",
|
|
|
|
" summed_impulse = ref_impulse + augmented_impulses\n",
|
|
|
|
" if True or k%2 == 1:\n",
|
|
|
|
" axes[-1].plot(time/ns, summed_impulse, label='k={:.0f}'.format(k),\n",
|
2022-08-04 17:22:54 +02:00
|
|
|
" alpha=0.1 + 0.9*1/(1+2*abs(best_maximum-maxima[i]))\n",
|
2022-08-01 17:03:26 +02:00
|
|
|
" )\n",
|
|
|
|
" \n",
|
|
|
|
"axes[-1].legend()\n",
|
|
|
|
"fig.show()\n",
|
|
|
|
"\n",
|
|
|
|
"del ref_impulse\n",
|
|
|
|
"del my_impulse"
|
2022-07-11 11:29:38 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
2022-08-04 17:22:54 +02:00
|
|
|
"## 1. Solve it\n",
|
|
|
|
"\n",
|
|
|
|
" 1. Find $t_\\phi$\n",
|
2022-08-08 10:49:17 +02:00
|
|
|
" 2. Find $\\Delta A$\n",
|
|
|
|
" 3. Find $kT$"
|
2022-08-01 17:03:26 +02:00
|
|
|
]
|
|
|
|
},
|
2022-07-11 11:29:38 +02:00
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
2022-08-04 17:22:54 +02:00
|
|
|
"##### 1.1 Beacon Phase Delay ($t_\\phi$)"
|
2022-07-11 11:29:38 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-08-05 18:09:47 +02:00
|
|
|
"execution_count": 7,
|
2022-07-11 11:29:38 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2022-08-05 14:26:40 +02:00
|
|
|
"Beacon delays [ns] \\pm k*14.285714285714285ns: [0. 8.57142857]\n"
|
2022-07-11 11:29:38 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
2022-08-05 12:16:19 +02:00
|
|
|
"abs_beacon_time_delays_tmp = np.array([\n",
|
2022-08-05 14:26:40 +02:00
|
|
|
" beacon_time_delay(samplerate, beacons[0], beacon)\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
" for beacon in beacons\n",
|
|
|
|
"])\n",
|
|
|
|
"\n",
|
2022-08-05 14:26:40 +02:00
|
|
|
"\n",
|
2022-08-05 12:16:19 +02:00
|
|
|
"abs_beacon_time_delays = abs_beacon_time_delays_tmp[:,0]\n",
|
2022-08-05 14:26:40 +02:00
|
|
|
"t_phi = np.array(abs_beacon_time_delays % (1/f_beacon), dtype=np.float64)\n",
|
2022-08-05 12:16:19 +02:00
|
|
|
"beacon_time_delays_err = abs_beacon_time_delays_tmp[:,1]\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"\n",
|
2022-08-05 14:26:40 +02:00
|
|
|
"print(\"Beacon delays [ns] \\pm k*{}ns: {}\".format(1/f_beacon/ns, t_phi/ns))"
|
2022-07-11 11:29:38 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-08-05 18:09:47 +02:00
|
|
|
"execution_count": 8,
|
2022-07-11 11:29:38 +02:00
|
|
|
"metadata": {},
|
2022-08-01 15:17:24 +02:00
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
2022-08-05 14:26:40 +02:00
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAEsCAYAAADtt+XCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOy9eZhU1bmo/35VPY/0CDTN0Mw00M3UTAr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+AQxE57B4GnhHRAY5V3BEO56Bd0mSAP4LeEYpdaSzCiISjU4C9rxSareH5+FW5m7KbQgSRoEYAsUYHAmI2hGRdHSug0BTB6R02JaCzqkQtogHqWQ7ogKQWtYhi9s0rRJmqWUNwccoEIPfcdxARuE0AhGRu9Hz2BNF5Mkujv3AhRVOe/nAQxH2AlEiMsRpWyFnT7GEI76kku2IP1LLgps0rSJhmVrWEGSMAjEEgnhHsQCIyFhgJvB34MfoHOiprg5USl3hbIXToVzh6hgXbdSjn34fFJ369yLgGvTTctii3KSS7YgELrUsuE/TGrLUsobwwSgQg99x3MCfBHaKSCmwAP0EOgY9KmlDZxAMJD9EK7GT6PS7P1BKnRmBOEY6vwqwDL6wAJ0bpRwoQX9X/7t9Zwe5o9FmuOXoqcEfA9cqpZz9Ku4A3lBKuZq++w+0iex9wLcd7/8DQCnVoJQqay/oacEmpVS5iPQH7kZfzzKnEeKtHpyHJzK7k9sQJph8IIaAIyKPoC1w7kPfMB5QSl3n5z78ktbWEP6IST0cNhgFYgg4IlKInsvuh14H+b5S6nhopTIYDN3FKBBDUBCR0cBdSqkfh1oWg8H
|
2022-08-01 15:17:24 +02:00
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 432x288 with 1 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
2022-07-11 11:29:38 +02:00
|
|
|
"source": [
|
|
|
|
"# Make a figure showing the corrected beacons\n",
|
|
|
|
"fig, ax = plt.subplots(1,1, sharex=True)\n",
|
|
|
|
"ax.set_xlabel(\"Time [ns]\")\n",
|
|
|
|
"ax.set_ylabel(\"Amplitude [au]\")\n",
|
2022-08-05 14:26:40 +02:00
|
|
|
"ax.set_title(\n",
|
|
|
|
" \"Beacon delays [ns] $\\pm$ $k*{}$\\n$t_{{\\phi}}$ = {}\"\n",
|
|
|
|
" .format(1/f_beacon/ns, t_phi/ns)\n",
|
|
|
|
")\n",
|
2022-08-05 12:16:19 +02:00
|
|
|
"\n",
|
|
|
|
"for i, _ in enumerate(beacons):\n",
|
|
|
|
" l = ax.plot(\n",
|
|
|
|
" time/ns, beacons[i],\n",
|
|
|
|
" label=\"ch {}\".format(i), \n",
|
|
|
|
" ls ='--', \n",
|
|
|
|
" alpha=0.5\n",
|
|
|
|
" )\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
" \n",
|
|
|
|
" # indicate start of uncorrected beacons\n",
|
2022-08-05 12:16:19 +02:00
|
|
|
" ax.axvline(\n",
|
2022-08-05 14:26:40 +02:00
|
|
|
" t_phi[i]/ns,\n",
|
2022-08-05 12:16:19 +02:00
|
|
|
" color=l[0].get_color(),\n",
|
|
|
|
" ls = '--'\n",
|
|
|
|
" )\n",
|
|
|
|
" \n",
|
|
|
|
" ax.plot(\n",
|
2022-08-05 14:26:40 +02:00
|
|
|
" (time-t_phi[i])/ns,\n",
|
2022-08-05 12:16:19 +02:00
|
|
|
" beacons[i],\n",
|
|
|
|
" label='ch {} corrected'.format(i),\n",
|
|
|
|
" color=l[0].get_color(),\n",
|
|
|
|
" ls=(5*i+2, (20, 20))\n",
|
|
|
|
" )\n",
|
|
|
|
" \n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"ax.legend(ncol=2)\n",
|
|
|
|
"ax.margins(y=0.3)\n",
|
|
|
|
"if True:\n",
|
2022-08-05 14:26:40 +02:00
|
|
|
" ax.set_xlim(time[0]/ns - 10, time[2*samplerate//f_beacon]/ns)\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"\n",
|
2022-08-05 14:26:40 +02:00
|
|
|
"fig.show()"
|
2022-07-11 11:29:38 +02:00
|
|
|
]
|
|
|
|
},
|
2022-08-08 10:49:17 +02:00
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"##### 1.1.2 Beacon Synced traces"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 9,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAArkAAAEWCAYAAABi/I8SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOzdd3wUdf7H8dd3d9MbKSQhARIgJIRepQhKEXvBcmI/PfX0Tqzn/WznnXeinl0563l2PXtDPZXekd4SyhJIIISSsOl9s/v9/TGbkJDChmwqn+fjsQ/I7szue2d3Zj/zne98R2mtEUIIIYQQoisxtXcAIYQQQgghPE2KXCGEEEII0eVIkSuEEEIIIbocKXKFEEIIIUSXI0WuEEIIIYTocqTIFUIIIYQQXY4UuUII0UUopR5TSn3Uhq9XrJTq6+HnfE8pNduTzymEODVJkSuEaHdKqQylVJmraMpTSv2olOrV3rlE07TWgVrrve2dQwghGiJFrhCio7hIax0I9ACOAP9q5zxdmlLK0t4ZhBCiNUmRK4ToULTW5cCXwMDq+5RSPkqp55RS+5VSR5RSbyil/FyPhSqlflBK5bhagX9QSvWsNW+YUupdpdRB1+Pf1nrsVqVUmlIqVyk1VykVU+sxrZS6XSm12zXfq0op5XosQSm1VClVoJQ6qpT6rKH3opTyVUp9pJSyKaXylVLrlFJRSqnfKKU2HDftn6qzuQ7Zv+pq0S5SSq1RSvWrNe0gpdR8V+4jSqmHaz2Vt1LqA9d8qUqp0bXmy1BKPaCU2gqUKKUsSqlkpdQSV75UpdTFtaY/UQ6tlEpw/f98pdR213RZSqn7a013oVJqs+s1VimlhtZ6bIRSaqNrvs8A3wa/GEII0UxS5AohOhSllD8wE/i11t1PA4nAcCABiAX+6nrMBLwLxAG9gTLglVrzfgj4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pyedffdd3P77bejlCI5OZm5i39lS89ofjvIl+ee2kNxcRULFnTjjikJzFm4m7MHRnHu4B5tnrOzLM/OkhM6T1bJ6VmS07MkZ8clRa4Qp7A1a9awYsUKdu7cyZNPPklpWTllgbFMve9GHr1mPNsGJ/HnPxutt3dOTWDRziM89PU2RsaFEhnU9cZaFEII0XWcVHcFpdS/PR1ECNH2Hn74Yd58800WLVpEeno6Zz74LmXZGbx45TAs5rqbBy+ziRevHE5JpYOHvtqGXBJcCCFER9ZokauUCmvkFg6c34YZhRCtYP78+VRUVDB+/HgAPl6zn3VHnHhrO93MlQ3O0z8qiAfOHcDCndl8vj6zLeMKIYQQzdJUd4UcYB+gat2nXX9HtmaoriYy8vr2juCW8PDw9o7gFsnpGdOnT2f69OnYbDaOFlXw+HfrMS97k++/+5YffviBzZs3s3+/lV27innqqad46KGHALhpQjzztx/mH99v5+yB0YQGeLdJ3o6+PKt1lpzQebJKTs+SnJ4lOTuuRsfJVUrtBqZprfc38Fim1rpXY08q4+QK0bl8vi6TP3+xiTEHvuK7L/5LYGAgTzzxBOPHfw7Uv6zvlsx8Lnl1JS/OHMalI3q2Q2IhhBDCcDLj5L4EhDby2DMeSSVOKW+++SY9evRg+PDhJCQkMGPGDCorGz4s3hreeusthg8fzvDhwzGZTDX/v++++9osQ0f108bdHHhpJj9+8zmDBg0iKiqKO++8k9/8Zl2D0w+JDSEi0IfFO3PaOKkQQgjhnka7K2itX23isX+1TpyuKS3tFQASEma1c5Km2Ww2oPUOaWzdupUnn3ySm266CafTSWJiIlu3bmX06Ho7X0062Zy33nort956K1lZWUyYMIHNmzc3a/7mau3l6SmHs3NYtfso4y65nr0rvic/P5+SkhI
|
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 864x288 with 3 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"fig, axes = beacon_sync_figure(\n",
|
|
|
|
" time, impulses, beacons,\n",
|
|
|
|
" delta_t = t_phi,\n",
|
|
|
|
" beacon_offsets = phase2time(beacon_init_phase, f_beacon) + t_phi,\n",
|
|
|
|
" impulse_offsets = impulses_offsets,\n",
|
|
|
|
" f_beacon = f_beacon,\n",
|
|
|
|
" show_annotations = True\n",
|
|
|
|
")\n",
|
|
|
|
"axes[0].set_title(\"Beacons synchronised\")\n",
|
|
|
|
"fig.show()"
|
|
|
|
]
|
|
|
|
},
|
2022-07-11 11:29:38 +02:00
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
2022-08-05 14:26:40 +02:00
|
|
|
"##### 1.2 Impulse delays ($\\Delta A, kT$)\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"\n",
|
2022-08-08 10:49:17 +02:00
|
|
|
"###### 1.2.1 $\\Delta A$\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"Find the delay within a single beacon period"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-08-08 10:49:17 +02:00
|
|
|
"execution_count": 10,
|
2022-07-11 11:29:38 +02:00
|
|
|
"metadata": {},
|
2022-08-08 10:49:17 +02:00
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"[0. 7.]\n"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
2022-07-11 11:29:38 +02:00
|
|
|
"source": [
|
2022-08-05 14:26:40 +02:00
|
|
|
"impulse_max_time = np.argmax(impulses, axis=1) /samplerate\n",
|
|
|
|
"impulse_time_in_periods = np.array((impulse_max_time - t_phi)*f_beacon)\n",
|
2022-08-08 10:49:17 +02:00
|
|
|
"someB, A = np.divmod(impulse_time_in_periods, 1)\n",
|
2022-08-05 14:26:40 +02:00
|
|
|
"\n",
|
|
|
|
"# subtract the reference beacon's value to obtain time differences\n",
|
|
|
|
"A -= A[0]\n",
|
2022-08-08 10:49:17 +02:00
|
|
|
"someB -= someB[0]\n",
|
|
|
|
"\n",
|
|
|
|
"Delta_A = A[1:] - A[0]\n",
|
|
|
|
"print(someB)"
|
2022-07-11 11:29:38 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
2022-08-05 14:26:40 +02:00
|
|
|
"cell_type": "markdown",
|
2022-07-11 11:29:38 +02:00
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
2022-08-08 10:49:17 +02:00
|
|
|
"###### 1.2.2 $kT$\n",
|
|
|
|
"Find integer number of periods"
|
2022-07-11 11:29:38 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-08-08 10:49:17 +02:00
|
|
|
"execution_count": 11,
|
2022-07-11 11:29:38 +02:00
|
|
|
"metadata": {},
|
2022-08-05 14:26:40 +02:00
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2022-08-08 10:49:17 +02:00
|
|
|
"Best k: 8\n",
|
|
|
|
"Maximum: 2.0\n"
|
2022-08-05 14:26:40 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
2022-07-11 11:29:38 +02:00
|
|
|
"source": [
|
2022-08-08 10:49:17 +02:00
|
|
|
"ref_impulse = impulses[0]\n",
|
|
|
|
"my_impulse = impulses[1]\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"\n",
|
2022-08-08 10:49:17 +02:00
|
|
|
"# remove 'already determined' offsets\n",
|
|
|
|
"if True:\n",
|
|
|
|
" # $t_\\phi$ offset\n",
|
|
|
|
" my_impulse = time_roll(my_impulse, samplerate, -t_phi)\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"\n",
|
2022-08-08 10:49:17 +02:00
|
|
|
"if True:\n",
|
|
|
|
" # $\\Delta A$ offset\n",
|
|
|
|
" my_impulse = time_roll(my_impulse, samplerate, +Delta_A)\n",
|
2022-07-11 11:29:38 +02:00
|
|
|
"\n",
|
2022-08-08 10:49:17 +02:00
|
|
|
"best_k, (ks, maxima) = beacon_integer_period(samplerate, f_beacon, ref_impulse, my_impulse)\n",
|
|
|
|
"print(\"Best k: {:0g}\".format(best_k))\n",
|
|
|
|
"print(\"Maximum: {}\".format(maxima[np.where(ks == best_k)][0]))\n",
|
|
|
|
"B = np.array([ 0, best_k])\n"
|
2022-07-11 11:29:38 +02:00
|
|
|
]
|
|
|
|
},
|
2022-08-05 18:09:47 +02:00
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
2022-08-08 10:49:17 +02:00
|
|
|
"#### 1.3 Total Time delay"
|
2022-08-05 18:09:47 +02:00
|
|
|
]
|
|
|
|
},
|
2022-07-11 11:29:38 +02:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-08-08 10:49:17 +02:00
|
|
|
"execution_count": 12,
|
2022-07-11 11:29:38 +02:00
|
|
|
"metadata": {},
|
2022-08-05 18:09:47 +02:00
|
|
|
"outputs": [
|
|
|
|
{
|
2022-08-08 10:49:17 +02:00
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"Δ𝐴 = [0. 5.42857143]\n",
|
|
|
|
"B = kT = [0 8]T\n",
|
|
|
|
"𝑡𝜙 = [0. 8.57142857]\n",
|
|
|
|
"Δt = 0.12828571428571425\n",
|
|
|
|
"Preset Δt = 0.11399999999999999\n"
|
|
|
|
]
|
2022-08-05 18:09:47 +02:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
2022-08-08 10:49:17 +02:00
|
|
|
"print(\"Δ𝐴 = {}\".format(A /f_beacon/ns))\n",
|
|
|
|
"print(\"B = kT = {}T\".format(B))\n",
|
|
|
|
"print(\"𝑡𝜙 = {}\".format(t_phi/ns))\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"delta_t = A/f_beacon + B/f_beacon + t_phi\n",
|
|
|
|
"\n",
|
|
|
|
"print(\"Δt = {}\".format(delta_t[1]))\n",
|
|
|
|
"\n",
|
|
|
|
"print(\"Preset Δt = {}\".format(impulses_offsets[1,0]-impulses_offsets[0,0]))"
|
2022-08-05 18:09:47 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"##### 1.3.2 Beacon Synced and Period Alignment"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-08-08 10:49:17 +02:00
|
|
|
"execution_count": 13,
|
2022-08-05 18:09:47 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
2022-08-08 10:49:17 +02:00
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAArkAAAEWCAYAAABi/I8SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOzdeVxVZf7A8c9zL/umLKKgCCqi4AZqbmmZZrtle02pLePUTE7bzK+aatrMmpqpad+stMyaabHNJksrS1MxF0RARVQQBUVBRWS99z6/P84BLshyRS4oft+v131x79m+z1m493ue85znKK01QgghhBBCdCSW9i6AEEIIIYQQrU2SXCGEEEII0eFIkiuEEEIIITocSXKFEEIIIUSHI0muEEIIIYTocCTJFUIIIYQQHY4kuUKI04pS6jGl1AdtGK9EKdW7lZc5Tyn1ZGsu08W4Pc31sbZg3vFKqd0tjFuzz06kDEKI04skuUKcIpRS2UqpMvMH/qBS6hulVFR7l0s0TWsdoLXe0V7xzYS40jxuipRSS5RS/VuyLK31LnN97K1dzlOpDC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PliSsvLwfAx8eVJ8dKLFdjlZZuBcDPr1+D87R2PHeRWBJLYp061q1bd0Br3aX+cLckuTExMaxdu9YdixZCdGArVxq9V40Zk+z2WJmZmQDExcVJrFaMtWHDeACSkpa1STx3kVgSS2KdOpRSDT5RUW48E0II0WrKquxU2hzNTyiEEG4mbXKFEEK02BNPPEF0tPHkZ6012/eXsHXvEQqOlLdzyYQQpzu39K4wfPhwLc0VhBCiY9u5cyeTJ0+
|
2022-08-05 18:09:47 +02:00
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 864x288 with 3 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"fig, axes = beacon_sync_figure(\n",
|
|
|
|
" time, impulses, beacons,\n",
|
|
|
|
" delta_t = (B + [0,-0])/f_beacon + t_phi,\n",
|
|
|
|
" beacon_offsets = phase2time(beacon_init_phase, f_beacon) + t_phi,\n",
|
|
|
|
" impulse_offsets = impulses_offsets,\n",
|
|
|
|
" f_beacon = f_beacon,\n",
|
|
|
|
" show_annotations = True\n",
|
|
|
|
")\n",
|
2022-08-08 10:49:17 +02:00
|
|
|
"axes[0].set_title(\"Beacons synchronised, Period alignment\")\n",
|
2022-08-05 18:09:47 +02:00
|
|
|
"fig.show()"
|
|
|
|
]
|
2022-07-11 11:29:38 +02:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"kernelspec": {
|
|
|
|
"display_name": "Python 3",
|
|
|
|
"language": "python",
|
|
|
|
"name": "python3"
|
|
|
|
},
|
|
|
|
"language_info": {
|
|
|
|
"codemirror_mode": {
|
|
|
|
"name": "ipython",
|
|
|
|
"version": 3
|
|
|
|
},
|
|
|
|
"file_extension": ".py",
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
"name": "python",
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
"pygments_lexer": "ipython3",
|
|
|
|
"version": "3.7.6"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 4
|
|
|
|
}
|