sdr.upsample(x: NDArray, rate: int) NDArray

Upsamples the time-domain signal \(x[n]\) by the factor \(r\).

Warning

This function does not perform any anti-aliasing filtering. The upsampled signal \(y[n]\) will have frequency components above the Nyquist frequency of the original signal \(x[n]\). For efficient polyphase interpolation (with anti-aliasing filtering), see sdr.Interpolator.

Parameters:
x: NDArray

The time-domain signal \(x[n]\) with sample rate \(f_s\).

rate: int

The upsampling factor \(r\).

Returns:

The upsampled signal \(y[n]\) with sample rate \(f_s r\).

See also

sdr.Interpolator

Examples

Upsample a complex exponential by a factor of 4.

In [1]: sample_rate = 100; \
   ...: x = np.exp(1j * 2 * np.pi * 15 / sample_rate * np.arange(20))
   ...: 

In [2]: y = sdr.upsample(x, 4)

In [3]: plt.figure(figsize=(8, 4)); \
   ...: sdr.plot.time_domain(x, sample_rate=sample_rate); \
   ...: plt.title("Input signal $x[n]$"); \
   ...: plt.tight_layout();
   ...: 

In [4]: plt.figure(figsize=(8, 4)); \
   ...: sdr.plot.time_domain(y, sample_rate=sample_rate*4); \
   ...: plt.title("Upsampled signal $y[n]$"); \
   ...: plt.tight_layout();
   ...: 
../../_images/sdr_upsample_1.png ../../_images/sdr_upsample_2.png

The spectrum of \(y[n]\) has 3 additional copies of the spectrum of \(x[n]\).

In [5]: plt.figure(figsize=(8, 4)); \
   ...: sdr.plot.periodogram(x, fft=2048, sample_rate=sample_rate); \
   ...: plt.xlim(-sample_rate*2, sample_rate*2); \
   ...: plt.title("Input signal $x[n]$"); \
   ...: plt.tight_layout();
   ...: 

In [6]: plt.figure(figsize=(8, 4)); \
   ...: sdr.plot.periodogram(y, fft=2048, sample_rate=sample_rate*4); \
   ...: plt.xlim(-sample_rate*2, sample_rate*2); \
   ...: plt.title("Upsampled signal $y[n]$"); \
   ...: plt.tight_layout();
   ...: 
../../_images/sdr_upsample_3.png ../../_images/sdr_upsample_4.png