Skip to content

Commit

Permalink
port to Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
pmonta committed Oct 16, 2015
1 parent b25b660 commit 43f6c95
Show file tree
Hide file tree
Showing 53 changed files with 78 additions and 77 deletions.
2 changes: 1 addition & 1 deletion acquire-beidou-b1i.py
Expand Up @@ -74,4 +74,4 @@ def search(x,prn):
#for prn in [1 2 3 4 5 6 7 8 9 10 11 12 13 14 30 31 32 33 34]:
metric,code,doppler = search(x,prn)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code)
print('prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code))
2 changes: 1 addition & 1 deletion acquire-beidou-b2i.py
Expand Up @@ -74,4 +74,4 @@ def search(x,prn):
#for prn in [1 2 3 4 5 6 7 8 9 10 11 12 13 14 30 31 32 33 34]:
metric,code,doppler = search(x,prn)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code)
print('prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code))
2 changes: 1 addition & 1 deletion acquire-galileo-e1b.py
Expand Up @@ -72,4 +72,4 @@ def search(x,prn):
#for prn in [11,12,14,18,19,20,22,24,26,30]:
metric,code,doppler = search(x,prn)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code)
print('prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code))
2 changes: 1 addition & 1 deletion acquire-galileo-e1c.py
Expand Up @@ -72,4 +72,4 @@ def search(x,prn):
#for prn in [11,12,14,18,19,20,22,24,26,30]:
metric,code,doppler = search(x,prn)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code)
print('prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code))
2 changes: 1 addition & 1 deletion acquire-galileo-e5ai.py
Expand Up @@ -71,4 +71,4 @@ def search(x,prn):
#for prn in [11,12,14,18,19,20,22,24,26,30]:
metric,code,doppler = search(x,prn)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code)
print('prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code))
2 changes: 1 addition & 1 deletion acquire-galileo-e5aq.py
Expand Up @@ -71,4 +71,4 @@ def search(x,prn):
#for prn in [11,12,14,18,19,20,22,24,26,30]:
metric,code,doppler = search(x,prn)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code)
print('prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code))
2 changes: 1 addition & 1 deletion acquire-galileo-e5bi.py
Expand Up @@ -71,4 +71,4 @@ def search(x,prn):
#for prn in [11,12,14,18,19,20,22,24,26,30]:
metric,code,doppler = search(x,prn)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code)
print('prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code))
2 changes: 1 addition & 1 deletion acquire-galileo-e5bq.py
Expand Up @@ -71,4 +71,4 @@ def search(x,prn):
#for prn in [11,12,14,18,19,20,22,24,26,30]:
metric,code,doppler = search(x,prn)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code)
print('prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code))
2 changes: 1 addition & 1 deletion acquire-glonass-l1.py
Expand Up @@ -72,4 +72,4 @@ def search(x,chan):
for chan in range(-7,8):
metric,code,doppler = search(x,chan)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'chan % 2d doppler % 7.1f metric %7.1f code_offset %7.2f' % (chan,doppler,metric,code)
print('chan % 2d doppler % 7.1f metric %7.1f code_offset %7.2f' % (chan,doppler,metric,code))
2 changes: 1 addition & 1 deletion acquire-glonass-l2.py
Expand Up @@ -72,4 +72,4 @@ def search(x,chan):
for chan in range(-7,8):
metric,code,doppler = search(x,chan)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'chan % 2d doppler % 7.1f metric %7.1f code_offset %7.2f' % (chan,doppler,metric,code)
print('chan % 2d doppler % 7.1f metric %7.1f code_offset %7.2f' % (chan,doppler,metric,code))
2 changes: 1 addition & 1 deletion acquire-glonass-l3i.py
Expand Up @@ -71,4 +71,4 @@ def search(x,prn):
#for prn in [27,30,33]:
metric,code,doppler = search(x,prn)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code)
print('prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code))
2 changes: 1 addition & 1 deletion acquire-glonass-l3q.py
Expand Up @@ -71,4 +71,4 @@ def search(x,prn):
#for prn in [27,30,33]:
metric,code,doppler = search(x,prn)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code)
print('prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code))
4 changes: 2 additions & 2 deletions acquire-gps-l1.py
Expand Up @@ -70,7 +70,7 @@ def search(x,prn):

# iterate over PRNs of interest

for prn in range(1,33)+[133,135,138]:
for prn in list(range(1,33))+[133,135,138]:
metric,code,doppler = search(x,prn)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'prn %3d doppler % 7.1f metric %4.2f code_offset %6.1f' % (prn,doppler,metric,code)
print('prn %3d doppler % 7.1f metric %4.2f code_offset %6.1f' % (prn,doppler,metric,code))
2 changes: 1 addition & 1 deletion acquire-gps-l2cm.py
Expand Up @@ -70,4 +70,4 @@ def search(x,prn):
for prn in range(1,33):
metric,code,doppler = search(x,prn)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'prn %3d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code)
print('prn %3d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code))
2 changes: 1 addition & 1 deletion acquire-gps-l5i.py
Expand Up @@ -70,4 +70,4 @@ def search(x,prn):
for prn in range(1,33):
metric,code,doppler = search(x,prn)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code)
print('prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code))
2 changes: 1 addition & 1 deletion acquire-gps-l5q.py
Expand Up @@ -70,4 +70,4 @@ def search(x,prn):
for prn in range(1,33):
metric,code,doppler = search(x,prn)
if metric>0.0: # fixme: need a proper metric and threshold; and estimate cn0
print 'prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code)
print('prn %2d doppler % 7.1f metric %7.1f code_offset %6.1f' % (prn,doppler,metric,code))
6 changes: 3 additions & 3 deletions gnsstools/beidou/b1i.py
Expand Up @@ -44,7 +44,7 @@ def b1i(prn):
codes = {}

def b1i_code(prn):
if not codes.has_key(prn):
if prn not in codes:
codes[prn] = b1i(prn)
return codes[prn]

Expand All @@ -71,5 +71,5 @@ def correlate(x,prn,chips,frac,incr,c):
# test

if __name__=='__main__':
print b1i_code(1)[0:20]
print b1i_code(2)[0:20]
print(b1i_code(1)[0:20])
print(b1i_code(2)[0:20])
8 changes: 4 additions & 4 deletions gnsstools/galileo/e1b.py
Expand Up @@ -4,7 +4,7 @@

import numpy as np

from e1b_strings import *
from .e1b_strings import *

chip_rate = 1023000
code_length = 4092
Expand All @@ -22,7 +22,7 @@ def e1b_parse_hex(prn):
codes = {}

def e1b_code(prn):
if not codes.has_key(prn):
if prn not in codes:
codes[prn] = e1b_parse_hex(prn)
return codes[prn]

Expand Down Expand Up @@ -56,5 +56,5 @@ def correlate(x,prn,chips,frac,incr,c,boc11):
# test

if __name__=='__main__':
print e1b_code(1)[0:20]
print e1b_code(2)[0:20]
print(e1b_code(1)[0:20])
print(e1b_code(2)[0:20])
8 changes: 4 additions & 4 deletions gnsstools/galileo/e1c.py
Expand Up @@ -4,7 +4,7 @@

import numpy as np

from e1c_strings import *
from .e1c_strings import *

chip_rate = 1023000
code_length = 4092
Expand All @@ -25,7 +25,7 @@ def e1c_parse_hex(prn):
codes = {}

def e1c_code(prn):
if not codes.has_key(prn):
if prn not in codes:
codes[prn] = e1c_parse_hex(prn)
return codes[prn]

Expand Down Expand Up @@ -59,5 +59,5 @@ def correlate(x,prn,chips,frac,incr,c,boc11):
# test

if __name__=='__main__':
print e1c_code(1)[0:20]
print e1c_code(2)[0:20]
print(e1c_code(1)[0:20])
print(e1c_code(2)[0:20])
4 changes: 2 additions & 2 deletions gnsstools/galileo/e5ai.py
Expand Up @@ -83,7 +83,7 @@ def make_e5ai(prn):
return np.logical_xor(r1,r2)

def e5ai_code(prn):
if not codes.has_key(prn):
if prn not in codes:
codes[prn] = make_e5ai(prn)
return codes[prn]

Expand Down Expand Up @@ -112,4 +112,4 @@ def correlate(x,prn,chips,frac,incr,c):
if __name__=='__main__':
for prn in [1,2,3,4]:
x = e5ai_code(prn)
print x[0:24].astype('int')
print(x[0:24].astype('int'))
4 changes: 2 additions & 2 deletions gnsstools/galileo/e5aq.py
Expand Up @@ -111,7 +111,7 @@ def make_e5aq(prn):
return np.logical_xor(r1,r2)

def e5aq_code(prn):
if not codes.has_key(prn):
if prn not in codes:
codes[prn] = make_e5aq(prn)
return codes[prn]

Expand Down Expand Up @@ -140,4 +140,4 @@ def correlate(x,prn,chips,frac,incr,c):
if __name__=='__main__':
for prn in [1,2,3,4]:
x = e5aq_code(prn)
print x[0:24].astype('int')
print(x[0:24].astype('int'))
4 changes: 2 additions & 2 deletions gnsstools/galileo/e5bi.py
Expand Up @@ -69,7 +69,7 @@ def make_e5bi(prn):
return np.logical_xor(r1,r2)

def e5bi_code(prn):
if not codes.has_key(prn):
if prn not in codes:
codes[prn] = make_e5bi(prn)
return codes[prn]

Expand Down Expand Up @@ -98,4 +98,4 @@ def correlate(x,prn,chips,frac,incr,c):
if __name__=='__main__':
for prn in [1,2,3,4]:
x = e5bi_code(prn)
print x[0:24].astype('int')
print(x[0:24].astype('int'))
4 changes: 2 additions & 2 deletions gnsstools/galileo/e5bq.py
Expand Up @@ -111,7 +111,7 @@ def make_e5bq(prn):
return np.logical_xor(r1,r2)

def e5bq_code(prn):
if not codes.has_key(prn):
if prn not in codes:
codes[prn] = make_e5bq(prn)
return codes[prn]

Expand Down Expand Up @@ -140,4 +140,4 @@ def correlate(x,prn,chips,frac,incr,c):
if __name__=='__main__':
for prn in [1,2,3,4]:
x = e5bq_code(prn)
print x[0:24].astype('int')
print(x[0:24].astype('int'))
2 changes: 1 addition & 1 deletion gnsstools/glonass/ca.py
Expand Up @@ -50,4 +50,4 @@ def correlate(x,chips,frac,incr,c):
#

if __name__=='__main__':
print c[0:20]
print(c[0:20])
2 changes: 1 addition & 1 deletion gnsstools/glonass/l3i.py
Expand Up @@ -35,7 +35,7 @@ def make_l3i(n):
codes = {}

def l3i_code(n):
if not codes.has_key(n):
if n not in codes:
codes[n] = make_l3i(n)
return codes[n]

Expand Down
2 changes: 1 addition & 1 deletion gnsstools/glonass/l3q.py
Expand Up @@ -35,7 +35,7 @@ def make_l3q(n):
codes = {}

def l3q_code(n):
if not codes.has_key(n):
if n not in codes:
codes[n] = make_l3q(n)
return codes[n]

Expand Down
2 changes: 1 addition & 1 deletion gnsstools/glonass/p.py
Expand Up @@ -50,4 +50,4 @@ def correlate(x,chips,frac,incr,c):
#

if __name__=='__main__':
print c[0:100]
print(c[0:100])
6 changes: 3 additions & 3 deletions gnsstools/gps/ca.py
Expand Up @@ -99,7 +99,7 @@ def circular_shift(g,n):
codes = {}

def ca_code(prn):
if not codes.has_key(prn):
if prn not in codes:
codes[prn] = np.logical_xor(g1,circular_shift(g2,g2_delay[prn]))
return codes[prn]

Expand Down Expand Up @@ -138,8 +138,8 @@ def first_10_chips(prn):
return r

def print_first_10_chips():
for prn in g2_delay.keys():
print '%d: %04o' % (prn,first_10_chips(prn))
for prn in list(g2_delay.keys()):
print('%d: %04o' % (prn,first_10_chips(prn)))

if __name__=='__main__':
print_first_10_chips()
6 changes: 3 additions & 3 deletions gnsstools/gps/l2cl.py
Expand Up @@ -58,7 +58,7 @@ def make_l2cl(prn):
codes = {}

def l2cl_code(prn):
if not codes.has_key(prn):
if prn not in codes:
codes[prn] = make_l2cl(prn)
return codes[prn]

Expand Down Expand Up @@ -129,11 +129,11 @@ def test_end_state(prn):
return x

if __name__=='__main__':
for prn in l2cl_end_state.keys():
for prn in list(l2cl_end_state.keys()):
s = test_end_state(prn)
t = l2cl_end_state[prn]
if s!=t:
print "prn %d: ***mismatch*** %09o %09o" % (prn,s,t)
print("prn %d: ***mismatch*** %09o %09o" % (prn,s,t))
else:
# print "prn %d: %09o %09o" % (prn,s,t)
pass
6 changes: 3 additions & 3 deletions gnsstools/gps/l2cm.py
Expand Up @@ -58,7 +58,7 @@ def make_l2cm(prn):
codes = {}

def l2cm_code(prn):
if not codes.has_key(prn):
if prn not in codes:
codes[prn] = make_l2cm(prn)
return codes[prn]

Expand Down Expand Up @@ -129,11 +129,11 @@ def test_end_state(prn):
return x

if __name__=='__main__':
for prn in l2cm_end_state.keys():
for prn in list(l2cm_end_state.keys()):
s = test_end_state(prn)
t = l2cm_end_state[prn]
if s!=t:
print "prn %d: ***mismatch*** %09o %09o" % (prn,s,t)
print("prn %d: ***mismatch*** %09o %09o" % (prn,s,t))
else:
# print "prn %d: %09o %09o" % (prn,s,t)
pass
6 changes: 3 additions & 3 deletions gnsstools/gps/l5i.py
Expand Up @@ -107,7 +107,7 @@ def make_l5i(prn):
return np.logical_xor(xa,xb_shift)

def l5i_code(prn):
if not codes.has_key(prn):
if prn not in codes:
codes[prn] = make_l5i(prn)
return codes[prn]

Expand Down Expand Up @@ -147,11 +147,11 @@ def test_xb_start_state(prn):
return y

if __name__=='__main__':
for prn in xb_start_state.keys():
for prn in list(xb_start_state.keys()):
s = test_xb_start_state(prn)
t = xb_start_state[prn]
if s!=t:
print "prn %d: ***mismatch*** %s %s" % (prn,s,t)
print("prn %d: ***mismatch*** %s %s" % (prn,s,t))
else:
# print "prn %d: %s %s" % (prn,s,t)
pass
6 changes: 3 additions & 3 deletions gnsstools/gps/l5q.py
Expand Up @@ -105,7 +105,7 @@ def make_l5q(prn):
return np.logical_xor(xa,xb_shift)

def l5q_code(prn):
if not codes.has_key(prn):
if prn not in codes:
codes[prn] = make_l5q(prn)
return codes[prn]

Expand Down Expand Up @@ -145,11 +145,11 @@ def test_xb_start_state(prn):
return y

if __name__=='__main__':
for prn in xb_start_state.keys():
for prn in list(xb_start_state.keys()):
s = test_xb_start_state(prn)
t = xb_start_state[prn]
if s!=t:
print "prn %d: ***mismatch*** %s %s" % (prn,s,t)
print("prn %d: ***mismatch*** %s %s" % (prn,s,t))
else:
# print "prn %d: %s %s" % (prn,s,t)
pass
2 changes: 1 addition & 1 deletion gnsstools/gps/p.py
Expand Up @@ -115,7 +115,7 @@ def first_12_chips(prn):

def print_first_12_chips():
for prn in range(1,211):
print '%d: %04o' % (prn,first_12_chips(prn))
print('%d: %04o' % (prn,first_12_chips(prn)))

if __name__=='__main__':
print_first_12_chips()
5 changes: 3 additions & 2 deletions gnsstools/io.py
@@ -1,9 +1,10 @@
import numpy as np

def get_samples_complex(fp,n):
s = np.fromfile(fp,'b',2*n)
if len(s)!=2*n:
z = fp.read(2*n)
if len(z)!=2*n:
return None
s = np.fromstring(z,dtype='int8')
s.shape = (n,2)
x = np.empty(n,dtype='c8')
x.real = s[:,0]
Expand Down

0 comments on commit 43f6c95

Please sign in to comment.