Exemple #1
0
def paper_eg():
    """Gold code set example base on paper by E. H. Dinan and B. Jabbari 
    Spreading Codes for Direct Sequence CDMA and Wideband CDMA Cellular 
    Networks"""
    seq1 = mls.lfsr([2], [1, 1, 1, 1, 1])
    print 'Sequence 1:', numpy.where(seq1, 1, 0)
    seq2 = mls.lfsr([1, 2, 3], [1, 1, 1, 1, 1])
    print 'Sequence 2:', numpy.where(seq2, 1, 0)
    gold = gen_gold(seq1, seq2)
    print 'Gold 0 shift combination:', numpy.where(gold[0], 1, 0)
    print 'Gold 1 shift combination:', numpy.where(gold[1], 1, 0)
    print 'Gold 30 shift combination:', numpy.where(gold[-1], 1, 0)

    pylab.figure()
    pylab.subplot(2, 2, 1)
    pylab.title('Autocorrelation gold[0]')
    g0 = numpy.where(gold[0], 1.0, -1.0)
    pylab.plot((numpy.roll(filter.ccorr(g0, g0).real, len(g0) / 2 - 1)))
    pylab.subplot(2, 2, 2)
    pylab.title('Autocorrelation gold[30]')
    g30 = numpy.where(gold[30], 1.0, -1.0)
    pylab.plot((numpy.roll(filter.ccorr(g30, g30).real, len(g30) / 2 - 1)))
    pylab.subplot(2, 2, 3)
    pylab.title('Crosscorrelation gold[0] gold[1]')
    g1 = numpy.where(gold[1], 1.0, -1.0)
    pylab.plot((numpy.roll(filter.ccorr(g0, g1).real, len(g0) / 2 - 1)))
    pylab.subplot(2, 2, 4)
    pylab.title('Crosscorrelation gold[0] gold[30]')
    pylab.plot((numpy.roll(filter.ccorr(g0, g30).real, len(g0) / 2 - 1)))
    pylab.show()
Exemple #2
0
def paper_eg():
    """Gold code set example base on paper by E. H. Dinan and B. Jabbari 
    Spreading Codes for Direct Sequence CDMA and Wideband CDMA Cellular 
    Networks"""
    seq1 = mls.lfsr([2],[1, 1, 1, 1, 1])
    print 'Sequence 1:', numpy.where(seq1, 1, 0)
    seq2 = mls.lfsr([1, 2, 3], [1, 1, 1, 1, 1])
    print 'Sequence 2:', numpy.where(seq2, 1, 0)
    gold = gen_gold(seq1, seq2)
    print 'Gold 0 shift combination:', numpy.where(gold[0], 1, 0)
    print 'Gold 1 shift combination:', numpy.where(gold[1], 1, 0)
    print 'Gold 30 shift combination:', numpy.where(gold[-1], 1, 0)
    
    pylab.figure()
    pylab.subplot(2,2,1)
    pylab.title('Autocorrelation gold[0]')
    g0 = numpy.where(gold[0], 1.0, -1.0)
    pylab.plot((numpy.roll(filter.ccorr(g0, g0).real, len(g0)/2-1)))
    pylab.subplot(2,2,2)
    pylab.title('Autocorrelation gold[30]')
    g30 = numpy.where(gold[30], 1.0, -1.0)
    pylab.plot((numpy.roll(filter.ccorr(g30, g30).real, len(g30)/2-1)))
    pylab.subplot(2,2,3)
    pylab.title('Crosscorrelation gold[0] gold[1]')
    g1 = numpy.where(gold[1], 1.0, -1.0)
    pylab.plot((numpy.roll(filter.ccorr(g0, g1).real, len(g0)/2-1)))
    pylab.subplot(2,2,4)
    pylab.title('Crosscorrelation gold[0] gold[30]')
    pylab.plot((numpy.roll(filter.ccorr(g0, g30).real, len(g0)/2-1)))
    pylab.show()
Exemple #3
0
def web_eg():
    """Example of producing Gold Codes from the net 
    (http://paginas.fe.up.pt/~hmiranda/cm/Pseudo_Noise_Sequences.pdf)"""
    seq1 = mls.lfsr([1], [1, 0, 0])
    print 'Sequence 1:', numpy.where(seq1, 1, 0)
    seq2 = mls.lfsr([2], [1, 0, 0])
    print 'Sequence 2:', numpy.where(seq2, 1, 0)
    for gold in gen_gold(seq1, seq2):
        print 'Gold Code:', numpy.where(gold, 1, 0)
Exemple #4
0
def web_eg():
    """Example of producing Gold Codes from the net 
    (http://paginas.fe.up.pt/~hmiranda/cm/Pseudo_Noise_Sequences.pdf)"""
    seq1 = mls.lfsr([1],[1,0,0])
    print 'Sequence 1:', numpy.where(seq1, 1, 0)
    seq2 = mls.lfsr([2], [1,0,0])
    print 'Sequence 2:', numpy.where(seq2, 1, 0)
    for gold in gen_gold(seq1, seq2):
        print 'Gold Code:', numpy.where(gold, 1, 0)
Exemple #5
0
def gold(n):
    """Generate a set of 2^n +1 Gold Codes
    """
    n = int(n)
    if not n in preferred_pairs:
        raise ss.Error('preferred pairs for %s bits unknown' % str(n))
    seed = list(numpy.ones(n))
    seq1 = mls.lfsr(preferred_pairs[n][0], seed)
    seq2 = mls.lfsr(preferred_pairs[n][1], seed)
    return gen_gold(seq1, seq2)
Exemple #6
-1
def gold(n):
    """Generate a set of 2^n +1 Gold Codes
    """
    n = int(n)
    if not n in preferred_pairs:
        raise ss.Error('preferred pairs for %s bits unknown' % str(n))
    seed = list(numpy.ones(n))
    seq1 = mls.lfsr(preferred_pairs[n][0], seed)
    seq2 = mls.lfsr(preferred_pairs[n][1], seed)
    return gen_gold(seq1, seq2)