From 93844f6eb9dba5f84ccb55101d14d11513e53232 Mon Sep 17 00:00:00 2001 From: sara Date: Fri, 10 Dec 2021 17:54:18 +0100 Subject: QAM16 Maps angepasst --- notebooks/FrameSynchronization.ipynb | 64 ++++++++++++++++++++---------------- notebooks/Untitled.ipynb | 50 +++++++--------------------- 2 files changed, 48 insertions(+), 66 deletions(-) (limited to 'notebooks') diff --git a/notebooks/FrameSynchronization.ipynb b/notebooks/FrameSynchronization.ipynb index b9e3871..9902c18 100644 --- a/notebooks/FrameSynchronization.ipynb +++ b/notebooks/FrameSynchronization.ipynb @@ -188,49 +188,49 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 1, "id": "b56d782d-fcea-4fb9-b0c1-9c3933d5ce6c", "metadata": {}, "outputs": [], "source": [ "def modulate_16qam(m):\n", " sym = {\n", - " # first column\n", - " 0: -3 -3j,\n", - " 1: -3 -1j,\n", - " 2: -3 +3j,\n", - " 3: -3 +1j,\n", - " # second column\n", - " 4: -1 -3j,\n", - " 5: -1 -1j,\n", - " 6: -1 +3j,\n", - " 7: -1 +1j,\n", - " # fourth column\n", - " 8: 3 -3j,\n", - " 9: 3 -1j,\n", - " 10: 3 +3j,\n", - " 11: 3 +1j,\n", - " # third column\n", - " 12: 3 -3j,\n", - " 13: 3 -1j,\n", - " 14: 3 +3j,\n", - " 15: 3 +1j,\n", + " 0: 1 -1j,\n", + " 1: -1 -1j,\n", + " 2: 3 -3j,\n", + " 3: -3 -3j,\n", + " 4: -3 -1j,\n", + " 5: 3 -1j,\n", + " 6: -1 -3j,\n", + " 7: 1 -3j,\n", + " 8: -3 +3j,\n", + " 9: 3 +3j,\n", + " 10: -1 +1j,\n", + " 11: 1 +1j,\n", + " 12: 1 +3j,\n", + " 13: -1 +3j,\n", + " 14: 3 +1j,\n", + " 15: -3 +1j,\n", + " \n", " }\n", - " return map(lambda k: sym[k] if k in sym.keys() else None, m)" + " return map(lambda k: sym[k]*np.sqrt(0.1), m)\n" ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 2, "id": "2fb687aa-0061-4626-bf6b-3ec7d628d739", "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1, 10, 3, 4]\n", - "[(-3-1j), (3+3j), (-3+1j), (-1-3j)]\n" + "ename": "NameError", + "evalue": "name 'np' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/tmp/ipykernel_2456/3352720696.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# convert into chunks of 4 bits for QPSK\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mchunks\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlist\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmatmul\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mac_pad\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0msyms\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlist\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmodulate_16qam\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mchunks\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mchunks\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mNameError\u001b[0m: name 'np' is not defined" ] } ], @@ -242,6 +242,14 @@ "print(chunks)\n", "print(syms)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5951be43", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/notebooks/Untitled.ipynb b/notebooks/Untitled.ipynb index 23109f8..cdc5f74 100644 --- a/notebooks/Untitled.ipynb +++ b/notebooks/Untitled.ipynb @@ -38,7 +38,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 3, @@ -73,7 +73,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 5, "id": "2c43411f", "metadata": {}, "outputs": [ @@ -83,7 +83,7 @@ "'0b1010101'" ] }, - "execution_count": 24, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -141,36 +141,11 @@ "id": "cb3fdfcc", "metadata": {}, "outputs": [], - "source": [ - "def modulate_16qam(m):\n", - " sym = {\n", - " # first column\n", - " 0: -3 -3j,\n", - " 1: -3 -1j,\n", - " 2: -3 +3j,\n", - " 3: -3 +1j,\n", - " # second column\n", - " 4: -1 -3j,\n", - " 5: -1 -1j,\n", - " 6: -1 +3j,\n", - " 7: -1 +1j,\n", - " # fourth column\n", - " 8: 3 -3j,\n", - " 9: 3 -1j,\n", - " 10: 3 +3j,\n", - " 11: 3 +1j,\n", - " # third column\n", - " 12: 1 -3j,\n", - " 13: 1 -1j,\n", - " 14: 1 +3j,\n", - " 15: 1 +1j,\n", - " }\n", - " return map(lambda k: sym[k]*np.sqrt(0.1), m)\n" - ] + "source": [] }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 9, "id": "01626f53", "metadata": { "scrolled": true @@ -183,7 +158,7 @@ " (-0.9486832980505138-0.31622776601683794j)]" ] }, - "execution_count": 25, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -194,14 +169,13 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 10, "id": "df5b6858", "metadata": {}, "outputs": [], "source": [ "def modulate_16qam_2(m):\n", " sym = {\n", - " # first column\n", " 0: 1 -1j,\n", " 1: -1 -1j,\n", " 2: 3 -3j,\n", @@ -225,24 +199,24 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 12, "id": "f263ed95", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[(-0.31622776601683794-0.31622776601683794j),\n", - " (-0.31622776601683794-0.31622776601683794j)]" + "[(-0.9486832980505138-0.9486832980505138j),\n", + " (0.9486832980505138+0.9486832980505138j)]" ] }, - "execution_count": 23, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "list(modulate_16qam_2([1,1]))" + "list(modulate_16qam_2([3,9]))" ] }, { -- cgit v1.2.1