Skip to content

Commit e440590

Browse files
committed
add example that shows PAPR reduction by using nrTransformPrecode()
1 parent 6f0b35f commit e440590

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

examples/papr_comparison.ipynb

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 7,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import numpy as np\n",
10+
"import matplotlib.pyplot as plt\n",
11+
"from py3gpp import *"
12+
]
13+
},
14+
{
15+
"cell_type": "code",
16+
"execution_count": 58,
17+
"metadata": {},
18+
"outputs": [],
19+
"source": [
20+
"NFFT = 10\n",
21+
"ZERO_CARRIER = 400"
22+
]
23+
},
24+
{
25+
"cell_type": "code",
26+
"execution_count": 72,
27+
"metadata": {},
28+
"outputs": [
29+
{
30+
"name": "stdout",
31+
"output_type": "stream",
32+
"text": [
33+
"PAPR = 9.322 dB\n"
34+
]
35+
}
36+
],
37+
"source": [
38+
"cw = np.random.randint(0, 2, (2**NFFT - ZERO_CARRIER)*2)\n",
39+
"grid = np.zeros((2**NFFT, 1), np.complex128)\n",
40+
"grid[ZERO_CARRIER//2:-ZERO_CARRIER//2, 0] = nrSymbolModulate(cw, 'QPSK')\n",
41+
"waveform, _ = nrOFDMModulate(grid = grid)\n",
42+
"power = np.real(np.multiply(waveform, waveform.conj()))\n",
43+
"print(f\"PAPR = {10*np.log10(np.max(power)/np.mean(power)):.04} dB\")"
44+
]
45+
},
46+
{
47+
"cell_type": "code",
48+
"execution_count": null,
49+
"metadata": {},
50+
"outputs": [
51+
{
52+
"name": "stdout",
53+
"output_type": "stream",
54+
"text": [
55+
"PAPR = 6.304 dB\n"
56+
]
57+
}
58+
],
59+
"source": [
60+
"grid[ZERO_CARRIER//2:-ZERO_CARRIER//2, 0] = nrTransformPrecode(nrSymbolModulate(cw, 'QPSK'), (2**NFFT - ZERO_CARRIER)//12)\n",
61+
"waveform, _ = nrOFDMModulate(grid = grid)\n",
62+
"power = np.real(np.multiply(waveform, waveform.conj()))\n",
63+
"print(f\"PAPR with DFT-s precoding = {10*np.log10(np.max(power)/np.mean(power)):.04} dB\")"
64+
]
65+
}
66+
],
67+
"metadata": {
68+
"kernelspec": {
69+
"display_name": "Python 3",
70+
"language": "python",
71+
"name": "python3"
72+
},
73+
"language_info": {
74+
"codemirror_mode": {
75+
"name": "ipython",
76+
"version": 3
77+
},
78+
"file_extension": ".py",
79+
"mimetype": "text/x-python",
80+
"name": "python",
81+
"nbconvert_exporter": "python",
82+
"pygments_lexer": "ipython3",
83+
"version": "3.10.12"
84+
}
85+
},
86+
"nbformat": 4,
87+
"nbformat_minor": 2
88+
}

0 commit comments

Comments
 (0)