2022-03-07 18:34:26 +01:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"# Emitter/Receiver Simulation with Signals"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-03-10 14:59:35 +01:00
|
|
|
"execution_count": 1,
|
2022-03-07 18:34:26 +01:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"import numpy as np\n",
|
|
|
|
"\n",
|
2022-03-10 14:59:35 +01:00
|
|
|
"import matplotlib.pyplot as plt"
|
2022-03-07 18:34:26 +01:00
|
|
|
]
|
|
|
|
},
|
2022-03-10 14:59:35 +01:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
|
|
|
},
|
2022-03-07 18:34:26 +01:00
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"#### Signal"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-03-10 14:59:35 +01:00
|
|
|
"execution_count": 2,
|
2022-03-07 18:34:26 +01:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2022-03-10 15:41:09 +01:00
|
|
|
"from lib import TravelSignal\n",
|
2022-03-07 18:34:26 +01:00
|
|
|
"\n",
|
2022-03-10 14:59:35 +01:00
|
|
|
"####\n",
|
|
|
|
"from scipy.stats import norm\n",
|
2022-03-07 18:34:26 +01:00
|
|
|
"\n",
|
2022-03-10 14:59:35 +01:00
|
|
|
"sample_rate = 3e2 # Hz\n",
|
|
|
|
"interp_sample_rate = sample_rate * 1/10 # Hz\n",
|
|
|
|
"\n",
|
|
|
|
"t_offset = 8\n",
|
|
|
|
"periodic = False\n",
|
|
|
|
"\n",
|
|
|
|
"time = t_offset + np.arange(0, 1, 1/sample_rate) #s\n",
|
|
|
|
"time2 = t_offset + np.arange(-1.5, 1, 1/sample_rate) #s\n",
|
|
|
|
"\n",
|
|
|
|
"signal = norm.pdf(time, time[len(time)//2], (time[-1] - time[0])/10)\n",
|
|
|
|
"\n",
|
|
|
|
"if False:\n",
|
|
|
|
" mysignal = TravelSignal(signal, sample_rate, t_0 = t_offset, periodic=True)\n",
|
|
|
|
" mysignal2 = TravelSignal(signal, sample_rate, t_0 = t_offset, periodic=False)\n",
|
|
|
|
"\n",
|
|
|
|
" fig, ax = plt.subplots(1, 1, figsize=(16,4))\n",
|
|
|
|
" ax.set_title(\"Raw and TravelSignal\")\n",
|
|
|
|
" ax.set_ylabel(\"Amplitude\")\n",
|
|
|
|
" ax.set_xlabel(\"Time\")\n",
|
|
|
|
"\n",
|
|
|
|
" ax.plot(time, signal, label='Raw signal')\n",
|
|
|
|
" ax.plot(time2, mysignal(time2)+0.5, '.-', label='TravelSignal(periodic)+0.5')\n",
|
|
|
|
" ax.plot(time2, mysignal2(time2)-0.5, '.-', label='TravelSignal-0.5')\n",
|
|
|
|
"\n",
|
|
|
|
" ax.legend()\n",
|
|
|
|
"\n",
|
|
|
|
" plt.show();"
|
2022-03-07 18:34:26 +01:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## New code"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-03-10 14:59:35 +01:00
|
|
|
"execution_count": 3,
|
2022-03-07 18:34:26 +01:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2022-03-10 15:41:09 +01:00
|
|
|
"from lib.location import Receiver, Emitter"
|
2022-03-10 14:59:35 +01:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## Testing"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-03-10 15:41:09 +01:00
|
|
|
"execution_count": 4,
|
2022-03-10 14:59:35 +01:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPIAAACqCAYAAACXtRI+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAQuklEQVR4nO3dfbRVdZ3H8fcHEVAkynhIVCBdpqIktUgrZ1KzHNEpnFU2miU5FqmZzZpaiY3NOGOm0zRrKpXMykkzdFyrYaLGHkwzKx9hYkxERsYQCIGLSmIqBnznj9/vxu54z72Xyz133/Pj81rrrnP2w9n7ux8+e//2Pufco4jAzNrbkLoLMLOd5yCbFcBBNiuAg2xWAAfZrAAOslkBHOSdIOlgSb+UtEnSBS2e16ckfa2V88jzGS7pYUmv6mG810q6u9X1VOb3AUk/H6j5tZteBVnSaZLuk/Q7Sevz8/MkqdUF7ghJKyS9bQBn+UngzogYFRFf6qKeOyW9IOnZyt93+zKjiPhsRHwwT3eypJA0tDKv/trRZwN3RcTaHup5ENgo6R39MM9+IWlkXse37uDrjpW0ulV1DYQegyzp48AXgX8GXgWMB84BjgaGtbS6flbd8fvJJGBJD+OcHxF7Vf4GzY5fVVk3Hwa+2cuXfSuPP1i8G9gMnCBpn7qLGVAR0fQPGA38DnhXD+MNBz4PrATWAdcAe1SGfwhYDjwFLAAmVIYFcB7wKLAJuBQ4ELgHeAa4BRhWGf/PgcXARuBu4LW5/zeBbcDzwLOks+XkPP2zc213Af8FfLSh/geBU5os2ztJYd0I3A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
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": {
|
2022-03-10 15:41:09 +01:00
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAvEAAAF1CAYAAABh8bWyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOzdeXxdd33n/9fHkizZluQktrM6jhMSGhJKAzGhjLskgbZsZZlSmrAUpuUROh0mhMBQWtohtNCWaYfS5EdhPMB0YQklLAVSYFiSMqEQsLOREJaQhTib19iSbUmW9fn9cc61r+V7tV7pXvm+no+HH7r3nO8593Pvke23vvqccyIzkSRJkrRwLGp2AZIkSZKmxxAvSZIkLTCGeEmSJGmBMcRLkiRJC4whXpIkSVpgDPGSJEnSAmOIl6QFKCKWRsT1EbErIj4+x691YUTcNZevMdci4qaIeE2z65CkRjHES2oLETFY9WcsIvZVPX9Fs+ubgd8CjgNWZOal41dGxDsjYv+4971tJi+UmTdm5rlV+94cERdWPT8zIhb8TUci4rURkRHxH6e53Uci4qo5KkuSajLES2oLmdlb+QP8FPj1qmUfHT8+Ijrnv8ppOQ34YWaOTjDmo9XvOzNXzldx09FCn/WrgR3lV0lqaYZ4SeLgzPUnIuLjETEAvDIinhkR346IxyPikYi4OiK6qrb52Yj4akTsiIhHI+It5fJFEfFHEfGTiNgWEddGxLHluqUR8bGI2F7u9zsRUTNcR8S5EfFv5bjvRcTzy+XvAv4IeEU5wz6t0BkRneWM838uaxyIiLdHxFnl+91dfg5d5fhnR8T95eOPAycDXyxf+0rgG+W6yoz/08vnr42IH0TEzoj4YkScOu71fz8i7gF+UKPGRRFxXfm5Ph4RN0bEk6rWf6Q8H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|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"if True:\n",
|
|
|
|
" sample_rate = 3e2 # Hz\n",
|
|
|
|
" periodic = False\n",
|
|
|
|
" \n",
|
|
|
|
" t_offset = 8\n",
|
|
|
|
" t_start = 0\n",
|
|
|
|
" t_end = 1\n",
|
|
|
|
" time = t_offset + np.arange(t_start, t_end, 1/sample_rate) #s\n",
|
|
|
|
" \n",
|
|
|
|
" t_longstart = 0\n",
|
|
|
|
" t_longend = 30*t_end\n",
|
|
|
|
" longtime = np.arange(t_longstart, t_longend, 1/sample_rate) #s\n",
|
|
|
|
"\n",
|
|
|
|
"if False:\n",
|
|
|
|
" if True:\n",
|
|
|
|
" freq = sample_rate/8\n",
|
|
|
|
" signal = np.cos(2*np.pi*freq*time)\n",
|
|
|
|
" else: \n",
|
|
|
|
" from scipy.stats import norm\n",
|
|
|
|
" signal = norm.pdf(time, time[len(time)//2], (time[-1] - time[0])/10)\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"#####\n",
|
|
|
|
"# Setup Signal, Emitter and Antennae\n",
|
|
|
|
"\n",
|
|
|
|
"mysignal = TravelSignal(signal, sample_rate, t_0 = t_offset, periodic=periodic)\n",
|
|
|
|
"\n",
|
|
|
|
"source = Emitter([1,1])\n",
|
|
|
|
"emitted = source.emit(mysignal)\n",
|
|
|
|
"\n",
|
|
|
|
"antennae = [\n",
|
|
|
|
" Receiver([2,3]),\n",
|
|
|
|
" Receiver([10,10]),\n",
|
|
|
|
" Receiver([-2,-3]),\n",
|
|
|
|
"]\n",
|
|
|
|
" \n",
|
|
|
|
"#####\n",
|
|
|
|
"# Follow traces, and show geometry\n",
|
|
|
|
"ylabel_kw = {\"rotation\": \"horizontal\", \"va\":\"center\", \"ha\":\"center\", \"labelpad\": 30}\n",
|
|
|
|
"\n",
|
|
|
|
"fig, axs = plt.subplots(1,1, figsize=(2,2))\n",
|
|
|
|
"axs = [ axs ]\n",
|
|
|
|
"\n",
|
|
|
|
"### Geometry Plot\n",
|
|
|
|
"i = 0\n",
|
|
|
|
"axs[i].set_title(\"Geometry of Emitter(s) and Antennae\")\n",
|
|
|
|
"axs[i].set_ylabel(\"y\", **ylabel_kw)\n",
|
|
|
|
"axs[i].set_xlabel(\"x\")\n",
|
|
|
|
"axs[i].plot(*source.x, '*', label=\"Emitter\")\n",
|
|
|
|
"\n",
|
|
|
|
"for j, ant in enumerate(antennae):\n",
|
|
|
|
" axs[i].plot(*ant.x, '+', label=\"Antenna {}\".format(j))\n",
|
|
|
|
"\n",
|
|
|
|
"### Plot Traces\n",
|
|
|
|
"fig, axs = plt.subplots(1+len(antennae),1, sharex=True, figsize=(12,6))\n",
|
2022-03-10 15:41:09 +01:00
|
|
|
"axs[0].set_title(\"Traces of Emitter and Antennae\")\n",
|
2022-03-10 14:59:35 +01:00
|
|
|
"\n",
|
|
|
|
"# Emitter\n",
|
|
|
|
"i = 0\n",
|
|
|
|
"axs[i].set_ylabel(\"Emitter\\n at ({},{})\".format(*source.x), **ylabel_kw)\n",
|
|
|
|
"axs[i].plot(time, emitted(time))\n",
|
|
|
|
"\n",
|
|
|
|
"# Antenna\n",
|
|
|
|
"for j, ant in enumerate(antennae):\n",
|
|
|
|
" i +=1\n",
|
|
|
|
" axs[i].set_ylabel(\"Antenna {}\\n at ({},{})\".format(j, *ant.x), **ylabel_kw)\n",
|
|
|
|
" axs[i].plot(longtime, ant.recv(emitted)(longtime), label=\"Antenna {}\".format(j))\n",
|
|
|
|
" "
|
2022-03-07 18:34:26 +01: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
|
|
|
|
}
|