- sdr.to_complex_bb(x_r: NDArray[float_]) NDArray[complex_]
Converts the real passband signal \(x_r[n]\) centered at \(f_{s,r}/4\) with sample rate \(f_{s,r}\) to a complex baseband signal \(x_c[n]\) centered at \(0\) with sample rate \(f_{s,c} = f_{s,r}/2\).
- Parameters:¶
- x_r: NDArray[float_]¶
The real passband signal \(x_r[n]\) centered at \(f_{s,r}/4\) with sample rate \(f_{s,r}\). If the length is odd, one zero is appended to the end.
- Returns:¶
The complex baseband signal \(x_c[n]\) centered at \(0\) with sample rate \(f_{s,c} = f_{s,r}/2\).
Examples¶
Create a real passband signal with frequency components at 100, 250, and 300 Hz, at a sample rate of 1 ksps. Notice the spectrum is complex-conjugate symmetric.
In [1]: sample_rate = 1e3; \ ...: x_r = ( \ ...: 0.1 * np.sin(2 * np.pi * 100 / sample_rate * np.arange(1000)) \ ...: + 1.0 * np.sin(2 * np.pi * 250 / sample_rate * np.arange(1000)) \ ...: + 0.5 * np.sin(2 * np.pi * 300 / sample_rate * np.arange(1000)) \ ...: ); \ ...: x_r = sdr.awgn(x_r, snr=30) ...: In [2]: plt.figure(figsize=(8, 4)); \ ...: sdr.plot.time_domain(x_r[0:100], sample_rate=sample_rate); \ ...: plt.title("Time-domain signal $x_r[n]$"); \ ...: plt.tight_layout(); ...: In [3]: plt.figure(figsize=(8, 4)); \ ...: sdr.plot.periodogram(x_r, fft=2048, sample_rate=sample_rate); \ ...: plt.title("Periodogram of $x_r[n]$"); \ ...: plt.tight_layout(); ...:
Convert the real passband signal to a complex baseband signal with sample rate 500 sps and center of 0 Hz. Notice the spectrum is no longer complex-conjugate symmetric. The real sinusoids are now complex exponentials at -150, 0, and 50 Hz.
In [4]: x_c = sdr.to_complex_bb(x_r); \ ...: sample_rate /= 2 ...: In [5]: plt.figure(figsize=(8, 4)); \ ...: sdr.plot.time_domain(x_c[0:50], sample_rate=sample_rate); \ ...: plt.title("Time-domain signal $x_c[n]$"); \ ...: plt.tight_layout(); ...: In [6]: plt.figure(figsize=(8, 4)); \ ...: sdr.plot.periodogram(x_c, fft=2048, sample_rate=sample_rate); \ ...: plt.title("Periodogram of $x_c[n]$"); \ ...: plt.tight_layout(); ...: