diff options
author | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-03-05 19:15:28 +0100 |
---|---|---|
committer | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-03-05 19:15:28 +0100 |
commit | 4b419bd1ad9f22266e068341176f5ab665a26222 (patch) | |
tree | ec5ee9e379d4de3e15b33f0b640b700bef0750bc /lab-windows/dsss_experiments-ber.ipynb | |
parent | d9b26d16c063aec32b70287ff861a1f23642a9f2 (diff) | |
download | master-thesis-4b419bd1ad9f22266e068341176f5ab665a26222.tar.gz master-thesis-4b419bd1ad9f22266e068341176f5ab665a26222.tar.bz2 master-thesis-4b419bd1ad9f22266e068341176f5ab665a26222.zip |
Working on DSSS demodulator sim
Diffstat (limited to 'lab-windows/dsss_experiments-ber.ipynb')
-rw-r--r-- | lab-windows/dsss_experiments-ber.ipynb | 209 |
1 files changed, 181 insertions, 28 deletions
diff --git a/lab-windows/dsss_experiments-ber.ipynb b/lab-windows/dsss_experiments-ber.ipynb index a12b5a4..83a4a17 100644 --- a/lab-windows/dsss_experiments-ber.ipynb +++ b/lab-windows/dsss_experiments-ber.ipynb @@ -139,6 +139,25 @@ }, { "cell_type": "code", + "execution_count": 73, + "metadata": {}, + "outputs": [], + "source": [ + "test_duration = 300\n", + "test_nbits = 5\n", + "test_signal_amplitude=2.0e-3\n", + "test_decimation=10\n", + "\n", + "for test_signal_amplitude in [2.0e-3, 20e-3, 200e-3, 2]:\n", + " test_data = np.random.RandomState(seed=0).randint(0, 2 * (2**test_nbits), test_duration)\n", + " signal = np.repeat(modulate(test_data, test_nbits) * 2.0 - 1, test_decimation) * test_signal_amplitude\n", + " with open(f'dsss_test_signals/dsss_test_noiseless_{test_signal_amplitude*1000:.0f}mHz.bin', 'wb') as f:\n", + " for e in signal:\n", + " f.write(struct.pack('<f', e))" + ] + }, + { + "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], @@ -159,7 +178,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "c5fba7c7cec24f09a4f23f7c7d87eb90", + "model_id": "373401133cfe408aa15738e48c58dfaa", "version_major": 2, "version_minor": 0 }, @@ -186,6 +205,129 @@ }, { "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "<ipython-input-44-38927d86fcc7>:1: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).\n", + " fig, ax = plt.subplots()\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "2015d1f2951340d49397c6c289096b01", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "Text(0.5, 1.0, 'Ricker wavelet, w=69 a=7.3')" + ] + }, + "execution_count": 44, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "fig, ax = plt.subplots()\n", + "w = 69\n", + "a = 7.3\n", + "ax.plot(range(-w//2+1, w//2+1), sig.ricker(w, a))\n", + "ax.grid()\n", + "ax.axvline(0, color='orange')\n", + "ax.set_title(f'Ricker wavelet, w={w} a={a}')" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "<ipython-input-56-8e404350b85f>:1: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).\n", + " fig, ax = plt.subplots()\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "3cd0c25b914b41df835005ef6fb51b34", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "fig, ax = plt.subplots()\n", + "r = list(range(60, 120))\n", + "ax.plot(r, [sum(sig.ricker(w, a)) for w in r])\n", + "ax.set_yscale('log')\n", + "ax.grid()" + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "<ipython-input-67-2097444ed7d2>:1: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).\n", + " fig, ax = plt.subplots()\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "c5d1587fa0c944378aed31941ab66ff6", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "fig, ax = plt.subplots()\n", + "sw = 256\n", + "w = sig.ricker(sw, a)\n", + "r = list(range(1, sw//2 - 10))\n", + "d = [-sum(w[:i]) - sum(w[-i:]) for i in r]\n", + "ax.plot([sw-2*x for x in r], d)\n", + "ax.set_yscale('log')\n", + "ax.grid()" + ] + }, + { + "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], @@ -279,7 +421,7 @@ " chain_candidates = []\n", " for chain_score, chain in candidates:\n", " pos, ampl, _idx = chain[-1]\n", - " score_fun = lambda pos, npos, npol: pol_score_factor*abs(npol)/avg_peak + nonlinear_distance((npos-pos)/bit_period)\n", + " score_fun = lambda pos, npos, npol: pol_score_eebfactor*abs(npol)/avg_peak + nonlinear_distance((npos-pos)/bit_period)\n", " next_candidates = sorted([ (score_fun(pos, npos, npol), npos, npol, nidx) for npos, npol, nidx in peak_groups if pos < npos < pos + bit_period*max_lookahead ], reverse=True)\n", "\n", " print(f' candidates for {pos}, {ampl}:')\n", @@ -366,13 +508,13 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "5106e62521e246a0b0766cce3f9e556f", + "model_id": "672fae23dc99473a967c46b4b90d09d7", "version_major": 2, "version_minor": 0 }, @@ -386,10 +528,10 @@ { "data": { "text/plain": [ - "[<matplotlib.lines.Line2D at 0x7fc200d359d0>]" + "[<matplotlib.lines.Line2D at 0x7fc38cb743d0>]" ] }, - "execution_count": 14, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -444,7 +586,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -454,13 +596,13 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "15e67925b1bf47b5bbde289b353ed201", + "model_id": "985b1935796343d19c27e0b0ae31363c", "version_major": 2, "version_minor": 0 }, @@ -474,7 +616,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "6432dbccc7db43d7a227384bca772716", + "model_id": "418a9dd281534ffa8e0aa5f250424127", "version_major": 2, "version_minor": 0 }, @@ -491,12 +633,12 @@ "text": [ "nbits=5\n", "nbits=6\n", - "signal_amplitude=0.00046: ser=0.97396 ±0.00737, br=14.64844\n", "signal_amplitude=0.00015: ser=0.98958 ±0.00737, br=5.85938\n", - "signal_amplitude=0.00022: ser=0.96875 ±0.01276, br=17.57812\n", - "signal_amplitude=0.00010: ser=0.97396 ±0.00737, br=14.64844\n", "signal_amplitude=0.00032: ser=0.97396 ±0.00737, br=14.64844\n", + "signal_amplitude=0.00046: ser=0.97396 ±0.00737, br=14.64844\n", + "signal_amplitude=0.00010: ser=0.97396 ±0.00737, br=14.64844\n", "signal_amplitude=0.00068: ser=0.94792 ±0.01949, br=29.29688\n", + "signal_amplitude=0.00022: ser=0.96875 ±0.01276, br=17.57812\n", "signal_amplitude=0.00100: ser=0.78125 ±0.02552, br=123.04688\n", "signal_amplitude=0.00147: ser=0.28646 ±0.03683, br=401.36719\n", "signal_amplitude=0.00215: ser=0.06250 ±0.03375, br=527.34375\n", @@ -505,8 +647,8 @@ "signal_amplitude=0.00010: ser=0.98958 ±0.00737, br=3.51562\n", "signal_amplitude=0.00022: ser=0.98438 ±0.00000, br=5.27344\n", "signal_amplitude=0.00032: ser=0.98438 ±0.00000, br=5.27344\n", - "signal_amplitude=0.00068: ser=0.68229 ±0.09051, br=107.22656\n", "signal_amplitude=0.00046: ser=0.97917 ±0.01949, br=7.03125\n", + "signal_amplitude=0.00068: ser=0.68229 ±0.09051, br=107.22656\n", "signal_amplitude=0.00100: ser=0.15104 ±0.05156, br=286.52344\n", "signal_amplitude=0.00147: ser=0.01562 ±0.00000, br=332.22656\n", "signal_amplitude=0.00215: ser=0.01562 ±0.00000, br=332.22656\n", @@ -519,10 +661,10 @@ { "data": { "text/plain": [ - "<matplotlib.legend.Legend at 0x7fc23a223550>" + "<matplotlib.legend.Legend at 0x7fc382e9b7f0>" ] }, - "execution_count": 16, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -595,13 +737,13 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "bda9f8070b0142928936a7752f318e97", + "model_id": "8b9593f48de94ec399fd8e61dc11d1de", "version_major": 2, "version_minor": 0 }, @@ -615,10 +757,10 @@ { "data": { "text/plain": [ - "<matplotlib.legend.Legend at 0x7fc20046b730>" + "<matplotlib.legend.Legend at 0x7fc3c4c54b20>" ] }, - "execution_count": 17, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -651,13 +793,13 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "33b1f777dda149eda3a2f031087372c9", + "model_id": "15dc2e1a7cdd460e8cbde0352ea18270", "version_major": 2, "version_minor": 0 }, @@ -861,7 +1003,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ @@ -870,13 +1012,13 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "406505452bb84597a6c39bc12267dcc6", + "model_id": "e381ce02f19d4b85bbbaa9ea99e65623", "version_major": 2, "version_minor": 0 }, @@ -891,7 +1033,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "<ipython-input-25-50856f807a2a>:20: RuntimeWarning: divide by zero encountered in log10\n", + "<ipython-input-19-50856f807a2a>:20: RuntimeWarning: divide by zero encountered in log10\n", " cm_func = lambda x: cmap(np.log10(x - min(decimations)) / (np.log10(max(decimations)) - np.log10(min(decimations))))\n" ] } @@ -1011,9 +1153,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "41.6" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "13 * 2**5 / 10" ] |