From 84b3a6dca9d700eff5717767227688df8762107d Mon Sep 17 00:00:00 2001 From: Eric Teunis de Boone Date: Mon, 11 Apr 2022 12:34:21 +0200 Subject: [PATCH] Add simple time recovery --- simulations/04_recover_timing_errors.ipynb | 242 +++++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 simulations/04_recover_timing_errors.ipynb diff --git a/simulations/04_recover_timing_errors.ipynb b/simulations/04_recover_timing_errors.ipynb new file mode 100644 index 0000000..6e7359a --- /dev/null +++ b/simulations/04_recover_timing_errors.ipynb @@ -0,0 +1,242 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Recover timing errors from a list of antennas\n", + "\n", + "timing t_i, initial time y, \\\n", + "distance d(i) to receiver i from emit, \\\n", + "error s_i\n", + "\n", + "\n", + "t_a = y + d(a)/v + s_a \\\n", + "t_b = y + d(b)/v + s_b\n", + "\n", + "-----\n", + "\n", + "y = t_a - d(a)/v + s_a\n", + "\n", + "t_b = t_a - d(a)/v + s_a + d(b)/v + s_b \\\n", + " = t_a - d(a)/v + d(b)/v + s_b + s_a\n", + "\n", + "s_b - s_a = t_b - t_a + (d(b) - d(a))/v" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "rng = np.random.default_rng(12345)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "N = 50\n", + "D = 2\n", + "emit_location = rng.random((1, D))\n", + "velocity = 1\n", + "\n", + "\n", + "def distance(x, y = emit_location):\n", + " return np.sqrt( np.sum((x - y)**2, axis=-1) )\n", + "\n", + "actual_err_timings = rng.random(N)\n", + "if not True:\n", + " # undo timing errors\n", + " actual_err_timings = np.zeros_like(actual_err_timings)\n", + "\n", + "actual_locations = rng.random((N, D))\n", + "\n", + "actual_timings = distance(actual_locations)/velocity" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "# Create data to work with\n", + "timings = actual_timings + actual_err_timings\n", + "\n", + "## use the first number as reference\n", + "ref_timing = timings[0]\n", + "timings = timings\n", + "\n", + "ref_err_timing = actual_err_timings[0]\n", + "err_timings = actual_err_timings\n", + "\n", + "ref_location = actual_locations[0]\n", + "locations = actual_locations" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " \t Timing \t Error \t Location\n", + "0 \t 1.2114015836686018 \t 0.7973654573327341 \t [0.61682898 0.17632632]\n", + "1 \t 0.8223537613300713 \t 0.6762546707509746 \t [0.30438839 0.44088681]\n", + "2 \t 0.5164764930422616 \t 0.391109550601909 \t [0.15020234 0.21792886]\n", + "3 \t 0.626893985846481 \t 0.33281392786638453 \t [0.47433312 0.47636886]\n", + "4 \t 0.632169930455275 \t 0.5983087535871898 \t [0.25523235 0.29756527]\n", + "5 \t 0.2631030324439694 \t 0.18673418560371335 \t [0.27906712 0.26057921]\n", + "6 \t 0.9488374167867456 \t 0.6727560440146213 \t [0.48276159 0.21197904]\n", + "7 \t 1.2192047533568204 \t 0.9418028652699372 \t [0.4956306 0.24626133]\n", + "8 \t 0.8744783753275451 \t 0.248245714629571 \t [0.83848265 0.18013059]\n", + "9 \t 1.5986254396525794 \t 0.9488811518333182 \t [0.86215629 0.17829944]\n", + "10 \t 1.267555999078216 \t 0.6672374531003724 \t [0.75053133 0.6111204 ]\n", + "---\n", + "Ref: \t 1.2114015836686018 \t 0.7973654573327341 \t [0.61682898 0.17632632]\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEGCAYAAAB/+QKOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR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ts+tPgcvcfZ2ZHUE0nfpSqmoQZnY48C53/3czOx64jWhCSID5wBuJ5iBaBywws58A3wTe7+4bzOwVwBjRvEy73f1UMzsMWGdm98TzT4kEoQAhkk7S7KPrgC+Z2deBO9x9NK4EVBsEvmJmJxNNBfK6qn0/cfdRADN7CJgN7AZ+5e4bANz9N/H+s4F5Zva++LWTiSYlVICQYBQgRJows9cQXdy3A2+obHf3ZWZ2F9GcQuvjGYFrXQH8G3ASUZNu9aJN1bMG7yP6/2gkT3ttwMfdfW0HpyLSEuUgRBows2nATcBXaifKM7Pfd/dH3P0LwAjweuB5omnWKyYT1Qj2Ax8impivkSeAY83s1PgzjjSzQ4gm9bvUzAbj7a8zs5d3foYi9akGIXKwobjJZxAYB/4G+FLCcX8SLwizD3icaNWw/cC4mT0M3ArcCHzbzP4LcD/wu0Yf7O57zOz9wF+a2RBR/uGdROsKzAZ+GiezdwAXdHieIg2pm6uIiCRSE5OIiCRSgBARkUQKECIikkgBQkREEilAiIhIIgUIERFJpAAhIiKJ/j+UWuRk60D/wAAAAABJRU5ErkJggg==\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "# show data\n", + "N_clip = min(N, 10)\n", + "print(\" \", \"\\t\", \"Timing \", \"\\t\", \"Error \", \"\\t\", \"Location\")\n", + "for i, _ in enumerate(timings):\n", + " print(i, \"\\t\", timings[i], \"\\t\", err_timings[i], \"\\t\", locations[i])\n", + " if i > N_clip - 1:\n", + " break\n", + "print('---')\n", + "print(\"Ref:\", \"\\t\", ref_timing, \"\\t\", ref_err_timing, \"\\t\", ref_location)\n", + "\n", + "# plot\n", + "if True:\n", + " fig, ax = plt.subplots()\n", + " ax.plot(distance(locations, 0), actual_timings, 'o')\n", + " ax.plot(distance(locations, 0), timings, 'o')\n", + " ax.set_xlabel(\"Distance\")\n", + " ax.set_ylabel(\"Timing\")\n", + " plt.show();" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Clipped to [:10]:\n", + "[ 0. -0.26793704 -0.28866918 -0.11995607 -0.38017495 -0.33766728\n", + " -0.13795475 -0.13663424 0.21219653 0.23570816]\n", + "[ 0. -0.38904782 -0.69492509 -0.5845076 -0.57923165 -0.94829855\n", + " -0.26256417 0.00780317 -0.33692321 0.38722386]\n", + "---- + \n", + "Calc [ 0. -0.12111079 -0.40625591 -0.46455153 -0.1990567 -0.61063127\n", + " -0.12460941 0.14443741 -0.54911974 0.15151569]\n", + "---------------\n", + "Correct result: True\n" + ] + } + ], + "source": [ + "# s_b - s_a = t_b - t_a - (d(b) - d(a))/v\n", + "\n", + "calc_err_timings = timings - ref_timing - (distance(locations) - distance(ref_location))/velocity\n", + "\n", + "N_clip = min(N, 10)\n", + "\n", + "print(\"Clipped to [:{}]:\".format(N_clip))\n", + "print((distance(locations) - distance(ref_location))[:N_clip])\n", + "print((timings - ref_timing)[:N_clip])\n", + "print('---- + ')\n", + "\n", + "print(\"Calc\", calc_err_timings[:N_clip])\n", + "\n", + "print('---'*5)\n", + "print(\"Correct result:\", np.allclose(calc_err_timings + ref_err_timing, actual_err_timings))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "---------------\n", + "Actual error: [0.79736546 0.67625467 0.39110955 0.33281393 0.59830875 0.18673419\n", + " 0.67275604 0.94180287 0.24824571 0.94888115 0.66723745 0.09589794\n", + " 0.44183967 0.88647992 0.6974535 0.32647286 0.73392816 0.22013496\n", + " 0.08159457 0.1598956 0.34010018 0.46519315 0.26642103 0.8157764\n", + " 0.19329439 0.12946908 0.09166475 0.59856801 0.8547419 0.60162124\n", + " 0.93198836 0.72478136 0.86055132 0.9293378 0.54618601 0.93767296\n", + " 0.49498794 0.27377318 0.45177871 0.66503892 0.33089093 0.90345401\n", + " 0.25707418 0.33982834 0.2588534 0.35544648 0.00502233 0.62860454\n", + " 0.28238271 0.06808769]\n", + "Calc+ref error: [0.79736546 0.67625467 0.39110955 0.33281393 0.59830875 0.18673419\n", + " 0.67275604 0.94180287 0.24824571 0.94888115 0.66723745 0.09589794\n", + " 0.44183967 0.88647992 0.6974535 0.32647286 0.73392816 0.22013496\n", + " 0.08159457 0.1598956 0.34010018 0.46519315 0.26642103 0.8157764\n", + " 0.19329439 0.12946908 0.09166475 0.59856801 0.8547419 0.60162124\n", + " 0.93198836 0.72478136 0.86055132 0.9293378 0.54618601 0.93767296\n", + " 0.49498794 0.27377318 0.45177871 0.66503892 0.33089093 0.90345401\n", + " 0.25707418 0.33982834 0.2588534 0.35544648 0.00502233 0.62860454\n", + " 0.28238271 0.06808769]\n" + ] + } + ], + "source": [ + "if True:\n", + " print('---'*5)\n", + " print(\"Actual error:\", actual_err_timings)\n", + " print(\"Calc+ref error:\", calc_err_timings + ref_err_timing)" + ] + } + ], + "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 +}