-
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]: 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 autocorrelation sidelobes of +1 or -1.
In [4]: seq = sdr.barker_code(13, output="bipolar") In [5]: corr = np.correlate(seq, seq, mode="full") In [6]: lag = np.arange(-seq.size + 1, seq.size) In [7]: plt.figure(); \ ...: sdr.plot.time_domain(lag, np.abs(corr)); \ ...: plt.xlabel("Lag"); \ ...: plt.title("Autocorrelation of length-13 Barker sequence"); ...: