11
22# Copyright 2012 Veeresh Taranalli <[email protected] > 33#
4- # This file is part of CommPy.
4+ # This file is part of CommPy.
55#
66# CommPy is free software: you can redistribute it and/or modify
77# it under the terms of the GNU General Public License as published by
1616# You should have received a copy of the GNU General Public License
1717# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
19- """
19+ """
2020==================================================
2121Sequences (:mod:`commpy.sequences`)
2222==================================================
2323
2424.. autosummary::
2525 :toctree: generated/
26-
26+
2727 pnsequence -- PN Sequence Generator.
2828 zcsequence -- Zadoff-Chu (ZC) Sequence Generator.
2929
3333from numpy import array , empty , zeros , roll , exp , pi , arange
3434
3535def pnsequence (pn_order , pn_seed , pn_mask , seq_length ):
36- """ Generate a PN (Pseudo-Noise) sequence using a
37- Linear Feedback Shift Register (LFSR).
38-
36+ """ Generate a PN (Pseudo-Noise) sequence using a
37+ Linear Feedback Shift Register (LFSR).
38+
3939 Parameters
4040 ----------
4141 pn_order : int
4242 Number of delay elements used in the LFSR.
43-
43+
4444 pn_seed : string containing 0's and 1's
45- Seed for the initialization of the LFSR delay elements.
45+ Seed for the initialization of the LFSR delay elements.
4646 The length of this string must be equal to 'pn_order'.
4747
4848 pn_mask : string containing 0's and 1's
@@ -51,20 +51,20 @@ def pnsequence(pn_order, pn_seed, pn_mask, seq_length):
5151
5252 seq_length : int
5353 Length of the PN sequence to be generated. Usually (2^pn_order - 1)
54-
54+
5555 Returns
5656 -------
5757 pnseq : 1D ndarray of ints
5858 PN sequence generated.
5959
6060 """
6161 # Check if pn_order is equal to the length of the strings 'pn_seed' and 'pn_mask'
62-
62+
6363 pnseq = zeros (seq_length )
64-
64+
6565 # Initialize shift register with the pn_seed
6666 sr = array (map (lambda i : int (pn_seed [i ]), xrange (0 , len (pn_seed ))))
67-
67+
6868 for i in xrange (seq_length ):
6969 new_bit = 0
7070 for j in xrange (pn_order ):
@@ -92,6 +92,6 @@ def zcsequence(u, seq_length):
9292 zcseq : 1D ndarray of complex floats
9393 ZC sequence generated.
9494 """
95- zcseq = exp ((- 1j * pi * arange (seq_length ) * (arange (seq_length )+ 1 )) / seq_length )
95+ zcseq = exp ((- 1j * pi * u * arange (seq_length ) * (arange (seq_length )+ 1 )) / seq_length )
9696
9797 return zcseq
0 commit comments