From 0df6a664a35e54413f9bc27576773ab4dcefd8cb Mon Sep 17 00:00:00 2001 From: Junzi Sun Date: Wed, 27 Jun 2018 22:08:13 +0200 Subject: [PATCH] resturctue the uncertainty module, and some additional fixings. --- pyModeS/__init__.py | 5 +- pyModeS/decoder/adsb.py | 246 +++++++++--------- pyModeS/decoder/adsb_ua_parameters/NACp.csv | 13 - pyModeS/decoder/adsb_ua_parameters/NACv.csv | 6 - pyModeS/decoder/adsb_ua_parameters/NIC_v1.csv | 22 -- pyModeS/decoder/adsb_ua_parameters/NIC_v2.csv | 26 -- pyModeS/decoder/adsb_ua_parameters/NUCp.csv | 18 -- pyModeS/decoder/adsb_ua_parameters/NUCv.csv | 6 - pyModeS/decoder/adsb_ua_parameters/SIL.csv | 5 - pyModeS/decoder/uncertainty.py | 120 +++++++++ pyModeS/streamer/pmslive | 1 + pyModeS/streamer/screen.py | 17 +- pyModeS/streamer/stream.py | 42 +-- tests/test_adsb.py | 26 +- 14 files changed, 298 insertions(+), 255 deletions(-) delete mode 100644 pyModeS/decoder/adsb_ua_parameters/NACp.csv delete mode 100644 pyModeS/decoder/adsb_ua_parameters/NACv.csv delete mode 100644 pyModeS/decoder/adsb_ua_parameters/NIC_v1.csv delete mode 100644 pyModeS/decoder/adsb_ua_parameters/NIC_v2.csv delete mode 100644 pyModeS/decoder/adsb_ua_parameters/NUCp.csv delete mode 100644 pyModeS/decoder/adsb_ua_parameters/NUCv.csv delete mode 100644 pyModeS/decoder/adsb_ua_parameters/SIL.csv create mode 100644 pyModeS/decoder/uncertainty.py diff --git a/pyModeS/__init__.py b/pyModeS/__init__.py index 31b6ee8..3cf9c09 100644 --- a/pyModeS/__init__.py +++ b/pyModeS/__init__.py @@ -6,7 +6,10 @@ from .decoder import commb from .decoder import common from .decoder import bds from .extra import aero -from .extra import beastclient +from .extra import tcpclient from .decoder import els # depricated from .decoder import ehs # depricated + +import os +dirpath = os.path.dirname(os.path.realpath(__file__)) diff --git a/pyModeS/decoder/adsb.py b/pyModeS/decoder/adsb.py index ec0d9d2..ce1b1bb 100644 --- a/pyModeS/decoder/adsb.py +++ b/pyModeS/decoder/adsb.py @@ -18,10 +18,12 @@ The wrapper for decoding ADS-B messages """ from __future__ import absolute_import, print_function, division -from pyModeS.decoder import common -import pandas as pd # JoseAndresMR: I suppose you already have pandas in a common function, just change all occurrencies -# from pyModeS.decoder.bds import bds05, bds06, bds09 +import pyModeS as pms +from pyModeS.decoder import common +from pyModeS.decoder import uncertainty + +# from pyModeS.decoder.bds import bds05, bds06, bds09 from pyModeS.decoder.bds.bds05 import airborne_position, airborne_position_with_ref, altitude from pyModeS.decoder.bds.bds06 import surface_position, surface_position_with_ref, surface_velocity from pyModeS.decoder.bds.bds08 import category, callsign @@ -198,65 +200,127 @@ def version(msg): return version -def nic_v1(msg,nic_sup_b): +def nuc_p(msg): + """Calculate NUCp, Navigation Uncertainty Category - Position (ADS-B version 1) + + Args: + msg (string): 28 bytes hexadecimal message string, + + Returns: + int: Horizontal Protection Limit + int: 95% Containment Radius - Horizontal (meters) + int: 95% Containment Radius - Vertical (meters) + + """ + tc = typecode(msg) + + if typecode(msg) < 5 or typecode(msg) > 22: + raise RuntimeError( + "%s: Not a surface position message (5 22: - raise RuntimeError("%s: Not a surface position message (5 22: - raise RuntimeError("%s: Not a surface position message (5 22: - raise RuntimeError("%s: Not a surface position message (5