sdr.plot.time_domain(x: ArrayLike, sample_rate: float = 1.0, **kwargs)

Plots a time-domain signal \(x[n]\).

Parameters:
x: ArrayLike

The time-domain signal \(x[n]\).

sample_rate: float = 1.0

The sample rate \(f_s\) of the signal in samples/s. If the sample rate is 1, the x-axis will be label as “Samples”.

**kwargs

Additional keyword arguments to pass to matplotlib.pyplot.plot().

Examples

# Create a BPSK impulse signal
In [1]: x = np.zeros(1000); \
   ...: symbol_map = np.array([1, -1]); \
   ...: x[::10] = symbol_map[np.random.randint(0, 2, 100)]
   ...: 

# Pulse shape the signal with a square-root raised cosine filter
In [2]: h_srrc = sdr.root_raised_cosine(0.5, 7, 10); \
   ...: y = np.convolve(x, h_srrc)
   ...: 

In [3]: plt.figure(figsize=(8, 4)); \
   ...: sdr.plot.time_domain(y, sample_rate=10e3); \
   ...: plt.title("SRRC pulse-shaped BPSK"); \
   ...: plt.tight_layout()
   ...: 
../../_images/sdr_plot_time_domain_1.png
# Create a QPSK impulse signal
In [4]: x = np.zeros(1000, dtype=np.complex64); \
   ...: symbol_map = np.exp(1j * np.pi / 4) * np.array([1, 1j, -1, -1j]); \
   ...: x[::10] = symbol_map[np.random.randint(0, 4, 100)]
   ...: 

# Pulse shape the signal with a square-root raised cosine filter
In [5]: h_srrc = sdr.root_raised_cosine(0.5, 7, 10); \
   ...: y = np.convolve(x, h_srrc)
   ...: 

In [6]: plt.figure(figsize=(8, 4)); \
   ...: sdr.plot.time_domain(y, sample_rate=10e3); \
   ...: plt.title("SRRC pulse-shaped QPSK"); \
   ...: plt.tight_layout()
   ...: 
../../_images/sdr_plot_time_domain_2.png