-
sdr.walsh_code(length: int, index: int, output: 'binary' =
'binary'
) ndarray[Any, dtype[int64]] - sdr.walsh_code(length: int, index: int, output: 'field') FieldArray
- sdr.walsh_code(length: int, index: int, output: 'bipolar') ndarray[Any, dtype[float64]]
Generates the Walsh code/sequence of length \(n = 2^m\).
- Parameters:¶
- length: int¶
The length \(n = 2^m\) of the Walsh code/sequence.
- index: int¶
The index \(i\) in \([0, n)\) of the Walsh code. Indicates how many transitions there are in the code.
- output: 'binary' =
'binary'
¶ - output: 'field'
- output: 'bipolar'
The output format of the Walsh code/sequence.
"binary"
(default): The Walsh code with binary values of 0 and 1."field"
: The Walsh code as a Galois field array over \(\mathrm{GF}(2)\)."bipolar"
: The Walsh sequence with bipolar values of 1 and -1.
- Returns:¶
The Walsh code/sequence of length \(n = 2^m\) and index \(i\).
References
Examples
Create a Walsh code and sequence of length 16. The code index 4 indicates that there are 4 transitions in the code.
In [1]: sdr.walsh_code(16, 4) Out[1]: array([0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0]) In [2]: sdr.walsh_code(16, 4, output="bipolar") Out[2]: array([ 1., 1., -1., -1., -1., -1., 1., 1., 1., 1., -1., -1., -1., -1., 1., 1.]) In [3]: sdr.walsh_code(16, 4, output="field") Out[3]: GF([0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0], order=2)
The Hadamard and Walsh code sets are equivalent, however they are indexed differently.
In [4]: np.array_equal(sdr.hadamard_code(16, 3), sdr.walsh_code(16, 8)) Out[4]: True In [5]: np.array_equal(sdr.hadamard_code(16, 11), sdr.walsh_code(16, 9)) Out[5]: True
Walsh sequences have zero cross-correlation when time aligned.
In [6]: x1 = sdr.walsh_code(32, 10, output="bipolar"); \ ...: x2 = sdr.walsh_code(32, 14, output="bipolar"); \ ...: x3 = sdr.walsh_code(32, 18, output="bipolar"); ...: In [7]: plt.figure(); \ ...: sdr.plot.time_domain(x1 + 3); \ ...: sdr.plot.time_domain(x2 + 0); \ ...: sdr.plot.time_domain(x3 - 3) ...:
Walsh sequence auto-correlation sidelobes are not uniform as a function of sequence index. In fact, the sidelobes can be quite high.
In [8]: plt.figure(); \ ...: sdr.plot.correlation(x1, x1, mode="circular"); \ ...: sdr.plot.correlation(x2, x2, mode="circular"); \ ...: sdr.plot.correlation(x3, x3, mode="circular"); \ ...: plt.ylim(0, 32); ...:
Walsh sequences have zero cross-correlation when time aligned. However, the sidelobes can be quite large when time misaligned. Because of this, Walsh sequences for spreading codes are useful only when precise time information is known.
In [9]: plt.figure(); \ ...: sdr.plot.correlation(x1, x2, mode="circular"); \ ...: sdr.plot.correlation(x1, x3, mode="circular"); \ ...: sdr.plot.correlation(x2, x3, mode="circular"); \ ...: plt.ylim(0, 32); ...: