2010-12-06 09:43:13 +08:00
|
|
|
#!/usr/bin/python
|
|
|
|
import mlat
|
|
|
|
import numpy
|
|
|
|
|
2011-07-15 08:01:43 +08:00
|
|
|
#here's some test data to validate the algorithm
|
2011-08-25 09:19:57 +08:00
|
|
|
teststations = [[37.76225, -122.44254, 100], [37.680016,-121.772461, 100], [37.385844,-122.083082, 100], [37.701207,-122.309418, 100]]
|
2011-07-15 08:01:43 +08:00
|
|
|
testalt = 8000
|
2011-07-15 09:49:47 +08:00
|
|
|
testplane = numpy.array(mlat.llh2ecef([37.617175,-122.400843, testalt]))
|
2011-07-15 08:01:43 +08:00
|
|
|
testme = mlat.llh2geoid(teststations[0])
|
|
|
|
teststamps = [10,
|
|
|
|
10 + numpy.linalg.norm(testplane-numpy.array(mlat.llh2geoid(teststations[1]))) / mlat.c,
|
|
|
|
10 + numpy.linalg.norm(testplane-numpy.array(mlat.llh2geoid(teststations[2]))) / mlat.c,
|
2011-07-15 09:49:47 +08:00
|
|
|
10 + numpy.linalg.norm(testplane-numpy.array(mlat.llh2geoid(teststations[3]))) / mlat.c,
|
2011-07-15 08:01:43 +08:00
|
|
|
]
|
|
|
|
|
2011-07-15 09:49:47 +08:00
|
|
|
print teststamps
|
|
|
|
|
2010-12-07 02:28:44 +08:00
|
|
|
replies = []
|
2011-07-15 08:01:43 +08:00
|
|
|
for i in range(0, len(teststations)):
|
|
|
|
replies.append((teststations[i], teststamps[i]))
|
|
|
|
ans = mlat.mlat(replies, testalt)
|
|
|
|
error = numpy.linalg.norm(numpy.array(mlat.llh2ecef(ans))-numpy.array(testplane))
|
2011-07-15 09:49:47 +08:00
|
|
|
range = numpy.linalg.norm(mlat.llh2geoid(ans)-numpy.array(testme))
|
|
|
|
print testplane-testme
|
|
|
|
print ans
|
2010-12-07 02:28:44 +08:00
|
|
|
print "Error: %.2fm" % (error)
|
|
|
|
print "Range: %.2fkm (from first station in list)" % (range/1000)
|