diff options
author | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-02-20 19:21:09 +0000 |
---|---|---|
committer | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-02-20 19:21:09 +0000 |
commit | 99b9c0ecc13636553762ec4250adb6b6a50a097c (patch) | |
tree | 2edf8f26790395bdd75f72fd697e0fd6561a4426 /lab-windows/dsss_experiments-ber.ipynb | |
parent | 0a042733dd6a454066976447249e22384f69c828 (diff) | |
download | master-thesis-99b9c0ecc13636553762ec4250adb6b6a50a097c.tar.gz master-thesis-99b9c0ecc13636553762ec4250adb6b6a50a097c.tar.bz2 master-thesis-99b9c0ecc13636553762ec4250adb6b6a50a097c.zip |
Prettify fft comparisons
Diffstat (limited to 'lab-windows/dsss_experiments-ber.ipynb')
-rw-r--r-- | lab-windows/dsss_experiments-ber.ipynb | 109 |
1 files changed, 81 insertions, 28 deletions
diff --git a/lab-windows/dsss_experiments-ber.ipynb b/lab-windows/dsss_experiments-ber.ipynb index d4a2992..91c1daf 100644 --- a/lab-windows/dsss_experiments-ber.ipynb +++ b/lab-windows/dsss_experiments-ber.ipynb @@ -104,7 +104,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 221, "metadata": {}, "outputs": [ { @@ -116,7 +116,7 @@ } ], "source": [ - "with open('/mnt/c/Users/jaseg/shared/raw_freq.bin', 'rb') as f:\n", + "with open('data/raw_freq.bin', 'rb') as f:\n", " mains_noise = np.copy(np.frombuffer(f.read(), dtype='float32'))\n", " print('mean:', np.mean(mains_noise), 'len:', len(mains_noise))\n", " mains_noise -= np.mean(mains_noise)" @@ -610,13 +610,21 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 220, "metadata": {}, "outputs": [ { + "name": "stderr", + "output_type": "stream", + "text": [ + "<ipython-input-220-44ad44d9c4c6>: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(figsize=(12, 9))\n" + ] + }, + { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "3bcd7f07ef26458da90f748fd74addfb", + "model_id": "f63ab2c387f948b29d992a3edd04f4fa", "version_major": 2, "version_minor": 0 }, @@ -630,10 +638,10 @@ { "data": { "text/plain": [ - "<matplotlib.legend.Legend at 0x7f23d0aa37f0>" + "<matplotlib.legend.Legend at 0x7f00ecacf3a0>" ] }, - "execution_count": 7, + "execution_count": 220, "metadata": {}, "output_type": "execute_result" } @@ -645,7 +653,7 @@ "# ser, std = np.mean(sers), np.std(sers)\n", "# results = { nbits: [ res.get() for res in series ] for nbits, series in results.items() }\n", "\n", - "with open(f'/mnt/c/Users/jaseg/shared/dsss_experiments_res-2020-02-19-19-30-05.json', 'r') as f:\n", + "with open(f'data/dsss_experiments_res-2020-02-19-19-30-05.json', 'r') as f:\n", " results = json.load(f)\n", "\n", "for nbits, series in results.items():\n", @@ -666,21 +674,21 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 218, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "<ipython-input-36-8e813d331cd8>: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", + "<ipython-input-218-eb5258414ca6>: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, cbar_ax), (intercept_ax, empty)) = plt.subplots(2, 2, figsize=(12, 9), gridspec_kw={'width_ratios': [1, 0.05]})\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "c05f590a7c0040628c5c5d4032bb7c8e", + "model_id": "6651827b5eca4a0ba46effefd605f06c", "version_major": 2, "version_minor": 0 }, @@ -795,9 +803,9 @@ "\n", "results = []\n", "for fn in [\n", - " '/mnt/c/Users/jaseg/shared/dsss_experiments_res-2020-02-20-12-18-35.json',\n", - " '/mnt/c/Users/jaseg/shared/dsss_experiments_res-2020-02-20-12-26-07.json',\n", - " '/mnt/c/Users/jaseg/shared/dsss_experiments_res-2020-02-20-12-29-02.json'\n", + " 'data/dsss_experiments_res-2020-02-20-12-18-35.json',\n", + " 'data/dsss_experiments_res-2020-02-20-12-26-07.json',\n", + " 'data/dsss_experiments_res-2020-02-20-12-29-02.json'\n", "]:\n", " with open(fn, 'r') as f:\n", " results += json.load(f)\n", @@ -893,21 +901,21 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 268, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "<ipython-input-35-cafaa6062c72>: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, cbar_ax), (intercept_ax, empty)) = plt.subplots(2, 2, figsize=(12, 9), gridspec_kw={'width_ratios': [1, 0.05]})\n" + "<ipython-input-268-fd9510d5c128>: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, cbar_ax), (intercept_ax, empty)) = plt.subplots(2, 2, figsize=(12, 9), gridspec_kw={'width_ratios': [1, 0.05], 'hspace': 0.4})\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "fa93fb31355840148f941dab8b60f51c", + "model_id": "be4678ec02394b81b8aee83c759e1009", "version_major": 2, "version_minor": 0 }, @@ -922,21 +930,22 @@ "name": "stderr", "output_type": "stream", "text": [ - "<ipython-input-35-cafaa6062c72>:16: RuntimeWarning: divide by zero encountered in log10\n", + "<ipython-input-268-fd9510d5c128>:17: 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" ] } ], "source": [ - "fig, ((ax, cbar_ax), (intercept_ax, empty)) = plt.subplots(2, 2, figsize=(12, 9), gridspec_kw={'width_ratios': [1, 0.05]})\n", + "fig, ((ax, cbar_ax), (intercept_ax, empty)) = plt.subplots(2, 2, figsize=(12, 9), gridspec_kw={'width_ratios': [1, 0.05], 'hspace': 0.4})\n", "empty.axis('off')\n", "#fig.tight_layout()\n", "\n", "results = []\n", + "\n", "for fn in [\n", - " '/mnt/c/Users/jaseg/shared/dsss_experiments_res-2020-02-20-14-10-13.json',\n", - " '/mnt/c/Users/jaseg/shared/dsss_experiments_res-2020-02-20-13-21-57.json',\n", - " '/mnt/c/Users/jaseg/shared/dsss_experiments_res-2020-02-20-13-23-47.json',\n", + " 'data/dsss_experiments_res-2020-02-20-14-10-13.json',\n", + " 'data/dsss_experiments_res-2020-02-20-13-21-57.json',\n", + " 'data/dsss_experiments_res-2020-02-20-13-23-47.json',\n", "]:\n", " with open(fn, 'r') as f:\n", " results += json.load(f)\n", @@ -953,16 +962,27 @@ " stds = np.array([ np.std(values) for values in data ])\n", " decimation_sers[decimation] = list(zip(amps, sers, stds))\n", " \n", + " amps = [ amp*1000 for amp in amps ]\n", " l, = ax.plot(amps, np.clip(sers, 0, 1), label=f'decimation={decimation}', color=cm_func(decimation))\n", " ax.fill_between(amps, np.clip(sers + stds, 0, 1), np.clip(sers - stds, 0, 1), facecolor=l.get_color(), alpha=0.2)\n", " ax.axhline(0.5, color='gray', ls=(0, (3, 4)), lw=0.8)\n", "ax.grid()\n", - "ax.set_xlabel('Amplitude in mHz')\n", + "ax.set_xlabel('Amplitude [mHz]')\n", "ax.set_ylabel('Symbol error rate')\n", "\n", "norm = matplotlib.colors.Normalize(vmin=np.log10(min(decimations)), vmax=np.log10(max(decimations)))\n", - "cb1 = matplotlib.colorbar.ColorbarBase(cbar_ax, cmap=cmap, norm=norm, orientation='vertical', label=\"Decimation\", ticks=[np.log10(d) for d in decimations])\n", - "cb1.ax.set_yticklabels([f'{d:.1f}' for d in decimations])\n", + "yticks = [np.log10(d) for d in decimations]\n", + "cb1 = matplotlib.colorbar.ColorbarBase(cbar_ax, cmap=cmap, norm=norm, orientation='vertical', ticks=yticks)\n", + "cb1t = cbar_ax.twinx()\n", + "cb1t.set_ylim(cbar_ax.get_ylim())\n", + "cb1t.set_yticks(yticks)\n", + "\n", + "cbar_ax.set_yticklabels([f'{d/sampling_rate:.1f}' for d in decimations])\n", + "cbar_ax.set_ylabel(\"chip duration [s]\", labelpad=-70)\n", + "\n", + "cb1t.set_yticklabels([f'{d/sampling_rate * 2**nbits:.1f}' for d in decimations])\n", + "cb1t.set_ylabel(\"symbol duration [s]\")\n", + "\n", "\n", "def plot_intercepts(ax, SER_TH = 0.5):\n", " intercepts = {}\n", @@ -988,8 +1008,10 @@ " std = data[:,1]\n", " \n", " ax.set_xlim([min(x), max(x)])\n", - " l = ax.plot(x, y, label='Amplitude at SER=0.5', color='orange')\n", - " ax.legend(loc=3)\n", + " y = [ v*1000 if v is not None else v for v in y ]\n", + " l = ax.plot(x, y, label='Amplitude at SER=0.5 [mHz]', color='orange')\n", + " #ax.legend(loc=3)\n", + " ax.set_ylabel('Amplitude at SER=0.5 [mHz]')\n", " ax.grid()\n", " \n", " x, y, std = zip(*[ (le_x, le_y, le_std) for le_x, le_y, le_std in zip(x, y, std) if le_y is not None ])\n", @@ -1002,12 +1024,43 @@ " ax.set_ylim([min(y)*0.9, max(y)*1.1])\n", " ax.set_xscale('log')\n", " ax.xaxis.set_major_formatter(matplotlib.ticker.FuncFormatter(lambda x, _: '{:g}'.format(x)))\n", - " ax.set_xticks([1, 2, 5, 10, 20, 50])\n", + " xticks = [1, 2, 5, 10, 20, 50]\n", + " ax.set_xticks(xticks)\n", + " ax.set_xticklabels([ f'{x/sampling_rate:.1f}' for x in xticks ])\n", " ax.set_xlim([1, 60])\n", + " ax.set_xlabel('chip duration [s]')\n", + " \n", + " axt = ax.twiny()\n", + " axt.set_xlim(ax.get_xlim())\n", + " axt.set_xscale('log')\n", + " axt.set_xticks(xticks)\n", + " axt.set_xticklabels([ f'{x/sampling_rate * 2**nbits:.1f}' for x in xticks ])\n", + " axt.set_xlabel('symbol duration [s]')\n", + " \n", " return l\n", "\n", "l1 = plot_intercepts(intercept_ax)\n" ] + }, + { + "cell_type": "code", + "execution_count": 227, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "41.6" + ] + }, + "execution_count": 227, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "13 * 2**5 / 10" + ] } ], "metadata": { |