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]]

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

Notes

Barker codes only exist for length \(n = 1, 2, 3, 4, 5, 7, 11, 13\).

Examples

Create a Barker code and sequence of length 13.

In [1]: sdr.barker_code(13)
Out[1]: array([1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1])

In [2]: sdr.barker_code(13, output="bipolar")
Out[2]: array([-1., -1., -1., -1., -1.,  1.,  1., -1., -1.,  1., -1.,  1., -1.])

In [3]: sdr.barker_code(13, output="field")
Out[3]: GF([1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1], order=2)

Barker sequences have ideally minimal auto-correlation sidelobes of +1 or -1.

In [4]: x = sdr.barker_code(13, output="bipolar")

In [5]: plt.figure(); \
   ...: sdr.plot.correlation(x, x, mode="circular");
   ...: 
../../_images/sdr_barker_code_1.png