junzis / pyModeS

Python decoder for Mode S and ADS-B signals
GNU General Public License v3.0
529 stars 151 forks source link

Decoding position problem #28

Closed aaubrypro closed 5 years ago

aaubrypro commented 5 years ago

Hi,

I found out some problems with the position function. It gives me non continuous positions, sometimes jumping over several hundred km. I have a unit test reproducing the (possible) bug. It contains a set of real world ads-b messages. It seems to be coming from the calculation of the latitude index (j). At a certain moment, it goes from 7 to 8, and the tracks start jumping far from their actual position. When I force j=7, the result is correct.

 from pyModeS import adsb

 def test_adsb_icao():

# msg1 : odd msg
msg1 = "8D40093F5893F696E3FE74F04E96"
t1 = 1

# msg2 : even msg
msg2 = "8D40093F5897A3226409EFF5ACB6"
t2 = 2

# msg3 : even msg
msg3 = "8D40093F589B132BFC05D0C78026"
t3 = 3

pos = adsb.position(msg2, msg1, t2, t1)
assert pos == (46.70151, 8.95084)

pos = adsb.position(msg3, msg1, t3, t1)
# Found (52.75772, 10.11353), expected (46.7375, 8.9127)
assert pos == (46.7375, 8.9127)

Thanks.

aaubrypro commented 5 years ago

Finally, there is no problem. The msg3 came 23 seconds later after msg2. In this case (over 10 seconds), the global calculation way is not recommanded.

junzis commented 5 years ago

Hi @aaubrypro, In this case you can still use msg3 and previous decoded position with function pms.adsb.airborne_position_with_ref(msg, lat_ref, lon_ref), as long as the reference location is within 180nm (~ 330km).