From c9159feb7d763c336d97764d534bac82e8b5dba9 Mon Sep 17 00:00:00 2001 From: Alexander Hirsch Date: Thu, 16 May 2019 19:05:19 -0700 Subject: [PATCH 1/6] BDS09 returns direction and v/s source --- pyModeS/decoder/bds/bds09.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pyModeS/decoder/bds/bds09.py b/pyModeS/decoder/bds/bds09.py index 49ce794..8a3a384 100644 --- a/pyModeS/decoder/bds/bds09.py +++ b/pyModeS/decoder/bds/bds09.py @@ -32,9 +32,13 @@ def airborne_velocity(msg): msg (string): 28 bytes hexadecimal message string Returns: - (int, float, int, string): speed (kt), ground track or heading (degree), - rate of climb/descend (ft/min), and speed type - ('GS' for ground speed, 'AS' for airspeed) + (int, float, int, string, string, string): speed (kt), + ground track or heading (degree), + rate of climb/descent (ft/min), speed type + ('GS' for ground speed, 'AS' for airspeed), + direction source ('gnd_trk' for ground track, 'mag_hdg' for + magnetic heading), rate of climb/descent source ('Baro' for + barometer, 'GNSS' for GNSS constellation) """ if common.typecode(msg) != 19: @@ -66,6 +70,7 @@ def airborne_velocity(msg): tag = 'GS' trk_or_hdg = round(trk, 2) + dir_type = 'gnd_trk' else: if mb[13] == '0': @@ -83,12 +88,15 @@ def airborne_velocity(msg): tag = 'IAS' else: tag = 'TAS' + + dir_type = 'mag_hdg' + vr_source = 'GNSS' if mb[35]=='0' else 'Baro' vr_sign = -1 if mb[36]=='1' else 1 vr = common.bin2int(mb[37:46]) rocd = None if vr==0 else int(vr_sign*(vr-1)*64) - return spd, trk_or_hdg, rocd, tag + return spd, trk_or_hdg, rocd, tag, dir_type, vr_source def altitude_diff(msg): """Decode the differece between GNSS and barometric altitude From b813e41343537bd75177f853ee47cb9975bfac82 Mon Sep 17 00:00:00 2001 From: Alexander Hirsch Date: Fri, 17 May 2019 05:59:14 -0700 Subject: [PATCH 2/6] Fixed ground velocity return and updated velocity docstring --- pyModeS/decoder/adsb.py | 13 ++++++++++--- pyModeS/decoder/bds/bds06.py | 9 +++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/pyModeS/decoder/adsb.py b/pyModeS/decoder/adsb.py index d3699ba..521ce1d 100644 --- a/pyModeS/decoder/adsb.py +++ b/pyModeS/decoder/adsb.py @@ -151,9 +151,16 @@ def velocity(msg): msg (string): 28 bytes hexadecimal message string Returns: - (int, float, int, string): speed (kt), ground track or heading (degree), - rate of climb/descend (ft/min), and speed type - ('GS' for ground speed, 'AS' for airspeed) + (int, float, int, string, string, string): speed (kt), + ground track or heading (degree), + rate of climb/descent (ft/min), speed type + ('GS' for ground speed, 'AS' for airspeed), + direction source ('gnd_trk' for ground track, 'mag_hdg' for + magnetic heading), 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 direction, vertical rate, and their respective sources. """ if 5 <= typecode(msg) <= 8: diff --git a/pyModeS/decoder/bds/bds06.py b/pyModeS/decoder/bds/bds06.py index bceb643..03ce272 100644 --- a/pyModeS/decoder/bds/bds06.py +++ b/pyModeS/decoder/bds/bds06.py @@ -147,9 +147,10 @@ def surface_velocity(msg): msg (string): 28 bytes hexadecimal message string Returns: - (int, float, int, string): speed (kt), ground track (degree), - rate of climb/descend (ft/min), and speed type - ('GS' for ground speed, 'AS' for airspeed) + (int, float, None, string, None, None): speed (kt), + ground track (degree), None for rate of climb/descend (ft/min), + and speed type ('GS' for ground speed), direction source + ('gnd_trk' for ground track), None rate of climb/descent source. """ if common.typecode(msg) < 5 or common.typecode(msg) > 8: @@ -182,4 +183,4 @@ def surface_velocity(msg): spd = kts[i-1] + (mov-movs[i-1]) * step spd = round(spd, 2) - return spd, trk, 0, 'GS' + return spd, trk, None, 'GS', None, None From fc9b05b6f1ac5a6a1e7dbdf0fa8a3187a7d33a7c Mon Sep 17 00:00:00 2001 From: Alexander Hirsch Date: Fri, 17 May 2019 06:06:06 -0700 Subject: [PATCH 3/6] Added direction source to ground_velocity() --- pyModeS/decoder/bds/bds06.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyModeS/decoder/bds/bds06.py b/pyModeS/decoder/bds/bds06.py index 03ce272..8b9df07 100644 --- a/pyModeS/decoder/bds/bds06.py +++ b/pyModeS/decoder/bds/bds06.py @@ -147,7 +147,7 @@ def surface_velocity(msg): msg (string): 28 bytes hexadecimal message string Returns: - (int, float, None, string, None, None): speed (kt), + (int, float, None, string, string, None): speed (kt), ground track (degree), None for rate of climb/descend (ft/min), and speed type ('GS' for ground speed), direction source ('gnd_trk' for ground track), None rate of climb/descent source. @@ -183,4 +183,4 @@ def surface_velocity(msg): spd = kts[i-1] + (mov-movs[i-1]) * step spd = round(spd, 2) - return spd, trk, None, 'GS', None, None + return spd, trk, None, 'GS', 'gnd_trk', None From 3c14579040bcbe88bc4b5219eebc8de4aab339ab Mon Sep 17 00:00:00 2001 From: Alexander Hirsch Date: Fri, 17 May 2019 09:45:16 -0700 Subject: [PATCH 4/6] velocity default argument for backwards compatibility --- pyModeS/decoder/adsb.py | 12 ++++++++---- pyModeS/decoder/bds/bds06.py | 13 ++++++++++--- pyModeS/decoder/bds/bds09.py | 12 ++++++++++-- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/pyModeS/decoder/adsb.py b/pyModeS/decoder/adsb.py index 521ce1d..9253ee5 100644 --- a/pyModeS/decoder/adsb.py +++ b/pyModeS/decoder/adsb.py @@ -143,12 +143,16 @@ def altitude(msg): return None -def velocity(msg): +def velocity(msg, rtn_sources=False): """Calculate the speed, heading, and vertical rate (handles both airborne or surface message) Args: 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: (int, float, int, string, string, string): speed (kt), @@ -160,14 +164,14 @@ def velocity(msg): barometer, 'GNSS' for GNSS constellation). 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: - return surface_velocity(msg) + return surface_velocity(msg, rtn_sources) elif typecode(msg) == 19: - return airborne_velocity(msg) + return airborne_velocity(msg, rtn_sources) else: raise RuntimeError("incorrect or inconsistant message types, expecting 4 Date: Mon, 27 May 2019 08:13:02 -0700 Subject: [PATCH 5/6] Changed velocity source names --- pyModeS/decoder/adsb.py | 2 +- pyModeS/decoder/bds/bds06.py | 4 ++-- pyModeS/decoder/bds/bds09.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pyModeS/decoder/adsb.py b/pyModeS/decoder/adsb.py index 9253ee5..b9821b2 100644 --- a/pyModeS/decoder/adsb.py +++ b/pyModeS/decoder/adsb.py @@ -159,7 +159,7 @@ def velocity(msg, rtn_sources=False): ground track or heading (degree), rate of climb/descent (ft/min), speed type ('GS' for ground speed, 'AS' for airspeed), - direction source ('gnd_trk' for ground track, 'mag_hdg' for + direction source ('true_north' for ground track, 'mag_north' for magnetic heading), rate of climb/descent source ('Baro' for barometer, 'GNSS' for GNSS constellation). diff --git a/pyModeS/decoder/bds/bds06.py b/pyModeS/decoder/bds/bds06.py index d387696..69cff54 100644 --- a/pyModeS/decoder/bds/bds06.py +++ b/pyModeS/decoder/bds/bds06.py @@ -154,7 +154,7 @@ def surface_velocity(msg, rtn_sources=False): (int, float, int, string, string, None): speed (kt), ground track (degree), None for rate of climb/descend (ft/min), and speed type ('GS' for ground speed), direction source - ('gnd_trk' for ground track), None rate of climb/descent source. + ('true_north' for ground track), None rate of climb/descent source. """ if common.typecode(msg) < 5 or common.typecode(msg) > 8: @@ -188,6 +188,6 @@ def surface_velocity(msg, rtn_sources=False): spd = round(spd, 2) if rtn_sources: - return spd, trk, 0, 'GS', 'gnd_trk', None + return spd, trk, 0, 'GS', 'true_north', None else: return spd, trk, 0, 'GS' diff --git a/pyModeS/decoder/bds/bds09.py b/pyModeS/decoder/bds/bds09.py index 50ec8e2..8f5e386 100644 --- a/pyModeS/decoder/bds/bds09.py +++ b/pyModeS/decoder/bds/bds09.py @@ -40,7 +40,7 @@ def airborne_velocity(msg, rtn_sources=False): ground track or heading (degree), rate of climb/descent (ft/min), speed type ('GS' for ground speed, 'AS' for airspeed), - direction source ('gnd_trk' for ground track, 'mag_hdg' for + direction source ('true_north' for ground track, 'mag_north' for magnetic heading), rate of climb/descent source ('Baro' for barometer, 'GNSS' for GNSS constellation) """ @@ -74,7 +74,7 @@ def airborne_velocity(msg, rtn_sources=False): tag = 'GS' trk_or_hdg = round(trk, 2) - dir_type = 'gnd_trk' + dir_type = 'true_north' else: if mb[13] == '0': @@ -93,7 +93,7 @@ def airborne_velocity(msg, rtn_sources=False): else: tag = 'TAS' - dir_type = 'mag_hdg' + dir_type = 'mag_north' vr_source = 'GNSS' if mb[35]=='0' else 'Baro' vr_sign = -1 if mb[36]=='1' else 1 From 6fc68841ce3e6e9a9429cc53a3bbe69be7768608 Mon Sep 17 00:00:00 2001 From: Alexander Hirsch Date: Mon, 27 May 2019 08:25:11 -0700 Subject: [PATCH 6/6] Updted docstrings for velocity messages --- pyModeS/decoder/adsb.py | 7 ++++--- pyModeS/decoder/bds/bds06.py | 3 ++- pyModeS/decoder/bds/bds09.py | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pyModeS/decoder/adsb.py b/pyModeS/decoder/adsb.py index b9821b2..bd8daa4 100644 --- a/pyModeS/decoder/adsb.py +++ b/pyModeS/decoder/adsb.py @@ -159,9 +159,10 @@ def velocity(msg, rtn_sources=False): ground track or heading (degree), rate of climb/descent (ft/min), speed type ('GS' for ground speed, 'AS' for airspeed), - direction source ('true_north' for ground track, 'mag_north' for - magnetic heading), rate of climb/descent source ('Baro' for - barometer, 'GNSS' for GNSS constellation). + 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. diff --git a/pyModeS/decoder/bds/bds06.py b/pyModeS/decoder/bds/bds06.py index 69cff54..2c6c346 100644 --- a/pyModeS/decoder/bds/bds06.py +++ b/pyModeS/decoder/bds/bds06.py @@ -154,7 +154,8 @@ def surface_velocity(msg, rtn_sources=False): (int, float, int, string, string, None): speed (kt), ground track (degree), None for rate of climb/descend (ft/min), and speed type ('GS' for ground speed), direction source - ('true_north' for ground track), None rate of climb/descent 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: diff --git a/pyModeS/decoder/bds/bds09.py b/pyModeS/decoder/bds/bds09.py index 8f5e386..3ccdae6 100644 --- a/pyModeS/decoder/bds/bds09.py +++ b/pyModeS/decoder/bds/bds09.py @@ -40,9 +40,10 @@ def airborne_velocity(msg, rtn_sources=False): ground track or heading (degree), rate of climb/descent (ft/min), speed type ('GS' for ground speed, 'AS' for airspeed), - direction source ('true_north' for ground track, 'mag_north' for - magnetic heading), rate of climb/descent source ('Baro' for - barometer, 'GNSS' for GNSS constellation) + 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: