From 74ea61fb113eed62d98c2961b40a57b9349f4bdd Mon Sep 17 00:00:00 2001 From: gituser283 <131473905+gituser283@users.noreply.github.com> Date: Sun, 25 Aug 2024 06:27:12 -0400 Subject: [PATCH] fix decoder and uncertainty issues (#146) * Created branch mods20230421a * nic_v2 NIC return is set to None when a KeyError exception is raised * process_raw receives additional return values from nuc_p, nic_v2, nuc_v, nac_v, nac_p . hum44, p44, temp44, turb44, wind44, tk50, gs50, roc60baro, roc60ins, tc, and icao added to acs dictionary. --------- Co-authored-by: Mike M <> --- pyModeS/decoder/adsb.py | 1 + pyModeS/streamer/decode.py | 33 +++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/pyModeS/decoder/adsb.py b/pyModeS/decoder/adsb.py index 71bab5b3..031a2ed1 100644 --- a/pyModeS/decoder/adsb.py +++ b/pyModeS/decoder/adsb.py @@ -459,6 +459,7 @@ def nic_v2(msg: str, NICa: int, NICbc: int) -> tuple[int, int]: Rc = uncertainty.NICv2[NIC][NICs]["Rc"] except KeyError: + NIC = None Rc = uncertainty.NA return NIC, Rc # type: ignore diff --git a/pyModeS/streamer/decode.py b/pyModeS/streamer/decode.py index e5ae584f..b1c0c85a 100644 --- a/pyModeS/streamer/decode.py +++ b/pyModeS/streamer/decode.py @@ -73,8 +73,15 @@ def process_raw(self, adsb_ts, adsb_msg, commb_ts, commb_msg, tnow=None): "VFOMr": None, "PE_RCu": None, "PE_VPL": None, + "hum44" : None, + "p44" : None, + "temp44" : None, + "turb44" : None, + "wind44" : None, } + self.acs[icao]["tc"] = tc + self.acs[icao]["icao"] = icao self.acs[icao]["t"] = t self.acs[icao]["live"] = int(t) @@ -155,7 +162,7 @@ def process_raw(self, adsb_ts, adsb_msg, commb_ts, commb_msg, tnow=None): ac["nic_bc"] = pms.adsb.nic_b(msg) if (5 <= tc <= 8) or (9 <= tc <= 18) or (20 <= tc <= 22): - ac["HPL"], ac["RCu"], ac["RCv"] = pms.adsb.nuc_p(msg) + ac["NUCp"], ac["HPL"], ac["RCu"], ac["RCv"] = pms.adsb.nuc_p(msg) if (ac["ver"] == 1) and ("nic_s" in ac.keys()): ac["Rc"], ac["VPL"] = pms.adsb.nic_v1(msg, ac["nic_s"]) @@ -164,20 +171,20 @@ def process_raw(self, adsb_ts, adsb_msg, commb_ts, commb_msg, tnow=None): and ("nic_a" in ac.keys()) and ("nic_bc" in ac.keys()) ): - ac["Rc"] = pms.adsb.nic_v2(msg, ac["nic_a"], ac["nic_bc"]) + ac["NIC"], ac["Rc"] = pms.adsb.nic_v2(msg, ac["nic_a"], ac["nic_bc"]) if tc == 19: - ac["HVE"], ac["VVE"] = pms.adsb.nuc_v(msg) + ac["NUCv"], ac["HVE"], ac["VVE"] = pms.adsb.nuc_v(msg) if ac["ver"] in [1, 2]: - ac["HFOMr"], ac["VFOMr"] = pms.adsb.nac_v(msg) + ac["NACv"], ac["HFOMr"], ac["VFOMr"] = pms.adsb.nac_v(msg) if tc == 29: ac["PE_RCu"], ac["PE_VPL"], ac["base"] = pms.adsb.sil(msg, ac["ver"]) - ac["EPU"], ac["VEPU"] = pms.adsb.nac_p(msg) + ac["NACp"], ac["HEPU"], ac["VEPU"] = pms.adsb.nac_p(msg) if tc == 31: ac["ver"] = pms.adsb.version(msg) - ac["EPU"], ac["VEPU"] = pms.adsb.nac_p(msg) + ac["NACp"], ac["HEPU"], ac["VEPU"] = pms.adsb.nac_p(msg) ac["PE_RCu"], ac["PE_VPL"], ac["sil_base"] = pms.adsb.sil( msg, ac["ver"] ) @@ -194,6 +201,8 @@ def process_raw(self, adsb_ts, adsb_msg, commb_ts, commb_msg, tnow=None): if icao not in self.acs: continue + self.acs[icao]["icao"] = icao + self.acs[icao]["t"] = t self.acs[icao]["live"] = int(t) bds = pms.bds.infer(msg) @@ -217,8 +226,10 @@ def process_raw(self, adsb_ts, adsb_msg, commb_ts, commb_msg, tnow=None): output_buffer.append([t, icao, "rtrk50", rtrk50]) if trk50: + self.acs[icao]["trk50"] = trk50 output_buffer.append([t, icao, "trk50", trk50]) if gs50: + self.acs[icao]["gs50"] = gs50 output_buffer.append([t, icao, "gs50", gs50]) elif bds == "BDS60": @@ -241,10 +252,20 @@ def process_raw(self, adsb_ts, adsb_msg, commb_ts, commb_msg, tnow=None): output_buffer.append([t, icao, "mach60", mach60]) if roc60baro: + self.acs[icao]["roc60baro"] = roc60baro output_buffer.append([t, icao, "roc60baro", roc60baro]) if roc60ins: + self.acs[icao]["roc60ins"] = roc60ins output_buffer.append([t, icao, "roc60ins", roc60ins]) + elif bds == "BDS44": + if(pms.commb.is44(msg)): + self.acs[icao]["hum44"] = pms.commb.hum44(msg) + self.acs[icao]["p44"] = pms.commb.p44(msg) + self.acs[icao]["temp44"] = pms.commb.temp44(msg) + self.acs[icao]["turb44"] = pms.commb.turb44(msg) + self.acs[icao]["wind44"] = pms.commb.wind44(msg) + # clear up old data for icao in list(self.acs.keys()): if self.t - self.acs[icao]["live"] > self.cache_timeout: