- sdr.barker(length: int, output: 'binary') ndarray[Any, dtype[int64]]
-
sdr.barker(length: int, output: 'bipolar' =
'bipolar'
) ndarray[Any, dtype[float64]] Returns the Barker code/sequence of length \(N\).
Examples¶
Create a Barker code and sequence of length 13.
In [1]: code = sdr.barker(13, output="binary"); code Out[1]: array([1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1]) In [2]: seq = sdr.barker(13); seq Out[2]: array([-1., -1., -1., -1., -1., 1., 1., -1., -1., 1., -1., 1., -1.])
Barker sequences have ideally-minimal autocorrelation sidelobes of +1 or -1.
In [3]: corr = np.correlate(seq, seq, mode="full"); \ ...: lag = np.arange(-seq.size + 1, seq.size) ...: In [4]: plt.figure(figsize=(8, 4)); \ ...: plt.plot(lag, np.abs(corr)); \ ...: plt.xlabel("Lag"); \ ...: plt.ylabel("Magnitude"); \ ...: plt.title("Autocorrelation of length-13 Barker sequence"); \ ...: plt.tight_layout(); ...: