velocity default argument for backwards compatibility
This commit is contained in:
parent
fc9b05b6f1
commit
3c14579040
@ -143,12 +143,16 @@ 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, string, string): speed (kt),
|
(int, float, int, string, string, string): speed (kt),
|
||||||
@ -160,14 +164,14 @@ def velocity(msg):
|
|||||||
barometer, 'GNSS' for GNSS constellation).
|
barometer, 'GNSS' for GNSS constellation).
|
||||||
|
|
||||||
In the case of surface messages, None will be put in place
|
In the case of surface messages, None will be put in place
|
||||||
for direction, vertical rate, and their respective sources.
|
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")
|
||||||
|
@ -141,13 +141,17 @@ 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, None, string, string, None): speed (kt),
|
(int, float, int, string, string, None): speed (kt),
|
||||||
ground track (degree), None for rate of climb/descend (ft/min),
|
ground track (degree), None for rate of climb/descend (ft/min),
|
||||||
and speed type ('GS' for ground speed), direction source
|
and speed type ('GS' for ground speed), direction source
|
||||||
('gnd_trk' for ground track), None rate of climb/descent source.
|
('gnd_trk' for ground track), None rate of climb/descent source.
|
||||||
@ -183,4 +187,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, None, 'GS', 'gnd_trk', None
|
if rtn_sources:
|
||||||
|
return spd, trk, 0, 'GS', 'gnd_trk', None
|
||||||
|
else:
|
||||||
|
return spd, trk, 0, 'GS'
|
||||||
|
@ -25,11 +25,15 @@ 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, string, string): speed (kt),
|
(int, float, int, string, string, string): speed (kt),
|
||||||
@ -96,7 +100,11 @@ def airborne_velocity(msg):
|
|||||||
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, dir_type, vr_source
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user