Merge pull request #39 from amhirsch/DF-17Additions

Additional Information Extracted from TC-19/BDS0,9 Messages
This commit is contained in:
Junzi Sun
2019-05-27 20:26:23 +02:00
committed by GitHub
3 changed files with 54 additions and 16 deletions
+18 -6
View File
@@ -143,24 +143,36 @@ def altitude(msg):
return None return None
def velocity(msg): def velocity(msg, rtn_sources=False):
"""Calculate the speed, heading, and vertical rate """Calculate the speed, heading, and vertical rate
(handles both airborne or surface message) (handles both airborne or surface message)
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
rtn_source (boolean): If the function will return
the sources for direction of travel and vertical
rate. This will change the return value from a four
element array to a six element array.
Returns: Returns:
(int, float, int, string): speed (kt), ground track or heading (degree), (int, float, int, string, string, string): speed (kt),
rate of climb/descend (ft/min), and speed type ground track or heading (degree),
('GS' for ground speed, 'AS' for airspeed) rate of climb/descent (ft/min), speed type
('GS' for ground speed, 'AS' for airspeed),
direction source ('true_north' for ground track / true north
as refrence, 'mag_north' for magnetic north as reference),
rate of climb/descent source ('Baro' for barometer, 'GNSS'
for GNSS constellation).
In the case of surface messages, None will be put in place
for vertical rate and its respective sources.
""" """
if 5 <= typecode(msg) <= 8: if 5 <= typecode(msg) <= 8:
return surface_velocity(msg) return surface_velocity(msg, rtn_sources)
elif typecode(msg) == 19: elif typecode(msg) == 19:
return airborne_velocity(msg) return airborne_velocity(msg, rtn_sources)
else: else:
raise RuntimeError("incorrect or inconsistant message types, expecting 4<TC<9 or TC=19") raise RuntimeError("incorrect or inconsistant message types, expecting 4<TC<9 or TC=19")
+14 -5
View File
@@ -141,15 +141,21 @@ def surface_position_with_ref(msg, lat_ref, lon_ref):
return round(lat, 5), round(lon, 5) return round(lat, 5), round(lon, 5)
def surface_velocity(msg): def surface_velocity(msg, rtn_sources=False):
"""Decode surface velocity from from a surface position message """Decode surface velocity from from a surface position message
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
rtn_source (boolean): If the function will return
the sources for direction of travel and vertical
rate. This will change the return value from a four
element array to a six element array.
Returns: Returns:
(int, float, int, string): speed (kt), ground track (degree), (int, float, int, string, string, None): speed (kt),
rate of climb/descend (ft/min), and speed type ground track (degree), None for rate of climb/descend (ft/min),
('GS' for ground speed, 'AS' for airspeed) and speed type ('GS' for ground speed), direction source
('true_north' for ground track / true north as reference),
None rate of climb/descent source.
""" """
if common.typecode(msg) < 5 or common.typecode(msg) > 8: if common.typecode(msg) < 5 or common.typecode(msg) > 8:
@@ -182,4 +188,7 @@ def surface_velocity(msg):
spd = kts[i-1] + (mov-movs[i-1]) * step spd = kts[i-1] + (mov-movs[i-1]) * step
spd = round(spd, 2) spd = round(spd, 2)
return spd, trk, 0, 'GS' if rtn_sources:
return spd, trk, 0, 'GS', 'true_north', None
else:
return spd, trk, 0, 'GS'
+22 -5
View File
@@ -25,16 +25,25 @@ from pyModeS.decoder import common
import math import math
def airborne_velocity(msg): def airborne_velocity(msg, rtn_sources=False):
"""Calculate the speed, track (or heading), and vertical rate """Calculate the speed, track (or heading), and vertical rate
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
rtn_source (boolean): If the function will return
the sources for direction of travel and vertical
rate. This will change the return value from a four
element array to a six element array.
Returns: Returns:
(int, float, int, string): speed (kt), ground track or heading (degree), (int, float, int, string, string, string): speed (kt),
rate of climb/descend (ft/min), and speed type ground track or heading (degree),
('GS' for ground speed, 'AS' for airspeed) rate of climb/descent (ft/min), speed type
('GS' for ground speed, 'AS' for airspeed),
direction source ('true_north' for ground track / true north
as refrence, 'mag_north' for magnetic north as reference),
rate of climb/descent source ('Baro' for barometer, 'GNSS'
for GNSS constellation).
""" """
if common.typecode(msg) != 19: if common.typecode(msg) != 19:
@@ -66,6 +75,7 @@ def airborne_velocity(msg):
tag = 'GS' tag = 'GS'
trk_or_hdg = round(trk, 2) trk_or_hdg = round(trk, 2)
dir_type = 'true_north'
else: else:
if mb[13] == '0': if mb[13] == '0':
@@ -84,11 +94,18 @@ def airborne_velocity(msg):
else: else:
tag = 'TAS' tag = 'TAS'
dir_type = 'mag_north'
vr_source = 'GNSS' if mb[35]=='0' else 'Baro'
vr_sign = -1 if mb[36]=='1' else 1 vr_sign = -1 if mb[36]=='1' else 1
vr = common.bin2int(mb[37:46]) vr = common.bin2int(mb[37:46])
rocd = None if vr==0 else int(vr_sign*(vr-1)*64) rocd = None if vr==0 else int(vr_sign*(vr-1)*64)
return spd, trk_or_hdg, rocd, tag if rtn_sources:
return spd, trk_or_hdg, rocd, tag, dir_type, vr_source
else:
return spd, trk_or_hdg, rocd, tag
def altitude_diff(msg): def altitude_diff(msg):
"""Decode the differece between GNSS and barometric altitude """Decode the differece between GNSS and barometric altitude