Move CPR test code to main function within cpr.py
This commit is contained in:
parent
ce28741e84
commit
da41dd3c84
@ -1,40 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
import numpy
|
|
||||||
import mlat
|
|
||||||
|
|
||||||
#rudi says:
|
|
||||||
#17 8da12615 903bf4bd3eb2c0 36ac95 000000 0.0007421782357 2.54791875
|
|
||||||
#17 8d4b190a 682de4acf8c177 5b8f55 000000 0.0005142348236 2.81227225
|
|
||||||
|
|
||||||
#sf says:
|
|
||||||
#17 8da12615 903bf4bd3eb2c0 36ac95 000000 0.003357535461 00.1817445
|
|
||||||
#17 8d4b190a 682de4acf8c177 5b8f55 000000 0.002822938375 000.446215
|
|
||||||
|
|
||||||
sf_station = [37.762236,-122.442525, 100]
|
|
||||||
mv_station = [37.409348,-122.07732, 100]
|
|
||||||
|
|
||||||
report1_location = [37.737804, -122.485139, 3345]
|
|
||||||
report1_sf_tstamp = 0.1817445
|
|
||||||
report1_mv_tstamp = 2.54791875
|
|
||||||
|
|
||||||
report2_location = [37.640836, -122.260218, 2484]
|
|
||||||
report2_sf_tstamp = 0.446215
|
|
||||||
report2_mv_tstamp = 2.81227225
|
|
||||||
|
|
||||||
report1_tof_sf = numpy.linalg.norm(numpy.array(mlat.llh2ecef(sf_station))-numpy.array(mlat.llh2ecef(report1_location))) / mlat.c
|
|
||||||
report1_tof_mv = numpy.linalg.norm(numpy.array(mlat.llh2ecef(mv_station))-numpy.array(mlat.llh2ecef(report1_location))) / mlat.c
|
|
||||||
|
|
||||||
report1_sf_tstamp_abs = report1_sf_tstamp - report1_tof_sf
|
|
||||||
report1_mv_tstamp_abs = report1_mv_tstamp - report1_tof_mv
|
|
||||||
|
|
||||||
report2_tof_sf = numpy.linalg.norm(numpy.array(mlat.llh2ecef(sf_station))-numpy.array(mlat.llh2ecef(report2_location))) / mlat.c
|
|
||||||
report2_tof_mv = numpy.linalg.norm(numpy.array(mlat.llh2ecef(mv_station))-numpy.array(mlat.llh2ecef(report2_location))) / mlat.c
|
|
||||||
|
|
||||||
report2_sf_tstamp_abs = report2_sf_tstamp - report2_tof_sf
|
|
||||||
report2_mv_tstamp_abs = report2_mv_tstamp - report2_tof_mv
|
|
||||||
|
|
||||||
dt1 = report1_sf_tstamp_abs - report1_mv_tstamp_abs
|
|
||||||
dt2 = report2_sf_tstamp_abs - report2_mv_tstamp_abs
|
|
||||||
|
|
||||||
error = abs((dt1-dt2) * mlat.c)
|
|
||||||
print error
|
|
@ -1,63 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
#
|
|
||||||
# Copyright 2010 Nick Foster
|
|
||||||
#
|
|
||||||
# This file is part of gr-air-modes
|
|
||||||
#
|
|
||||||
# gr-air-modes is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 3, or (at your option)
|
|
||||||
# any later version.
|
|
||||||
#
|
|
||||||
# gr-air-modes is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with gr-air-modes; see the file COPYING. If not, write to
|
|
||||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
|
||||||
# Boston, MA 02110-1301, USA.
|
|
||||||
#
|
|
||||||
|
|
||||||
from modes_parse import *
|
|
||||||
from cpr import *
|
|
||||||
import sys
|
|
||||||
|
|
||||||
my_location = [37.76225, -122.44254]
|
|
||||||
|
|
||||||
shortdata = long(sys.argv[1], 16)
|
|
||||||
longdata = long(sys.argv[2], 16)
|
|
||||||
parity = long(sys.argv[3], 16)
|
|
||||||
ecc = long(sys.argv[4], 16)
|
|
||||||
|
|
||||||
parser = modes_parse(my_location)
|
|
||||||
|
|
||||||
[altitude, decoded_lat, decoded_lon, rnge, bearing] = parser.parseBDS06(shortdata, longdata, parity, ecc)
|
|
||||||
|
|
||||||
if decoded_lat is not None:
|
|
||||||
print "Altitude: %i\nLatitude: %.6f\nLongitude: %.6f\nRange: %.2f\nBearing: %i\n" % (altitude, decoded_lat, decoded_lon, rnge, bearing,)
|
|
||||||
|
|
||||||
print "Decomposing...\n"
|
|
||||||
|
|
||||||
subtype = (longdata >> 51) & 0x1F;
|
|
||||||
|
|
||||||
encoded_lon = longdata & 0x1FFFF
|
|
||||||
encoded_lat = (longdata >> 17) & 0x1FFFF
|
|
||||||
cpr_format = (longdata >> 34) & 1
|
|
||||||
|
|
||||||
enc_alt = (longdata >> 36) & 0x0FFF
|
|
||||||
|
|
||||||
[cpr_lat, cpr_lon] = cpr_resolve_local(my_location, [encoded_lat, encoded_lon], cpr_format, 1)
|
|
||||||
|
|
||||||
print "Subtype: %i\nEncoded longitude: %x\nEncoded latitude: %x\nCPR format: %i\nEncoded altitude: %x\n" % (subtype, encoded_lon, encoded_lat, cpr_format, enc_alt,)
|
|
||||||
print "Pos: %.6f %.6f" % (cpr_lat, cpr_lon)
|
|
||||||
|
|
||||||
#print "First argument is order %i, second %i" % ((evendata >> 34) & 1, (odddata >> 34) & 1,)
|
|
||||||
|
|
||||||
#evenencpos = [(evendata >> 17) & 0x1FFFF, evendata & 0x1FFFF]
|
|
||||||
#oddencpos = [(odddata >> 17) & 0x1FFFF, odddata & 0x1FFFF]
|
|
||||||
|
|
||||||
#[declat, declon] = cpr_decode_global(evenencpos, oddencpos, newer)
|
|
||||||
|
|
||||||
#print "Global latitude: %.6f\nGlobal longitude: %.6f" % (declat, declon,)
|
|
35
python/cpr.py
Normal file → Executable file
35
python/cpr.py
Normal file → Executable file
@ -117,6 +117,8 @@ def cpr_resolve_global(evenpos, oddpos, mostrecent, surface): #ok this is consid
|
|||||||
rlateven = dlateven * (mod(j, 60)+evenpos[0]/2**nbits(surface))
|
rlateven = dlateven * (mod(j, 60)+evenpos[0]/2**nbits(surface))
|
||||||
rlatodd = dlatodd * (mod(j, 59)+ oddpos[0]/2**nbits(surface))
|
rlatodd = dlatodd * (mod(j, 59)+ oddpos[0]/2**nbits(surface))
|
||||||
|
|
||||||
|
#This checks to see if the latitudes of the reports straddle a transition boundary
|
||||||
|
#If so, you can't get a globally-resolvable location.
|
||||||
if nl(rlateven) != nl(rlatodd):
|
if nl(rlateven) != nl(rlatodd):
|
||||||
#print "Boundary straddle!"
|
#print "Boundary straddle!"
|
||||||
return (None, None,)
|
return (None, None,)
|
||||||
@ -260,3 +262,36 @@ def cpr_encode(lat, lon, ctype, surface):
|
|||||||
xz = int(mod(xz, scalar))
|
xz = int(mod(xz, scalar))
|
||||||
|
|
||||||
return (yz, xz) #lat, lon
|
return (yz, xz) #lat, lon
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
from modes_parse import *
|
||||||
|
import sys
|
||||||
|
|
||||||
|
my_location = [37.76225, -122.44254]
|
||||||
|
|
||||||
|
shortdata = long(sys.argv[1], 16)
|
||||||
|
longdata = long(sys.argv[2], 16)
|
||||||
|
parity = long(sys.argv[3], 16)
|
||||||
|
ecc = long(sys.argv[4], 16)
|
||||||
|
|
||||||
|
parser = modes_parse(my_location)
|
||||||
|
|
||||||
|
[altitude, decoded_lat, decoded_lon, rnge, bearing] = parser.parseBDS06(shortdata, longdata, parity, ecc)
|
||||||
|
|
||||||
|
if decoded_lat is not None:
|
||||||
|
print "Altitude: %i\nLatitude: %.6f\nLongitude: %.6f\nRange: %.2f\nBearing: %i\n" % (altitude, decoded_lat, decoded_lon, rnge, bearing,)
|
||||||
|
|
||||||
|
print "Decomposing...\n"
|
||||||
|
|
||||||
|
subtype = (longdata >> 51) & 0x1F;
|
||||||
|
|
||||||
|
encoded_lon = longdata & 0x1FFFF
|
||||||
|
encoded_lat = (longdata >> 17) & 0x1FFFF
|
||||||
|
cpr_format = (longdata >> 34) & 1
|
||||||
|
|
||||||
|
enc_alt = (longdata >> 36) & 0x0FFF
|
||||||
|
|
||||||
|
[cpr_lat, cpr_lon] = cpr_resolve_local(my_location, [encoded_lat, encoded_lon], cpr_format, 1)
|
||||||
|
|
||||||
|
print "Subtype: %i\nEncoded longitude: %x\nEncoded latitude: %x\nCPR format: %i\nEncoded altitude: %x\n" % (subtype, encoded_lon, encoded_lat, cpr_format, enc_alt,)
|
||||||
|
print "Pos: %.6f %.6f" % (cpr_lat, cpr_lon)
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
import modes_print
|
|
||||||
|
|
||||||
infile = open("27augrudi3.txt")
|
|
||||||
|
|
||||||
printer = modes_print.modes_output_print([37.409348,-122.07732])
|
|
||||||
for line in infile:
|
|
||||||
printer.parse(line)
|
|
Loading…
Reference in New Issue
Block a user