junzis / pyModeS

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

calculate surface position using even/odd message pair #63

Closed wrobell closed 4 years ago

wrobell commented 4 years ago

It would be great if pyModeS allowed to calculate surface positions using even/odd message pairs.

At the moment it is possible to calculate surface position with a known position of receiver or an airport. But it is not possible to use that position to verify the surface position (see reasonableness tests in ICAO document 9871), because known position has no time information and might be quite far away from the surface positions (i.e. a receiver more than 2.5 nautical miles from an airport or multiple airports, etc).

Being able to use even/odd message pairs to calculate surface positions, we can verify them using distance and time information as described in the document.

wrobell commented 4 years ago

I would like to provide an example where validation, as described in ICAO document 9871, would be useful. The example is from #58.

time,typecode,icao,is_even,hpl,rcu,rcv,altitude,data
2019-11-29T11:40:12.810898+00:00,11,475001,0,185,93,,23000,8d4750015879039838daa3184811
2019-11-29T11:40:13.850254+00:00,11,475001,0,185,93,,23000,8d4750015879039848dab90a04d5
2019-11-29T11:40:16.043512+00:00,11,475001,0,185,93,,23000,8d4750015879039870daea00154e
2019-11-29T11:40:18.136748+00:00,11,475001,1,185,93,,23000,8d47500158790700b4e378e2c6da
2019-11-29T11:40:19.173048+00:00,11,475001,1,185,93,,23000,8d47500158790700c4e38d0a6e46
2019-11-29T11:40:21.007554+00:00,11,475001,0,185,93,,23000,8d47500158790398c6db5a56fa74
2019-11-29T11:40:48.130493+00:00,11,475001,0,185,93,,23000,8d4750015879039a9eddbbe68381
2019-11-29T11:40:51.409955+00:00,11,475001,0,185,93,,23000,8d4750015879039ad6de0316989f
2019-11-29T11:40:52.520525+00:00,11,475001,0,185,93,,23000,8d4750015879039aeade1e280f21
2019-11-29T11:40:57.636195+00:00,11,475001,1,185,93,,23000,8d4750015879070356e6d56fa9d8
2019-11-29T11:41:28.369844+00:00,11,475001,0,185,93,,23000,8d4750015879039d56e143a83d62
2019-11-29T11:41:35.391029+00:00,7,475001,0,185,93,,0,8d4750013fc9927745878223fd46
2019-11-29T11:41:36.563117+00:00,7,475001,0,185,93,,0,8d4750013fc992779987ef3a4826
2019-11-29T11:41:37.609665+00:00,7,475001,0,185,93,,0,8d4750013fc99277df8849c0e62f
2019-11-29T11:41:38.606173+00:00,7,475001,0,185,93,,0,8d4750013fc992782588a33bec2c
2019-11-29T11:41:40.428474+00:00,7,475001,0,185,93,,0,8d4750013fc99278a389460994a8
2019-11-29T11:41:42.341523+00:00,7,475001,1,185,93,,0,8d4750013fc9941943aa925a86a6
2019-11-29T11:41:48.502174+00:00,7,475001,1,185,93,,0,8d4750013fc9941aebacb33d4366
2019-11-29T11:41:49.550796+00:00,7,475001,1,185,93,,0,8d4750013fc9941b31ad0bd65614
2019-11-29T11:41:50.461127+00:00,7,475001,1,185,93,,0,8d4750013fc9941b75ad629639f7
2019-11-29T11:41:59.913935+00:00,7,475001,1,185,93,,0,8d4750013fc9941df7b09e3cf920

Without validation, the plane is on its track (typecode 11) and lands in Irish Sea (typecode 7). All positions reported via above messages are easily within range of my receiver, so range based verification will not filter out anything here.

At 11:41:28 the calculation of airplane track has to be restarted as previous message is more than 30s earlier.

We look for first message pair for new track start - 11:41:40 and 11:41:42. Using the message pair we calculate new position - the start of new track. This position has to be validated with next independent message pair. Such pair does not exist. This will invalidate all positions landing the plane in Irish Sea.

junzis commented 4 years ago

Have you tried to use the following?

pms.adsb.position(msg_even, msg_odd, t_even, t_odd, lat_ref=None, lon_ref=None)

With this function, you can also use a pair of even/odd surface position messages. However, you always need the reference position for surface position decoding.

The corresponding lower-level function is at: https://github.com/junzis/pyModeS/blob/master/pyModeS/decoder/bds/bds06.py#L12

wrobell commented 4 years ago

Thanks for the pointer. I got confused by the error message when I specified no reference position.