diff --git a/pyModeS/decoder/bds/__init__.py b/pyModeS/decoder/bds/__init__.py index f3ed2d2..7ace4c2 100644 --- a/pyModeS/decoder/bds/__init__.py +++ b/pyModeS/decoder/bds/__init__.py @@ -60,25 +60,34 @@ def is50or60(msg, spd_ref, trk_ref, alt_ref): vy = v * np.cos(np.radians(angle)) return vx, vy + # message must be both BDS 50 and 60 before processing if not (bds50.is50(msg) and bds60.is60(msg)): return None - h50 = bds50.trk50(msg) - v50 = bds50.gs50(msg) - - if h50 is None or v50 is None: - return "BDS50,BDS60" - + # --- assuming BDS60 --- h60 = bds60.hdg60(msg) m60 = bds60.mach60(msg) i60 = bds60.ias60(msg) + # additional check now knowing the altitude + if (m60 is not None) and (i60 is not None): + ias_ = aero.mach2cas(m60, alt_ref * aero.ft) / aero.kts + if abs(i60 - ias_) > 20: + return "BDS50" + if h60 is None or (m60 is None and i60 is None): return "BDS50,BDS60" m60 = np.nan if m60 is None else m60 i60 = np.nan if i60 is None else i60 + # --- assuming BDS50 --- + h50 = bds50.trk50(msg) + v50 = bds50.gs50(msg) + + if h50 is None or v50 is None: + return "BDS50,BDS60" + XY5 = vxy(v50 * aero.kts, h50) XY6m = vxy(aero.mach2tas(m60, alt_ref * aero.ft), h60) XY6i = vxy(aero.cas2tas(i60 * aero.kts, alt_ref * aero.ft), h60) @@ -98,6 +107,7 @@ def is50or60(msg, spd_ref, trk_ref, alt_ref): try: dist = np.linalg.norm(X - Mu, axis=1) BDS = allbds[np.nanargmin(dist)] + print(dist, BDS) except ValueError: return "BDS50,BDS60" diff --git a/pyModeS/decoder/bds/bds50.py b/pyModeS/decoder/bds/bds50.py index a2e534a..e20bd38 100644 --- a/pyModeS/decoder/bds/bds50.py +++ b/pyModeS/decoder/bds/bds50.py @@ -40,7 +40,7 @@ def is50(msg): return False roll = roll50(msg) - if (roll is not None) and abs(roll) > 60: + if (roll is not None) and abs(roll) > 50: return False gs = gs50(msg) diff --git a/pyModeS/decoder/bds/bds60.py b/pyModeS/decoder/bds/bds60.py index b8d91cb..e5749cd 100644 --- a/pyModeS/decoder/bds/bds60.py +++ b/pyModeS/decoder/bds/bds60.py @@ -4,6 +4,7 @@ # ------------------------------------------ from pyModeS import common +from pyModeS.extra import aero def is60(msg): @@ -54,6 +55,13 @@ def is60(msg): if vr_ins is not None and abs(vr_ins) > 6000: return False + # additional check knowing altitude + if (mach is not None) and (ias is not None) and (common.df(msg) == 20): + alt = common.altcode(msg) + ias_ = aero.mach2cas(mach, alt * aero.ft) / aero.kts + if abs(ias - ias_) > 20: + return False + return True diff --git a/tests/sample_run_commb.py b/tests/sample_run_commb.py index 369f4e7..1162875 100644 --- a/tests/sample_run_commb.py +++ b/tests/sample_run_commb.py @@ -46,7 +46,7 @@ def bds_info(BDS, m): ) else: - info = None + info = [] return info @@ -87,5 +87,5 @@ def commb_decode_all(df, n=None): if __name__ == "__main__": - commb_decode_all(df=20, n=100) - commb_decode_all(df=21, n=100) + commb_decode_all(df=20, n=500) + commb_decode_all(df=21, n=500) diff --git a/tests/test_bds_inference.py b/tests/test_bds_inference.py index 5ef67f0..c5c849f 100644 --- a/tests/test_bds_inference.py +++ b/tests/test_bds_inference.py @@ -17,8 +17,8 @@ def test_bds_infer(): def test_bds_is50or60(): assert bds.is50or60("A0001838201584F23468207CDFA5", 0, 0, 0) == None - assert bds.is50or60("A0000000FFDA9517000464000000", 182, 237, 1250) == "BDS50" - assert bds.is50or60("A0000000919A5927E23444000000", 413, 54, 18700) == "BDS60" + assert bds.is50or60("A8001EBCFFFB23286004A73F6A5B", 320, 250, 14000) == "BDS50" + assert bds.is50or60("A8001EBCFE1B29287FDCA807BCFC", 320, 250, 14000) == "BDS50" def test_surface_position():