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\).

Parameters:
length: int

The length \(N\) of the Barker code/sequence.

output: 'binary'
output: 'bipolar' = 'bipolar'

The output format of the Barker code/sequence.

  • "binary": The Barker code with binary values of 0 and 1.

  • "bipolar": The Barker sequence with bipolar values of 1 and -1.

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();
   ...: 
../../_images/sdr_barker_1.png