aboutsummaryrefslogtreecommitdiffstats
path: root/notebooks/Untitled.ipynb
diff options
context:
space:
mode:
authorsara <sara.halter@gmx.ch>2021-12-09 18:38:20 +0100
committersara <sara.halter@gmx.ch>2021-12-09 18:38:20 +0100
commitc9ce47670c3ff124abde569c8b5baf675413f68a (patch)
tree23ef12b120d38bfba647e170ebfa3d46cab652c8 /notebooks/Untitled.ipynb
parentBegin tag stream to vector stream (diff)
downloadFading-c9ce47670c3ff124abde569c8b5baf675413f68a.tar.gz
Fading-c9ce47670c3ff124abde569c8b5baf675413f68a.zip
Map test
Diffstat (limited to '')
-rw-r--r--notebooks/Untitled.ipynb278
1 files changed, 278 insertions, 0 deletions
diff --git a/notebooks/Untitled.ipynb b/notebooks/Untitled.ipynb
new file mode 100644
index 0000000..23109f8
--- /dev/null
+++ b/notebooks/Untitled.ipynb
@@ -0,0 +1,278 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "9aef28b0",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import numpy as np "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "412e054c",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def modulate_qpsk(m):\n",
+ " ampl = np.sqrt(2)\n",
+ " sym = {\n",
+ " 0: ampl * (-1 -1j)/np.sqrt(2),\n",
+ " 1: ampl * ( 1 -1j)/np.sqrt(2),\n",
+ " 2: ampl * (-1 +1j)/np.sqrt(2),\n",
+ " 3: ampl * ( 1 +1j)/np.sqrt(2)\n",
+ " }\n",
+ "\n",
+ " return map(lambda k: sym[k], m)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "c340fb0f",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "<map at 0x7f2fe63da820>"
+ ]
+ },
+ "execution_count": 3,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "modulate_qpsk([0])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "b4881afe",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'0x1f'"
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "hex(31)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "id": "2c43411f",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'0b1010101'"
+ ]
+ },
+ "execution_count": 24,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "bin(0x55)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "f65a2e47",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(0.7071067811865475+0.7071067811865475j)"
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "a=(1 +1j)/np.sqrt(2)\n",
+ "a"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "3c15cd13",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(-9.486832980505138-9.486832980505138j)"
+ ]
+ },
+ "execution_count": 7,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "-3/np.sqrt(0.1)-3j/np.sqrt(0.1)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "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"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "id": "01626f53",
+ "metadata": {
+ "scrolled": true
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "[(-0.9486832980505138-0.31622776601683794j),\n",
+ " (-0.9486832980505138-0.31622776601683794j)]"
+ ]
+ },
+ "execution_count": 25,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "list(modulate_16qam([1, 1]))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "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",
+ " 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]*np.sqrt(0.1), m)\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "id": "f263ed95",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "[(-0.31622776601683794-0.31622776601683794j),\n",
+ " (-0.31622776601683794-0.31622776601683794j)]"
+ ]
+ },
+ "execution_count": 23,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "list(modulate_16qam_2([1,1]))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "27855d88",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.9.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}