sdr.sample_rate_offset(x: ArrayLike, offset: float, sample_rate: float = 1.0) NDArray

Applies a sample rate offset to the time-domain signal \(x[n]\).

Parameters:
x: ArrayLike

The time-domain signal \(x[n]\) to which the sample rate offset is applied.

offset: float

The sample rate offset \(\Delta f_s = f_{s,\text{new}} - f_{s,\text{old}}\) in samples/s.

sample_rate: float = 1.0

The sample rate \(f_s\) in samples/s.

Returns:

The signal \(x[n]\) with sample rate offset applied.

Examples

Create a QPSK reference signal.

In [1]: psk = sdr.PSK(4, phase_offset=45); \
   ...: s = np.random.randint(0, psk.order, 1_000); \
   ...: x = psk.map_symbols(s)
   ...: 

Add 10 ppm of sample rate offset.

In [2]: y = sdr.sample_rate_offset(x, 10e-6)

In [3]: plt.figure(); \
   ...: sdr.plot.constellation(x, label="$x[n]$", zorder=2); \
   ...: sdr.plot.constellation(y, label="$y[n]$", zorder=1); \
   ...: plt.title("10 ppm sample rate offset");
   ...: 
../../_images/sdr_sample_rate_offset_1.png

Add 100 ppm of sample rate offset.

In [4]: y = sdr.sample_rate_offset(x, 100e-6)

In [5]: plt.figure(); \
   ...: sdr.plot.constellation(x, label="$x[n]$", zorder=2); \
   ...: sdr.plot.constellation(y, label="$y[n]$", zorder=1); \
   ...: plt.title("100 ppm sample rate offset");
   ...: 
../../_images/sdr_sample_rate_offset_2.png