Add BER curve for DSSS experiments
This commit is contained in:
parent
61accdf087
commit
9a833efed9
2 changed files with 556 additions and 35 deletions
|
|
@ -28,6 +28,15 @@
|
|||
"%matplotlib widget"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 105,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sampling_rate = 10 # sp/s"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
|
|
@ -410,29 +419,29 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 96,
|
||||
"execution_count": 145,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"(31,) (31,)\n",
|
||||
"(31,) (31,)\n"
|
||||
"(63,) (63,)\n",
|
||||
"(63,) (63,)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"<ipython-input-96-b3aae757ccad>:33: 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-145-babcf8a4e867>:33: 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, ((ax1, ax3), (ax2, ax4)) = plt.subplots(2, 2, figsize=(16, 9))\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "246c19a3c1424e7eb0b675ff060ea5b3",
|
||||
"model_id": "10aa67d294304f2ba26c8e6d5555d5e6",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
|
|
@ -446,10 +455,10 @@
|
|||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"(0.002, 0.013899708)"
|
||||
"(0.002, 0.014074279)"
|
||||
]
|
||||
},
|
||||
"execution_count": 96,
|
||||
"execution_count": 145,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
|
|
@ -457,15 +466,15 @@
|
|||
"source": [
|
||||
"decimation = 10\n",
|
||||
"signal_amplitude = 2.0e-3\n",
|
||||
"nbits = 5\n",
|
||||
"nbits = 6\n",
|
||||
"\n",
|
||||
"#test_data = np.random.randint(0, 2, 100)\n",
|
||||
"#test_data = np.array([0, 1, 0, 0, 1, 1, 1, 0])\n",
|
||||
"#test_data = np.random.RandomState(seed=0).randint(0, 2 * (2**nbits), 64)\n",
|
||||
"test_data = np.random.RandomState(seed=0).randint(0, 2 * (2**nbits), 64)\n",
|
||||
"#test_data = np.random.RandomState(seed=0).randint(0, 8, 64)\n",
|
||||
"#test_data = np.array(list(range(8)) * 8)\n",
|
||||
"#test_data = np.array([0, 1] * 32)\n",
|
||||
"test_data = np.array(list(range(64)))\n",
|
||||
"#test_data = np.array(list(range(64)))\n",
|
||||
"\n",
|
||||
"foo = np.repeat(modulate(test_data, nbits) * 2.0 - 1, decimation) * signal_amplitude\n",
|
||||
"noise = np.resize(mains_noise, len(foo))\n",
|
||||
|
|
@ -493,12 +502,20 @@
|
|||
"ax1.plot(foo + noise)\n",
|
||||
"ax1.plot(foo)\n",
|
||||
"ax1.set_title('raw')\n",
|
||||
"ax1.grid(axis='y')\n",
|
||||
"\n",
|
||||
"ax2.plot(filtered)\n",
|
||||
"ax2.plot(foo)\n",
|
||||
"ax2.set_title('filtered')\n",
|
||||
"ax2.grid(axis='y')\n",
|
||||
"\n",
|
||||
"ax3.plot(cor1.T)\n",
|
||||
"for i in range(0, len(foo) + 1, decimation*(2**nbits - 1)):\n",
|
||||
" ax1.axvline(i, color='gray', alpha=0.5, lw=1)\n",
|
||||
" ax2.axvline(i, color='gray', alpha=0.5, lw=1)\n",
|
||||
"\n",
|
||||
"for i, (color, trace) in enumerate(zip(plt.cm.winter(np.linspace(0, 1, cor1.shape[0])), cor1.T)):\n",
|
||||
" if i%3 == 0:\n",
|
||||
" ax3.plot(trace + 0.5 * i, alpha=1.0, color=color)\n",
|
||||
"ax3.set_title('corr raw')\n",
|
||||
"ax3.grid()\n",
|
||||
"\n",
|
||||
|
|
@ -678,21 +695,21 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 97,
|
||||
"execution_count": 146,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"<ipython-input-97-2d2c2f814215>:11: 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-146-badd40342f73>:11: 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, (ax1, ax3) = plt.subplots(2, figsize=(12, 5))\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "b083c661b5b441d6b7fc45201faa0576",
|
||||
"model_id": "509bf67d93b74741b48bca58529c4b9d",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
|
|
@ -707,26 +724,24 @@
|
|||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"cor_an (33, 20149)\n",
|
||||
"cwt_res (33, 20149)\n",
|
||||
"th (33, 20149)\n",
|
||||
"[((33,), (33,)), ((33,), (33,)), ((33,), (33,)), ((33,), (33,)), ((33,), (33,))]\n",
|
||||
"peaks: 180\n",
|
||||
"avg_peak 1.058897833824206\n",
|
||||
"skipped 3 symbols at 5889.0\n",
|
||||
"skipped 2 symbols at 8369.0\n",
|
||||
"skipped 2 symbols at 14568.5\n",
|
||||
"skipped 2 symbols at 16739.0\n",
|
||||
"cor_an (65, 40949)\n",
|
||||
"cwt_res (65, 40949)\n",
|
||||
"th (65, 40949)\n",
|
||||
"[((65,), (65,)), ((65,), (65,)), ((65,), (65,)), ((65,), (65,)), ((65,), (65,))]\n",
|
||||
"peaks: 982\n",
|
||||
"avg_peak 1.6673786030736735\n",
|
||||
"skipped 2 symbols at 30238.5\n",
|
||||
"decoding [ref|dec]:\n",
|
||||
" -1| -1 ✔ 1| 1 ✔ 2| 2 ✔ 3| 3 ✔ 4| 4 ✔ 5| 5 ✔ 6| 6 ✔ 7| 7 ✔ \n",
|
||||
" 8| 8 ✔ 9| 9 ✔ 10| 10 ✔ 11| 11 ✔ 12| 12 ✔ 13| 13 ✔ 14| 14 ✔ 15| 15 ✔ \n",
|
||||
" 16| -1 ✘ 17| -1 ✘ 18| 18 ✔ 19| 19 ✔ 20| 20 ✔ 21| 21 ✔ 22| 22 ✔ 23| 23 ✔ \n",
|
||||
" 24| 24 ✔ 25| -1 ✘ 26| 26 ✔ 27| 27 ✔ 28| 28 ✔ 29| 29 ✔ 30| 30 ✔ 31| 31 ✔ \n",
|
||||
" 32| 32 ✔ 33| 33 ✔ 34| 34 ✔ 35| 35 ✔ 36| 36 ✔ 37| 37 ✔ 38| 38 ✔ 39| 39 ✔ \n",
|
||||
" 40| 40 ✔ 41| 41 ✔ 42| 42 ✔ 43| 43 ✔ 44| 44 ✔ 45| -1 ✘ 46| 46 ✔ 47| 47 ✔ \n",
|
||||
" 48| 48 ✔ 49| 49 ✔ 50| 50 ✔ 51| 51 ✔ 52| -1 ✘ 53| 53 ✔ 54| 54 ✔ 55| 55 ✔ \n",
|
||||
" 56| 56 ✔ 57| 57 ✔ 58| 58 ✔ 59| 59 ✔ 60| 60 ✔ 61| 61 ✔ 62| 62 ✔ 63| 56 ✘ \n",
|
||||
"Symbol error rate r=0.09375\n"
|
||||
" 44| 44 ✔ 47| 47 ✔ 117|117 ✔ 64| 64 ✔ 67| 67 ✔ 123|123 ✔ 67| 67 ✔ 103|103 ✔ \n",
|
||||
" 9| 9 ✔ 83| 83 ✔ 21| 21 ✔ 114|114 ✔ 36| 36 ✔ 87| 87 ✔ 70| 70 ✔ 88| 88 ✔ \n",
|
||||
" 88| 88 ✔ 12| 12 ✔ 58| 58 ✔ 65| 65 ✔ 102|102 ✔ 39| 39 ✔ 87| 87 ✔ 46| 46 ✔ \n",
|
||||
" 88| 88 ✔ 81| 81 ✔ 37| 37 ✔ 25| 25 ✔ 77| 77 ✔ 72| 72 ✔ 9| 9 ✔ 20| 20 ✔ \n",
|
||||
"115|115 ✔ 80| 80 ✔ 115|115 ✔ 69| 69 ✔ 126|126 ✔ 79| 79 ✔ 47| 47 ✔ 64| 64 ✔ \n",
|
||||
" 82| 82 ✔ 99| 99 ✔ 88| 88 ✔ 49| 49 ✔ 115|115 ✔ 29| 29 ✔ 19| -1 19| 19 ✔ \n",
|
||||
" 14| 14 ✔ 39| 39 ✔ 32| 32 ✔ 65| 64 ✘ 9| 9 ✔ 57| 57 ✔ 127|127 ✔ 32| 32 ✔ \n",
|
||||
" 31| 31 ✔ 74| 74 ✔ 116|116 ✔ 23| 23 ✔ 35| 35 ✔ 126|126 ✔ 75| 75 ✔ 114| 26 ✘ \n",
|
||||
"Symbol error rate e=0.046875\n",
|
||||
"maximum bitrate r=321.6796875 b/h\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -869,12 +884,13 @@
|
|||
"print('decoding [ref|dec]:')\n",
|
||||
"failures = 0\n",
|
||||
"for i, (ref, found) in enumerate(itertools.zip_longest(test_data, decoded)):\n",
|
||||
" print(f'{ref or -1:>3d}|{found or -1:>3d} {\"✔\" if ref==found else \"✘\"}', end=' ')\n",
|
||||
" print(f'{ref or -1:>3d}|{found or -1:>3d} {\"✔\" if ref==found else \"✘\" if found else \" \"}', end=' ')\n",
|
||||
" if ref != found:\n",
|
||||
" failures += 1\n",
|
||||
" if i%8 == 7:\n",
|
||||
" print()\n",
|
||||
"print(f'Symbol error rate r={failures/len(test_data)}')\n",
|
||||
"print(f'Symbol error rate e={failures/len(test_data)}')\n",
|
||||
"print(f'maximum bitrate r={sampling_rate / decimation / (2**nbits) * nbits * (1 - failures/len(test_data)) * 3600} b/h')\n",
|
||||
"#ax3.plot(th)"
|
||||
]
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue