diff options
author | sara <sara.halter@gmx.ch> | 2021-12-10 17:54:18 +0100 |
---|---|---|
committer | sara <sara.halter@gmx.ch> | 2021-12-10 17:54:18 +0100 |
commit | 93844f6eb9dba5f84ccb55101d14d11513e53232 (patch) | |
tree | 43c0ea4699d6ed80904dc60a4299905e4956786e | |
parent | Map test (diff) | |
download | Fading-93844f6eb9dba5f84ccb55101d14d11513e53232.tar.gz Fading-93844f6eb9dba5f84ccb55101d14d11513e53232.zip |
QAM16 Maps angepasst
-rw-r--r-- | notebooks/FrameSynchronization.ipynb | 64 | ||||
-rw-r--r-- | notebooks/Untitled.ipynb | 50 | ||||
-rwxr-xr-x | tests/Map/Map_test.py | 32 | ||||
-rw-r--r-- | tests/Map/Map_tets.grc | 64 |
4 files changed, 58 insertions, 152 deletions
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<module>\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": [ - "<map at 0x7f2fe63da820>" + "<map at 0x7fb7d4904a60>" ] }, "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]))" ] }, { diff --git a/tests/Map/Map_test.py b/tests/Map/Map_test.py index f7b478f..96a5b15 100755 --- a/tests/Map/Map_test.py +++ b/tests/Map/Map_test.py @@ -36,18 +36,14 @@ class Map_test(gr.top_block): self.v0 = v0 = -0.7071067811865475-0.7071067811865475j self.samp_rate = samp_rate = 32000 self.const = const = digital.constellation_16qam().base() - self.a3 = a3 = -9.486832980505138-9.486832980505138j - self.a2 = a2 = 9.486832980505138-9.486832980505138j - self.a1 = a1 = -3.162277660168379-3.162277660168379j - self.a0 = a0 = 3.162277660168379-3.162277660168379j ################################################## # Blocks ################################################## self.epy_block_1 = epy_block_1.blk() self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(const) - self.blocks_vector_source_x_1_0 = blocks.vector_source_c([(-0.9486832980505138-0.31622776601683794j), (-0.9486832980505138-0.31622776601683794j)], True, 1, []) - self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(2, 8, "", False, gr.GR_MSB_FIRST) + self.blocks_vector_source_x_1_0 = blocks.vector_source_c([(-0.9486832980505138-0.9486832980505138j), (0.9486832980505138+0.9486832980505138j)], True, 1, []) + self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(4, 8, "", False, gr.GR_MSB_FIRST) @@ -95,30 +91,6 @@ class Map_test(gr.top_block): def set_const(self, const): self.const = const - def get_a3(self): - return self.a3 - - def set_a3(self, a3): - self.a3 = a3 - - def get_a2(self): - return self.a2 - - def set_a2(self, a2): - self.a2 = a2 - - def get_a1(self): - return self.a1 - - def set_a1(self, a1): - self.a1 = a1 - - def get_a0(self): - return self.a0 - - def set_a0(self, a0): - self.a0 = a0 - diff --git a/tests/Map/Map_tets.grc b/tests/Map/Map_tets.grc index 1002b25..ffaa6e0 100644 --- a/tests/Map/Map_tets.grc +++ b/tests/Map/Map_tets.grc @@ -32,54 +32,6 @@ options: state: enabled blocks: -- name: a0 - id: variable - parameters: - comment: '' - value: 3.162277660168379-3.162277660168379j - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [552, 52.0] - rotation: 0 - state: enabled -- name: a1 - id: variable - parameters: - comment: '' - value: -3.162277660168379-3.162277660168379j - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [552, 116.0] - rotation: 0 - state: enabled -- name: a2 - id: variable - parameters: - comment: '' - value: 9.486832980505138-9.486832980505138j - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [552, 180.0] - rotation: 0 - state: enabled -- name: a3 - id: variable - parameters: - comment: '' - value: -9.486832980505138-9.486832980505138j - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [552, 244.0] - rotation: 0 - state: enabled - name: const id: variable_constellation parameters: @@ -95,7 +47,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [264, 420.0] + coordinate: [984, 388.0] rotation: 0 state: enabled - name: samp_rate @@ -119,7 +71,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [712, 428.0] + coordinate: [712, 404.0] rotation: 0 state: enabled - name: v1 @@ -131,7 +83,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [712, 492.0] + coordinate: [712, 468.0] rotation: 0 state: enabled - name: v2 @@ -143,7 +95,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [712, 556.0] + coordinate: [712, 532.0] rotation: 0 state: enabled - name: v3 @@ -155,7 +107,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [712, 620.0] + coordinate: [712, 596.0] rotation: 0 state: enabled - name: blocks_repack_bits_bb_0 @@ -166,7 +118,7 @@ blocks: align_output: 'False' comment: '' endianness: gr.GR_MSB_FIRST - k: '2' + k: '4' l: '8' len_tag_key: '""' maxoutbuf: '0' @@ -189,7 +141,7 @@ blocks: repeat: 'True' tags: '[]' type: complex - vector: '[(-0.9486832980505138-0.31622776601683794j), (-0.9486832980505138-0.31622776601683794j)]' + vector: '[(-0.9486832980505138-0.9486832980505138j), (0.9486832980505138+0.9486832980505138j)]' vlen: '1' states: bus_sink: false @@ -253,7 +205,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [1664, 336.0] + coordinate: [1632, 336.0] rotation: 0 state: enabled - name: import_0 |