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

Upsamples the time-domain signal \(x[n]\) by the factor \(r\), by inserting \(r-1\) zeros between each sample.

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: ArrayLike

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(); \
   ...: sdr.plot.time_domain(x, sample_rate=sample_rate); \
   ...: plt.title("Input signal $x[n]$");
   ...: 

In [4]: plt.figure(); \
   ...: sdr.plot.time_domain(y, sample_rate=sample_rate*4); \
   ...: plt.title("Upsampled signal $y[n]$");
   ...: 
../../_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(); \
   ...: sdr.plot.periodogram(x, fft=2048, sample_rate=sample_rate); \
   ...: plt.xlim(-sample_rate*2, sample_rate*2); \
   ...: plt.ylim(-100, 0); \
   ...: plt.title("Input signal $x[n]$");
   ...: 

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