Peak-to-average power

import matplotlib.pyplot as plt
import numpy as np

import sdr

%config InlineBackend.print_figure_kwargs = {"facecolor" : "w"}
%matplotlib inline
# %matplotlib widget

sdr.plot.use_style()

QPSK signal with various pulse shapes

qpsk = sdr.PSK(4, phase_offset=45)
N_symbols = 1_000
s = np.random.randint(0, qpsk.order, N_symbols)
x = qpsk.map_symbols(s)
span = 10  # Length of the pulse shape in symbols
sps = 200  # Samples per symbol
def pulse_shape(alpha):
    if alpha is None:
        h = np.zeros(span * sps + 1)
        h[span * sps // 2 - sps // 2 : span * sps // 2 + sps // 2] = 1 / np.sqrt(sps)
    else:
        h = sdr.root_raised_cosine(alpha, span, sps)
    fir = sdr.Interpolator(sps, h)

    bb = fir(x)
    pb = sdr.mix(bb, 0.02)
    pb = pb.real

    return bb, sdr.papr(bb), pb, sdr.papr(pb)
x_bb_rect, papr_bb_rect, x_pb_rect, papr_pb_rect = pulse_shape(None)
x_bb_0p1, papr_bb_0p1, x_pb_0p1, papr_pb_0p1 = pulse_shape(0.1)
x_bb_0p5, papr_bb_0p5, x_pb_0p5, papr_pb_0p5 = pulse_shape(0.5)
x_bb_0p9, papr_bb_0p9, x_pb_0p9, papr_pb_0p9 = pulse_shape(0.9)

Examine time domain

plt.figure()
sdr.plot.time_domain(x_bb_rect, color="k", label=f"Rectangular, PAPR = {papr_bb_rect:.2f} dB", diff="line")
sdr.plot.time_domain(x_bb_0p9, label=rf"$\alpha = 0.9$, PAPR = {papr_bb_0p9:.2f} dB", diff="line")
sdr.plot.time_domain(x_bb_0p5, label=rf"$\alpha = 0.5$, PAPR = {papr_bb_0p5:.2f} dB", diff="line")
sdr.plot.time_domain(x_bb_0p1, label=rf"$\alpha = 0.1$, PAPR = {papr_bb_0p1:.2f} dB", diff="line")
plt.xlim(25 * sps, 50 * sps)
plt.title("Baseband QPSK with SRRC pulse shaping")
plt.show()
../../_images/6670c4dcd3ae17a78205ff0d1e2423672f749bab8570c3810ed1801bd149f058.png
plt.figure()
sdr.plot.time_domain(x_pb_rect, color="k", label=f"Rectangular, PAPR = {papr_pb_rect:.2f} dB")
sdr.plot.time_domain(x_pb_0p9, label=rf"$\alpha = 0.9$, PAPR = {papr_pb_0p9:.2f} dB")
sdr.plot.time_domain(x_pb_0p5, label=rf"$\alpha = 0.5$, PAPR = {papr_pb_0p5:.2f} dB")
sdr.plot.time_domain(x_pb_0p1, label=rf"$\alpha = 0.1$, PAPR = {papr_pb_0p1:.2f} dB")
plt.xlim(25 * sps, 50 * sps)
plt.title("Passband QPSK with SRRC pulse shaping")
plt.show()
../../_images/9113245e39a99781eb4a3c0d0fd64377f98d30b4b9579cf2d9e0efee8d1b0411.png

Examine frequency domain

plt.figure()
sdr.plot.periodogram(x_bb_rect, length=2**12, overlap=2**11, label=f"Rectangular, PAPR = {papr_bb_rect:.2f} dB")
sdr.plot.periodogram(x_bb_0p9, length=2**12, overlap=2**11, label=rf"$\alpha = 0.9$, PAPR = {papr_bb_0p9:.2f} dB")
sdr.plot.periodogram(x_bb_0p5, length=2**12, overlap=2**11, label=rf"$\alpha = 0.5$, PAPR = {papr_bb_0p5:.2f} dB")
sdr.plot.periodogram(x_bb_0p1, length=2**12, overlap=2**11, label=rf"$\alpha = 0.1$, PAPR = {papr_bb_0p1:.2f} dB")
plt.title("Power spectral density of baseband QPSK with SRRC pulse shaping")
plt.show()
../../_images/f4d483158ec6d7185ebd065225d7f0e613ce77c5abcd626c6d79f7295147546f.png
plt.figure()
sdr.plot.periodogram(
    x_pb_rect,
    length=2**12,
    overlap=2**11,
    x_axis="one-sided",
    label=f"Rectangular, PAPR = {papr_pb_rect:.2f} dB",
)
sdr.plot.periodogram(
    x_pb_0p9,
    length=2**12,
    overlap=2**11,
    x_axis="one-sided",
    label=rf"$\alpha = 0.9$, PAPR = {papr_pb_0p9:.2f} dB",
)
sdr.plot.periodogram(
    x_pb_0p5,
    length=2**12,
    overlap=2**11,
    x_axis="one-sided",
    label=rf"$\alpha = 0.5$, PAPR = {papr_pb_0p5:.2f} dB",
)
sdr.plot.periodogram(
    x_pb_0p1,
    length=2**12,
    overlap=2**11,
    x_axis="one-sided",
    label=rf"$\alpha = 0.1$, PAPR = {papr_pb_0p1:.2f} dB",
)
plt.title("Power spectral density of passband QPSK with SRRC pulse shaping")
plt.show()
../../_images/f72828f89c2ff8fbebc0bc52dfcfc4856665dada5e9ca38e7826694015b7b53b.png

Plot across excess bandwidth

def sweep_alpha(order):
    psk = sdr.PSK(order)
    N_symbols = 10_000
    s = np.random.randint(0, psk.order, N_symbols)
    x = psk.map_symbols(s)

    alphas = np.linspace(0, 1, 101)
    bb_papr = []
    pb_papr = []

    for alpha in alphas:
        h = sdr.root_raised_cosine(alpha, span, sps)
        fir = sdr.Interpolator(sps, h)

        bb = fir(x)
        pb = sdr.mix(bb, 0.02)
        pb = pb.real

        bb_papr.append(sdr.papr(bb))
        pb_papr.append(sdr.papr(pb))

    return alphas, bb_papr, pb_papr
alpha, bpsk_bb_papr, bpsk_pb_papr = sweep_alpha(2)
alpha, qpsk_bb_papr, qpsk_pb_papr = sweep_alpha(4)
alpha, psk8_bb_papr, psk8_pb_papr = sweep_alpha(8)
alpha, psk16_bb_papr, psk16_pb_papr = sweep_alpha(16)
plt.figure()
plt.plot(alpha, bpsk_bb_papr, label="BPSK")
plt.plot(alpha, qpsk_bb_papr, label="QPSK")
plt.plot(alpha, psk8_bb_papr, label="8-PSK")
plt.plot(alpha, psk16_bb_papr, label="16-PSK")
plt.legend()
plt.xlabel(r"SRRC excess bandwidth, $\alpha$")
plt.ylabel("Peak-to-average-power (PAPR)")
plt.title("PAPR for baseband PSK across SRRC excess bandwidth")
plt.show()
../../_images/71e1b18433321d4cfb712cce70b93f20cf5b6dba89bfa297154cc3b6dd2610f1.png
plt.figure()
plt.plot(alpha, bpsk_pb_papr, label="BPSK")
plt.plot(alpha, qpsk_pb_papr, label="QPSK")
plt.plot(alpha, psk8_pb_papr, label="8-PSK")
plt.plot(alpha, psk16_pb_papr, label="16-PSK")
plt.legend()
plt.xlabel(r"SRRC excess bandwidth, $\alpha$")
plt.ylabel("Peak-to-average-power (PAPR)")
plt.title("PAPR for passband PSK across SRRC excess bandwidth")
plt.show()
../../_images/19730e7850ca0dd809176ffcf0fea6e700816c1839e060091c607f5c00e2e1dc.png

Last update: Jun 15, 2024