Peak-to-average power

import matplotlib.pyplot as plt
import numpy as np

import sdr

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

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.modulate(s)
span = 8  # Length of the pulse shape in symbols
sps = 20  # 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.to_real_pb(bb)

    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(figsize=(10, 5))
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.legend()
plt.title("Baseband QPSK with SRRC pulse shaping")
plt.tight_layout()
plt.show()
../../_images/4a83d8b95471af52dec662011519ede8abdb2dcb87b5bc673b31d893298ada0f.png
plt.figure(figsize=(10, 5))
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.legend()
plt.title("Passband QPSK with SRRC pulse shaping")
plt.tight_layout()
plt.show()
../../_images/eead71d6823c0216e24f19ed07ed0d924b6e23d2ad664b4b926b943d9238f057.png

Examine frequency domain

plt.figure(figsize=(10, 5))
sdr.plot.periodogram(x_bb_rect, length=1024, overlap=1024 - 256, label=f"Rectangular, PAPR = {papr_bb_rect:.2f} dB")
sdr.plot.periodogram(x_bb_0p9, length=1024, overlap=1024 - 256, label=rf"$\alpha = 0.9$, PAPR = {papr_bb_0p9:.2f} dB")
sdr.plot.periodogram(x_bb_0p5, length=1024, overlap=1024 - 256, label=rf"$\alpha = 0.5$, PAPR = {papr_bb_0p5:.2f} dB")
sdr.plot.periodogram(x_bb_0p1, length=1024, overlap=1024 - 256, 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/48c071f80ddb5ea5f727d9b7fa95055561020497ab471e4861bf291b08e06217.png
plt.figure(figsize=(10, 5))
sdr.plot.periodogram(
    x_pb_rect,
    length=2048,
    overlap=2048 - 512,
    x_axis="one-sided",
    label=f"Rectangular, PAPR = {papr_pb_rect:.2f} dB",
)
sdr.plot.periodogram(
    x_pb_0p9,
    length=2048,
    overlap=2048 - 512,
    x_axis="one-sided",
    label=rf"$\alpha = 0.9$, PAPR = {papr_pb_0p9:.2f} dB",
)
sdr.plot.periodogram(
    x_pb_0p5,
    length=2048,
    overlap=2048 - 512,
    x_axis="one-sided",
    label=rf"$\alpha = 0.5$, PAPR = {papr_pb_0p5:.2f} dB",
)
sdr.plot.periodogram(
    x_pb_0p1,
    length=2048,
    overlap=2048 - 512,
    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/449b23d51286b6b4fd6a92c921fa84e6c01cb3a4fbf1e15a11475d81b1b24350.png

Plot across excess bandwidth

def sweep_alpha(order):
    bpsk = sdr.PSK(order)
    N_symbols = 1_000
    s = np.random.randint(0, bpsk.order, N_symbols)
    x = bpsk.modulate(s)

    alphas = np.linspace(0, 1, 20)
    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.to_real_pb(bb)

        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(figsize=(10, 5))
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.grid(True)
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/fbfc8251e73c6c68363d58fbf0e19d32cc9d9572edf507dfbe8ff45136a9c219.png
plt.figure(figsize=(10, 5))
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.grid(True)
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/d0ac7291e85ac18321d63b625b51be44170a8dd73ef09185de9c137983161d7b.png

Last update: Aug 13, 2023