sdr.barker_code(length: int, output: 'binary' = 'binary') ndarray[Any, dtype[int64]]
sdr.barker_code(length: int, output: 'field') FieldArray
sdr.barker_code(length: int, output: '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' = 'binary'
output: 'field'
output: 'bipolar'

The output format of the Barker code/sequence.

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

  • "field": The Barker code as a Galois field array over \(\mathrm{GF}(2)\).

  • "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_code(13); code
Out[1]: array([1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1])

In [2]: seq = sdr.barker_code(13, output="bipolar"); 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")

In [4]: lag = np.arange(-seq.size + 1, seq.size)

In [5]: plt.figure(); \
   ...: sdr.plot.time_domain(lag, np.abs(corr)); \
   ...: plt.xlabel("Lag"); \
   ...: plt.title("Autocorrelation of length-13 Barker sequence");
   ...: 
../../_images/sdr_barker_code_1.png