Pulse shapes

import matplotlib.pyplot as plt
import numpy as np
import scipy.signal

import sdr

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

sdr.plot.use_style()
span = 8  # Length of the pulse shape in symbols
sps = 10  # Samples per symbol

Create a rectangular pulse shape for reference.

rect = np.zeros(sps * span + 1)
rect[rect.size // 2 - sps // 2 : rect.size // 2 + sps // 2] = 1 / np.sqrt(sps)

Raised cosine

Create three raised cosine pulses with different excess bandwidths. This is achieved using the sdr.raised_cosine() function.

rc_0p1 = sdr.raised_cosine(0.1, span, sps)
rc_0p5 = sdr.raised_cosine(0.5, span, sps)
rc_0p9 = sdr.raised_cosine(0.9, span, sps)
plt.figure()
sdr.plot.impulse_response(rect, color="k", label="Rectangular")
sdr.plot.impulse_response(rc_0p1, label=r"$\alpha = 0.1$")
sdr.plot.impulse_response(rc_0p5, label=r"$\alpha = 0.5$")
sdr.plot.impulse_response(rc_0p9, label=r"$\alpha = 0.9$")
plt.show()
../../_images/a1c9ff5f9a2c217c65e1d965c0cf124b95d4a54e2f143b5a57e6b371d24a0f4e.png

The raised cosine filter is a Nyquist filter. This means that the impulse response \(h[n]\) is zero at adjacent symbols. Specifically, \(h[n] = 0\) for \(n = \pm k\ T_s / T_{sym}\)

plt.figure()
sdr.plot.time_domain(np.roll(rc_0p1, -3 * sps))
sdr.plot.time_domain(np.roll(rc_0p1, -2 * sps))
sdr.plot.time_domain(np.roll(rc_0p1, -1 * sps))
sdr.plot.time_domain(np.roll(rc_0p1, 0 * sps))
sdr.plot.time_domain(np.roll(rc_0p1, 1 * sps))
plt.xlim(0, 60)
plt.title("Raised cosine pulses for adjacent symbols")
plt.show()
../../_images/83d861e1b8f599eac701a11e7c0a80e8ab2ca517173e9505834068291846b0b0.png
plt.figure()
sdr.plot.magnitude_response(rect, sample_rate=sps, color="k", label="Rectangular")
sdr.plot.magnitude_response(rc_0p1, sample_rate=sps, label=r"$\alpha = 0.1$")
sdr.plot.magnitude_response(rc_0p5, sample_rate=sps, label=r"$\alpha = 0.5$")
sdr.plot.magnitude_response(rc_0p9, sample_rate=sps, label=r"$\alpha = 0.9$")
plt.xlabel("Normalized frequency, $f/f_{sym}$")
plt.show()
../../_images/0931b13fd24ff255377247facf87bb44d0c74f3108e1ef782ca71f5c620fceb5.png

Notice the raised cosine pulse with excess bandwidth \(\alpha = 0.1\) has a total bandwidth of nearly \(f_{sym}\). Compare this to \(\alpha = 0.9\), which has a null-to-null bandwidth of nearly \(2 f_{sym}\).

While small \(\alpha\) produces a filter with smaller bandwidth, its side lobes are much higher.

# Compute the one-sided power spectral density of the pulses
w, H_rect = scipy.signal.freqz(rect, 1, worN=1024, whole=False, fs=sps)
w, H_rc_0p1 = scipy.signal.freqz(rc_0p1, 1, worN=1024, whole=False, fs=sps)
w, H_rc_0p5 = scipy.signal.freqz(rc_0p5, 1, worN=1024, whole=False, fs=sps)
w, H_rc_0p9 = scipy.signal.freqz(rc_0p9, 1, worN=1024, whole=False, fs=sps)

# Compute the relative power in the main lobe of the pulses
P_rect = sdr.db(np.cumsum(np.abs(H_rect) ** 2) / np.sum(np.abs(H_rect) ** 2))
P_rc_0p1 = sdr.db(np.cumsum(np.abs(H_rc_0p1) ** 2) / np.sum(np.abs(H_rc_0p1) ** 2))
P_rc_0p5 = sdr.db(np.cumsum(np.abs(H_rc_0p5) ** 2) / np.sum(np.abs(H_rc_0p5) ** 2))
P_rc_0p9 = sdr.db(np.cumsum(np.abs(H_rc_0p9) ** 2) / np.sum(np.abs(H_rc_0p9) ** 2))

plt.figure()
plt.plot(w, P_rect, color="k", label="Rectangular")
plt.plot(w, P_rc_0p1, label=r"$\alpha = 0.1$")
plt.plot(w, P_rc_0p5, label=r"$\alpha = 0.5$")
plt.plot(w, P_rc_0p9, label=r"$\alpha = 0.9$")
plt.legend()
plt.xlim(0.25, 1)
plt.ylim(-3, 0)
plt.xlabel("One-sided normalized frequency, $f/f_{sym}$")
plt.ylabel("Relative power (dB)")
plt.title("Relative power within bandwidths for various raised cosine pulses")
plt.show()
../../_images/02008e942fee33c15104afcfc4df1164e516019af9821b3f865155bd87691807.png

Square-root raised cosine

Create three square-root raised cosine pulses with different excess bandwidths. This is achieved using the sdr.root_raised_cosine() function.

srrc_0p1 = sdr.root_raised_cosine(0.1, span, sps)
srrc_0p5 = sdr.root_raised_cosine(0.5, span, sps)
srrc_0p9 = sdr.root_raised_cosine(0.9, span, sps)
plt.figure()
sdr.plot.impulse_response(rect, color="k", label="Rectangular")
sdr.plot.impulse_response(srrc_0p1, label=r"$\alpha = 0.1$")
sdr.plot.impulse_response(srrc_0p5, label=r"$\alpha = 0.5$")
sdr.plot.impulse_response(srrc_0p9, label=r"$\alpha = 0.9$")
plt.show()
../../_images/df6ff5b7d27c2c31c4f39a7331987436334cf430d4f92e22f635c2f1b4a62761.png

The square-root raised cosine filter is not a Nyquist filter. Therefore, the impulse response \(h[n]\) is not zero at adjacent symbols.

plt.figure()
sdr.plot.time_domain(np.roll(srrc_0p1, -3 * sps))
sdr.plot.time_domain(np.roll(srrc_0p1, -2 * sps))
sdr.plot.time_domain(np.roll(srrc_0p1, -1 * sps))
sdr.plot.time_domain(np.roll(srrc_0p1, 0 * sps))
sdr.plot.time_domain(np.roll(srrc_0p1, 1 * sps))
plt.xlim(0, 60)
plt.title("Square-root raised cosine pulses for adjacent symbols")
plt.show()
../../_images/649ca76898017b9043032440cf97393c4939d5fd3027885ead80b6eacd7a15d0.png
plt.figure()
sdr.plot.magnitude_response(rect, sample_rate=sps, color="k", label="Rectangular")
sdr.plot.magnitude_response(srrc_0p1, sample_rate=sps, label=r"$\alpha = 0.1$")
sdr.plot.magnitude_response(srrc_0p5, sample_rate=sps, label=r"$\alpha = 0.5$")
sdr.plot.magnitude_response(srrc_0p9, sample_rate=sps, label=r"$\alpha = 0.9$")
plt.xlabel("Normalized frequency, $f/f_{sym}$")
plt.show()
../../_images/975eddff4dbd4b6e35878bef881ca933a18f1c646c4af4f24b073f9da884c68f.png

While the bandwidths of the square-root raised cosine filter are similar to the raised cosine filter, the side lobes are significantly higher. This is due to this filter not being a Nyquist filter.

# Compute the one-sided power spectral density of the pulses
w, H_rect = scipy.signal.freqz(rect, 1, worN=1024, whole=False, fs=sps)
w, H_srrc_0p1 = scipy.signal.freqz(srrc_0p1, 1, worN=1024, whole=False, fs=sps)
w, H_srrc_0p5 = scipy.signal.freqz(srrc_0p5, 1, worN=1024, whole=False, fs=sps)
w, H_srrc_0p9 = scipy.signal.freqz(srrc_0p9, 1, worN=1024, whole=False, fs=sps)

# Compute the relative power in the main lobe of the pulses
P_rect = sdr.db(np.cumsum(np.abs(H_rect) ** 2) / np.sum(np.abs(H_rect) ** 2))
P_srrc_0p1 = sdr.db(np.cumsum(np.abs(H_srrc_0p1) ** 2) / np.sum(np.abs(H_srrc_0p1) ** 2))
P_srrc_0p5 = sdr.db(np.cumsum(np.abs(H_srrc_0p5) ** 2) / np.sum(np.abs(H_srrc_0p5) ** 2))
P_srrc_0p9 = sdr.db(np.cumsum(np.abs(H_srrc_0p9) ** 2) / np.sum(np.abs(H_srrc_0p9) ** 2))

plt.figure()
plt.plot(w, P_rect, color="k", label="Rectangular")
plt.plot(w, P_srrc_0p1, label=r"$\alpha = 0.1$")
plt.plot(w, P_srrc_0p5, label=r"$\alpha = 0.5$")
plt.plot(w, P_srrc_0p9, label=r"$\alpha = 0.9$")
plt.legend()
plt.xlim(0.25, 1)
plt.ylim(-3, 0)
plt.xlabel("One-sided normalized frequency, $f/f_{sym}$")
plt.ylabel("Relative power (dB)")
plt.title("Relative power within bandwidths for various square-root raised cosine pulses")
plt.show()
../../_images/e8fa638351e709389c80108a2fcbd60eff17e7993836d1a47f7dfa4cefc98898.png

Gaussian

Create three raised Gaussian pulses with different time-bandwidth products. This is achieved using the sdr.gaussian() function.

gauss_0p1 = sdr.gaussian(0.1, span, sps)
gauss_0p2 = sdr.gaussian(0.2, span, sps)
gauss_0p3 = sdr.gaussian(0.3, span, sps)
plt.figure()
sdr.plot.impulse_response(gauss_0p1, label=r"$B T_{sym} = 0.1$")
sdr.plot.impulse_response(gauss_0p2, label=r"$B T_{sym} = 0.2$")
sdr.plot.impulse_response(gauss_0p3, label=r"$B T_{sym} = 0.3$")
plt.show()
../../_images/d0717073a5a33c34fc421735c5b257ac53ee1b70e7d7a587892d156f989bfc89.png
plt.figure()
sdr.plot.magnitude_response(gauss_0p1, sample_rate=sps, label=r"$B T_{sym} = 0.1$")
sdr.plot.magnitude_response(gauss_0p2, sample_rate=sps, label=r"$B T_{sym} = 0.2$")
sdr.plot.magnitude_response(gauss_0p3, sample_rate=sps, label=r"$B T_{sym} = 0.3$")
plt.xlabel("Normalized frequency, $f/f_{sym}$")
plt.show()
/home/matt/repos/sdr/src/sdr/plot/_filter.py:377: RuntimeWarning: divide by zero encountered in log10
  H = 10 * np.log10(np.abs(H) ** 2)
../../_images/70ac7d89f6bb67a3b91ec02d7e053973fe194fcd96041885f2b3684cde301d56.png

Last update: Jun 15, 2024