From 1f15a953e38605d876fcba31801c5a890acc1440 Mon Sep 17 00:00:00 2001 From: Junzi Sun Date: Wed, 29 Jul 2020 00:53:05 +0200 Subject: [PATCH] minor fix in surface speed calculation --- pyModeS/decoder/bds/bds06.py | 12 +++++------- tests/test_adsb.py | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pyModeS/decoder/bds/bds06.py b/pyModeS/decoder/bds/bds06.py index 2c366ce..bd7a8f8 100644 --- a/pyModeS/decoder/bds/bds06.py +++ b/pyModeS/decoder/bds/bds06.py @@ -168,13 +168,11 @@ def surface_velocity(msg, source=False): elif mov == 124: spd = 175 else: - movs = [2, 9, 13, 39, 94, 109, 124] - kts = [0.125, 1, 2, 15, 70, 100, 175] - i = next(m[0] for m in enumerate(movs) if m[1] > mov) - step = (kts[i] - kts[i - 1]) * 1.0 / (movs[i] - movs[i - 1]) - spd = kts[i - 1] + (mov - movs[i - 1]) * step - spd = round(spd, 2) - + mov_lb = [2, 9, 13, 39, 94, 109, 124] + kts_lb = [0.125, 1, 2, 15, 70, 100, 175] + step = [0.125, 0.25, 0.5, 1, 2, 5] + i = next(m[0] for m in enumerate(mov_lb) if m[1] > mov) + spd = kts_lb[i - 1] + (mov - mov_lb[i - 1]) * step[i - 1] if source: return spd, trk, 0, "GS", "TRUE_NORTH", None else: diff --git a/tests/test_adsb.py b/tests/test_adsb.py index c6e6de0..2b8b631 100644 --- a/tests/test_adsb.py +++ b/tests/test_adsb.py @@ -76,7 +76,7 @@ def test_adsb_velocity(): vgs_surface = adsb.velocity("8FC8200A3AB8F5F893096B000000") assert vgs == (159, 182.88, -832, "GS") assert vas == (375, 243.98, -2304, "TAS") - assert vgs_surface == (19.0, 42.2, 0, "GS") + assert vgs_surface == (19, 42.2, 0, "GS") assert adsb.altitude_diff("8D485020994409940838175B284F") == 550