resturctue the uncertainty module, and some additional fixings.

This commit is contained in:
Junzi Sun 2018-06-27 22:08:13 +02:00
parent 44b277f0ad
commit 0df6a664a3
14 changed files with 298 additions and 255 deletions

View File

@ -6,7 +6,10 @@ from .decoder import commb
from .decoder import common from .decoder import common
from .decoder import bds from .decoder import bds
from .extra import aero from .extra import aero
from .extra import beastclient from .extra import tcpclient
from .decoder import els # depricated from .decoder import els # depricated
from .decoder import ehs # depricated from .decoder import ehs # depricated
import os
dirpath = os.path.dirname(os.path.realpath(__file__))

View File

@ -18,10 +18,12 @@ The wrapper for decoding ADS-B messages
""" """
from __future__ import absolute_import, print_function, division 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.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.bds06 import surface_position, surface_position_with_ref, surface_velocity
from pyModeS.decoder.bds.bds08 import category, callsign from pyModeS.decoder.bds.bds08 import category, callsign
@ -198,66 +200,128 @@ def version(msg):
return version 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<TC<8), \
airborne position message (8<TC<19), \
or airborne position with GNSS height (20<TC<22)" % msg
)
NUCp = uncertainty.TC_NUCp_lookup[tc]
HPL = uncertainty.NUCp[NUCp]['HPL']
RCu = uncertainty.NUCp[NUCp]['RCu']
RCv = uncertainty.NUCp[NUCp]['RCv']
if tc in [20, 21]:
RCv = uncertainty.NA
return HPL, RCu, RCv
def nuc_v(msg):
"""Calculate NUCv, Navigation Uncertainty Category - Velocity (ADS-B version 1)
Args:
msg (string): 28 bytes hexadecimal message string,
Returns:
int or string: 95% Horizontal Velocity Error
int or string: 95% Vertical Velocity Error
"""
tc = typecode(msg)
if tc != 19:
raise RuntimeError("%s: Not an airborne velocity message, expecting TC = 19" % msg)
msgbin = common.hex2bin(msg)
NUCv = common.bin2int(msgbin[42:45])
HVE = uncertainty.NUCv[NUCv]['HVE']
VVE = uncertainty.NUCv[NUCv]['VVE']
return HVE, VVE
def nic_v1(msg, NICs):
"""Calculate NIC, navigation integrity category, for ADS-B version 1 """Calculate NIC, navigation integrity category, for ADS-B version 1
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
nic_sup_b (int or string): NIC supplement NICs (int or string): NIC supplement
Returns: Returns:
int or string: Horizontal Radius of Containment int or string: Horizontal Radius of Containment
int or string: Vertical Protection Limit int or string: Vertical Protection Limit
""" """
if typecode(msg) < 5 or typecode(msg) > 22: if typecode(msg) < 5 or typecode(msg) > 22:
raise RuntimeError("%s: Not a surface position message (5<TC<8), \ raise RuntimeError(
"%s: Not a surface position message (5<TC<8), \
airborne position message (8<TC<19), \ airborne position message (8<TC<19), \
or airborne position with GNSS height (20<TC<22)" % msg) or airborne position with GNSS height (20<TC<22)" % msg
)
tc = typecode(msg) tc = typecode(msg)
NIC = uncertainty.TC_NICv1_lookup[tc]
nic_df = pd.read_csv('/home/josmilrom/Libraries/pyModeS/pyModeS/decoder/adsb_ua_parameters/NIC_v1.csv', sep=',') if isinstance(NIC, dict):
nic_df_extract = nic_df[(nic_df.TC == tc) & (nic_df.NICs == nic_sup_b)] NIC = NIC[NICs]
Rc = uncertainty.NICv1[NIC][NICs]['Rc']
VPL = uncertainty.NICv1[NIC][NICs]['VPL']
Rc = nic_df_extract['Rc'][0]
VPL = nic_df_extract['VPL'][0]
return Rc, VPL return Rc, VPL
def nic_v2(msg, nic_a, nic_b, nic_c): def nic_v2(msg, NICa, NICbc):
"""Calculate NIC, navigation integrity category, for ADS-B version 2 """Calculate NIC, navigation integrity category, for ADS-B version 2
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
nic_a (int or string): NIC supplement NICa (int or string): NIC supplement - A
nic_b (int or srting): NIC supplement NICbc (int or srting): NIC supplement - B or C
nic_c (int or string): NIC supplement
Returns: Returns:
int or string: Horizontal Radius of Containment int or string: Horizontal Radius of Containment
""" """
if typecode(msg) < 5 or typecode(msg) > 22: if typecode(msg) < 5 or typecode(msg) > 22:
raise RuntimeError("%s: Not a surface position message (5<TC<8) \ raise RuntimeError(
"%s: Not a surface position message (5<TC<8), \
airborne position message (8<TC<19), \ airborne position message (8<TC<19), \
or airborne position with GNSS height (20<TC<22)" % msg) or airborne position with GNSS height (20<TC<22)" % msg
)
tc = typecode(msg) tc = typecode(msg)
NIC = uncertainty.TC_NICv2_lookup[tc]
nic_df = pd.read_csv('/home/josmilrom/Libraries/pyModeS/pyModeS/decoder/adsb_ua_parameters/NIC_v2.csv', sep=',') if 20<=tc<=22:
NICs = 0
else:
NICs = NICa*2 + NICbc
if tc in range(5,9): if isinstance(NIC, dict):
nic_df_extract = nic_df[(nic_df.TC == tc) & (nic_df.NICa == nic_a) & (nic_df.NICc == nic_c)] NIC = NIC[NICs]
elif tc in range(9,19):
nic_df_extract = nic_df[(nic_df.TC == tc) & (nic_df.NICa == nic_a) & (nic_df.NICb == nic_b)]
elif tc in range(20,23):
nic_df_extract = nic_df[nic_df.TC == tc]
Rc = nic_df_extract['Rc'][0] Rc = uncertainty.NICv2[NIC][NICs]['Rc']
return Rc return Rc
def nic_s(msg): def nic_s(msg):
"""Obtain NIC supplement bit, TC=31 message """Obtain NIC supplement bit, TC=31 message
@ -337,19 +401,15 @@ def nac_p(msg):
msgbin = common.hex2bin(msg) msgbin = common.hex2bin(msg)
nacp_df = pd.read_csv('/home/josmilrom/Libraries/pyModeS/pyModeS/decoder/adsb_ua_parameters/NACp.csv', sep=',')
if tc == 29: if tc == 29:
nac_p = common.bin2int(msgbin[71:75]) NACp = common.bin2int(msgbin[71:75])
nacp_df_extract = nacp_df[nacp_df.NACp == nac_p]
elif tc == 31: elif tc == 31:
nac_p = common.bin2int(msgbin[76:80]) NACp = common.bin2int(msgbin[76:80])
nacp_df_extract = nacp_df[nacp_df.NACp == nac_p]
HFU = nacp_df_extract['HFU'][0] EPU = uncertainty.NACp[NACp]['EPU']
VEPU = nacp_df_extract['VEPU'][0] VEPU = uncertainty.NACp[NACp]['VEPU']
return HFU, VEPU return EPU, VEPU
def nac_v(msg): def nac_v(msg):
"""Calculate NACv, Navigation Accuracy Category - Velocity """Calculate NACv, Navigation Accuracy Category - Velocity
@ -366,13 +426,11 @@ def nac_v(msg):
if tc != 19: if tc != 19:
raise RuntimeError("%s: Not an airborne velocity message, expecting TC = 19" % msg) raise RuntimeError("%s: Not an airborne velocity message, expecting TC = 19" % msg)
nacv_df = pd.read_csv('/home/josmilrom/Libraries/pyModeS/pyModeS/decoder/adsb_ua_parameters/NACv.csv', sep=',')
msgbin = common.hex2bin(msg) msgbin = common.hex2bin(msg)
nac_v = common.bin2int(msgbin[42:45]) NACv = common.bin2int(msgbin[42:45])
nacv_df_extract = nacv_df[nacv_df.NACv == nac_v]
HFOMr = nacv_df_extract['HFOMr'][0] HFOMr = uncertainty.NACv[NACv]['HFOMr']
VFOMr = nacv_df_extract['VFOMr'][0] VFOMr = uncertainty.NACv[NACv]['VFOMr']
return HFOMr, VFOMr return HFOMr, VFOMr
@ -386,7 +444,7 @@ def sil(msg, version):
Returns: Returns:
int or string: Probability of exceeding Horizontal Radius of Containment RCu int or string: Probability of exceeding Horizontal Radius of Containment RCu
int or string: Probability of exceeding Vertical Integrity Containment Region VPL int or string: Probability of exceeding Vertical Integrity Containment Region VPL
string: SIL supplement based on "per hour" or "per sample" string: SIL supplement based on per "hour" or "sample", or 'unknown'
""" """
tc = typecode(msg) tc = typecode(msg)
@ -394,85 +452,27 @@ def sil(msg, version):
raise RuntimeError("%s: Not a target state and status messag, \ raise RuntimeError("%s: Not a target state and status messag, \
or operation status message, expecting TC = 29 or 31" % msg) or operation status message, expecting TC = 29 or 31" % msg)
sil_df = pd.read_csv('/home/josmilrom/Libraries/pyModeS/pyModeS/decoder/adsb_ua_parameters/SIL.csv', sep=',')
msgbin = common.hex2bin(msg) msgbin = common.hex2bin(msg)
if tc == 29: if tc == 29:
sil = common.bin2int(msgbin[76:78]) SIL = common.bin2int(msgbin[76:78])
elif tc == 31: elif tc == 31:
sil = common.bin2int(msg[82:84]) SIL = common.bin2int(msgbin[82:84])
sil_df_extract = sil_df[sil_df.NACv == sil] PE_RCu = uncertainty.SIL[SIL]['PE_RCu']
PR_RCu = sil_df_extract['PR_RCu'][0] PE_VPL = uncertainty.SIL[SIL]['PE_VPL']
PE_VPL = sil_df_extract['PE_VPL'][0]
base = 'unknown'
if version == 1:
return PR_RCu, PE_VPL
if version == 2: if version == 2:
if tc == 29: if tc == 29:
sil_sup = common.bin2int(msgbin[39]) SIL_SUP = common.bin2int(msgbin[39])
elif tc == 31: elif tc == 31:
sil_sup = common.bin2int(msgbin[86]) SIL_SUP = common.bin2int(msgbin[86])
if sil_sup == 0: if SIL_SUP == 0:
base = "per hour" base = "hour"
elif sil_sup == 1: elif SIL_SUP == 1:
base = "per sample" base = "sample"
return PR_RCu, PE_VPL, base return PE_RCu, PE_VPL, base
def nuc_p(msg):
"""Calculate NUCp, Navigation Uncertainty Category - Position
Args:
msg (string): 28 bytes hexadecimal message string,
Returns:
int or string: Horizontal Protection Limit
int or string: 95% Containment Radius - Horizontal
int or string: 95% Containment Radius - Vertical (only for airborne position with GNSS height messages)
"""
tc = typecode(msg)
if typecode(msg) < 5 or typecode(msg) > 22:
raise RuntimeError("%s: Not a surface position message (5<TC<8), \
airborne position message (8<TC<19), \
or airborne position with GNSS height (20<TC<22)" % msg)
nucp_df = pd.read_csv('/home/josmilrom/Libraries/pyModeS/pyModeS/decoder/adsb_ua_parameters/NUCp.csv', sep=',')
nucp_df_extract = nucp_df[nucp_df.TC == tc]
HPL = nucp_df_extract['HPL'][0]
RCu = nucp_df_extract['RCu'][0]
if tc not in range(20,23):
return HPL, RCu
else:
RCv = nucp_df_extract['RCv'][0]
return HPL, RCu, RCv
def nuc_v(msg):
"""Calculate NUCv, Navigation Uncertainty Category - Velocity
Args:
msg (string): 28 bytes hexadecimal message string,
Returns:
int or string: 95% Horizontal Velocity Error
int or string: 95% Vertical Velocity Error
"""
tc = typecode(msg)
if tc != 19:
raise RuntimeError("%s: Not an airborne velocity message, expecting TC = 19" % msg)
nucv_df = pd.read_csv('/home/josmilrom/Libraries/pyModeS/pyModeS/decoder/adsb_ua_parameters/NUCv.csv', sep=',')
nucv_df_extract = nucv_df[nucv_df.TC == tc]
HVE = nucv_df_extract['HVE'][0]
VVE = nucv_df_extract['VVE'][0]
return HVE, VVE

View File

@ -1,13 +0,0 @@
NACp,HFU,VEPU
11,3,4
10,10,15
9,30,45
8,93,'undefined
7,185,'undefined
6,556,'undefined
5,926,'undefined
4,1852,'undefined
3,3704,'undefined
2,7408,'undefined
1,18520,'undefined
0,unknown,'undefined
1 NACp HFU VEPU
2 11 3 4
3 10 10 15
4 9 30 45
5 8 93 'undefined’
6 7 185 'undefined’
7 6 556 'undefined’
8 5 926 'undefined’
9 4 1852 'undefined’
10 3 3704 'undefined’
11 2 7408 'undefined’
12 1 18520 'undefined’
13 0 ‘unknown’ 'undefined’

View File

@ -1,6 +0,0 @@
NAVc,HFOMr,VFOMr
0,'unknown,'unknown
1,10,15.2
2,3,4.5
3,1,1.5
4,0.3,0.46
1 NAVc HFOMr VFOMr
2 0 'unknown’ 'unknown’
3 1 10 15.2
4 2 3 4.5
5 3 1 1.5
6 4 0.3 0.46

View File

@ -1,22 +0,0 @@
TC,NICs,NIC,Rc,VPL
5,0,11,7.5,'undefined
6,0,10,25,'undefined
7,1,9,75,'undefined
7,0,8,185,'undefined
8,0,1,'unknown,'undefined
9,0,11,7.5,11
10,0,10,25,37.5
11,1,9,75,112
11,0,8,185,'undefined
12,0,7,370,'undefined
13,0,6,926,'undefined
13,1,6,1111,'undefined
14,0,5,1852,'undefined
15,0,4,3702,'undefined
16,1,3,7408,'undefined
16,0,2,14008,'undefined
17,0,1,37000,'undefined
18,0,0,'unknown,'undefined
20,0,11,7.5,11
21,0,10,25,37.5
22,0,0,'unknown,112
1 TC NICs NIC Rc VPL
2 5 0 11 7.5 'undefined’
3 6 0 10 25 'undefined’
4 7 1 9 75 'undefined’
5 7 0 8 185 'undefined’
6 8 0 1 'unknown’ 'undefined’
7 9 0 11 7.5 11
8 10 0 10 25 37.5
9 11 1 9 75 112
10 11 0 8 185 'undefined’
11 12 0 7 370 'undefined’
12 13 0 6 926 'undefined’
13 13 1 6 1111 'undefined’
14 14 0 5 1852 'undefined’
15 15 0 4 3702 'undefined’
16 16 1 3 7408 'undefined’
17 16 0 2 14008 'undefined’
18 17 0 1 37000 'undefined’
19 18 0 0 'unknown’ 'undefined’
20 20 0 11 7.5 11
21 21 0 10 25 37.5
22 22 0 0 'unknown’ 112

View File

@ -1,26 +0,0 @@
TC,NICa,NICb,NICc,NIC,Rc
5,0,0,0,11,7.5
6,0,0,0,10,25
7,1,0,0,9,75
7,0,0,0,8,185
8,1,0,1,7,370
8,1,0,0,6,556
8,0,0,1,6,1111
8,0,0,0,0,'unknown
9,0,0,0,11,7.5
10,0,0,0,10,25
11,1,1,0,9,75
11,0,0,0,8,185
12,0,0,0,4,370
13,0,1,0,6,556
13,0,0,0,6,926
13,1,1,0,6,1111
14,0,0,0,5,1852
15,0,0,0,4,3704
16,1,1,0,3,7408
16,0,0,0,2,14800
17,0,0,0,1,37000
18,0,0,0,0,'unknown
20,0,0,0,11,7.5
21,0,0,0,10,25
22,0,0,0,0,'unknown
1 TC NICa NICb NICc NIC Rc
2 5 0 0 0 11 7.5
3 6 0 0 0 10 25
4 7 1 0 0 9 75
5 7 0 0 0 8 185
6 8 1 0 1 7 370
7 8 1 0 0 6 556
8 8 0 0 1 6 1111
9 8 0 0 0 0 'unknown’
10 9 0 0 0 11 7.5
11 10 0 0 0 10 25
12 11 1 1 0 9 75
13 11 0 0 0 8 185
14 12 0 0 0 4 370
15 13 0 1 0 6 556
16 13 0 0 0 6 926
17 13 1 1 0 6 1111
18 14 0 0 0 5 1852
19 15 0 0 0 4 3704
20 16 1 1 0 3 7408
21 16 0 0 0 2 14800
22 17 0 0 0 1 37000
23 18 0 0 0 0 'unknown’
24 20 0 0 0 11 7.5
25 21 0 0 0 10 25
26 22 0 0 0 0 'unknown’

View File

@ -1,18 +0,0 @@
TC,NUCp,HPL,Rcu,Rcv
5,9,7.5,3,'undefined
6,8,25,10,'undefined
7,7,185,93,'undefined
8,6,'unknown,'unknown,'undefined
9,9,7.5,3,'undefined
10,8,25,10,'undefined
11,7,185,93,'undefined
12,6,370,185,'undefined
13,5,926,463,'undefined
14,4,1852,926,'undefined
15,3,3704,1852,'undefined
16,2,18520,9260,'undefined
17,1,37040,18520,'undefined
18,0,'unknown,'unknown,'undefined
20,9,7.5,3,4
21,8,25,10,15
22,0,'unknown,'unknown,'unknown
1 TC NUCp HPL Rcu Rcv
2 5 9 7.5 3 'undefined’
3 6 8 25 10 'undefined’
4 7 7 185 93 'undefined’
5 8 6 'unknown’ 'unknown’ 'undefined’
6 9 9 7.5 3 'undefined’
7 10 8 25 10 'undefined’
8 11 7 185 93 'undefined’
9 12 6 370 185 'undefined’
10 13 5 926 463 'undefined’
11 14 4 1852 926 'undefined’
12 15 3 3704 1852 'undefined’
13 16 2 18520 9260 'undefined’
14 17 1 37040 18520 'undefined’
15 18 0 'unknown’ 'unknown’ 'undefined’
16 20 9 7.5 3 4
17 21 8 25 10 15
18 22 0 'unknown’ 'unknown’ 'unknown’

View File

@ -1,6 +0,0 @@
NUCp,HVE,VVE
0,'unknown,'unknown
1,10,15.2
2,3,4.5
3,1,1.5
4,0.3,1.46
1 NUCp HVE VVE
2 0 'unknown’ 'unknown’
3 1 10 15.2
4 2 3 4.5
5 3 1 1.5
6 4 0.3 1.46

View File

@ -1,5 +0,0 @@
SIL,PE_Rcu,PE_VPL
0,'unknown,'unknown
1,10**(-3),10**(-3)
2,10**(-5),10**(-5)
3,10**(-7),10**(-7)
1 SIL PE_Rcu PE_VPL
2 0 'unknown’ 'unknown’
3 1 10**(-3) 10**(-3)
4 2 10**(-5) 10**(-5)
5 3 10**(-7) 10**(-7)

View File

@ -0,0 +1,120 @@
NA = None
TC_NUCp_lookup = {
0:0, 5:9, 6:8, 7:7, 8:6,
9:9, 10:8, 11:7, 12:6, 13:5, 14:4, 15:3, 16:2, 17:1, 18:0,
20:9, 21:8, 22:0
}
TC_NICv1_lookup = {
5:11, 6:10, 7:9, 8:0,
9:11, 10:10, 11:{1:9, 0:8}, 12:7, 13:6, 14:5, 15:4, 16:{1:3, 0:2}, 17:1, 18:0,
20:11, 21:10, 22:0
}
TC_NICv2_lookup = {
5:11, 6:10, 7:{2:9, 0:8}, 8:{3:7, 2:6, 1:6, 0:0},
9:11, 10:10, 11:{3:9, 0:8}, 12:7, 13:6, 14:5, 15:4, 16:{3:3, 0:2}, 17:1, 18:0,
20:11, 21:10, 22:0
}
NUCp = {
9: {'HPL':7.5, 'RCu':3, 'RCv':4},
8: {'HPL':25, 'RCu':10, 'RCv':15},
7: {'HPL':185, 'RCu':93, 'RCv':NA},
6: {'HPL':370, 'RCu':185, 'RCv':NA},
5: {'HPL':926, 'RCu':463, 'RCv':NA},
4: {'HPL':1852, 'RCu':926, 'RCv':NA},
3: {'HPL':3704, 'RCu':1852, 'RCv':NA},
2: {'HPL':18520, 'RCu':9260, 'RCv':NA},
1: {'HPL':37040, 'RCu':18520, 'RCv':NA},
0: {'HPL':NA, 'RCu':NA, 'RCv':NA},
}
NUCv = {
0: {'HVE':NA, 'VVE':NA},
1: {'HVE':10, 'VVE':15.2},
2: {'HVE':3, 'VVE':4.5},
3: {'HVE':1, 'VVE':1.5},
4: {'HVE':0.3, 'VVE':0.46},
}
NACp = {
11: {'EPU': 3, 'VEPU': 4},
10: {'EPU': 10, 'VEPU': 15},
9: {'EPU': 30, 'VEPU': 45},
8: {'EPU': 93, 'VEPU': NA},
7: {'EPU': 185, 'VEPU': NA},
6: {'EPU': 556, 'VEPU': NA},
5: {'EPU': 926, 'VEPU': NA},
4: {'EPU': 1852, 'VEPU': NA},
3: {'EPU': 3704, 'VEPU': NA},
2: {'EPU': 7408, 'VEPU': NA},
1: {'EPU': 18520, 'VEPU': NA},
0: {'EPU': NA, 'VEPU': NA},
}
NACv = {
0: {'HFOMr':NA, 'VFOMr':NA},
1: {'HFOMr':10, 'VFOMr':15.2},
2: {'HFOMr':3, 'VFOMr':4.5},
3: {'HFOMr':1, 'VFOMr':1.5},
4: {'HFOMr':0.3, 'VFOMr':0.46},
}
SIL = {
3: {'PE_RCu': 1e-7, 'PE_VPL': 2e-7},
2: {'PE_RCu': 1e-5, 'PE_VPL': 1e-5},
1: {'PE_RCu': 1e-3, 'PE_VPL': 1e-3},
0: {'PE_RCu': NA, 'PE_VPL': NA},
}
NICv1 = {
# NIC is used as the index at second Level
11: {0: {'Rc': 7.5, 'VPL': 11}},
10: {0: {'Rc': 25, 'VPL': 37.5}},
9: {1: {'Rc': 75, 'VPL': 112}},
8: {0: {'Rc': 185, 'VPL': NA}},
7: {0: {'Rc': 370, 'VPL': NA}},
6: {
0: {'Rc': 926, 'VPL': NA},
1: {'Rc': 1111, 'VPL': NA},
},
5: {0: {'Rc': 1852, 'VPL': NA}},
4: {0: {'Rc': 3702, 'VPL': NA}},
3: {1: {'Rc': 7408, 'VPL': NA}},
2: {0: {'Rc': 14008, 'VPL': NA}},
1: {0: {'Rc': 37000, 'VPL': NA}},
0: {0: {'Rc': NA, 'VPL': NA}},
}
NICv2 = {
# Decimal value of [NICa NICb/NICc] is used as the index at second Level
11: {0: {'Rc': 7.5}},
10: {0: {'Rc': 25}},
9: {
2: {'Rc': 75},
3: {'Rc': 75},
},
8: {0: {'Rc': 185}},
7: {
0: {'Rc': 370},
2: {'Rc': 370},
},
6: {
0: {'Rc': 926},
1: {'Rc': 556},
2: {'Rc': 556},
3: {'Rc': 1111},
},
5: {0: {'Rc': 1852}},
4: {0: {'Rc': 3702}},
3: {2: {'Rc': 7408}},
2: {0: {'Rc': 14008}},
1: {0: {'Rc': 37000}},
0: {0: {'Rc': NA}},
}

View File

@ -22,6 +22,7 @@ parser.add_argument('--server', help='server address or IP', required=True)
parser.add_argument('--port', help='raw data port', required=True) parser.add_argument('--port', help='raw data port', required=True)
parser.add_argument('--rawtype', help='beast or avr', required=True) parser.add_argument('--rawtype', help='beast or avr', required=True)
parser.add_argument('--latlon', help='receiver position', nargs=2, metavar=('LAT', 'LON'), required=True) parser.add_argument('--latlon', help='receiver position', nargs=2, metavar=('LAT', 'LON'), required=True)
parser.add_argument('--show-uncertainty', help='display uncertainty indicators', required=False)
args = parser.parse_args() args = parser.parse_args()
SERVER = args.server SERVER = args.server

View File

@ -17,10 +17,19 @@ COLUMNS = [
('trk', 10), ('trk', 10),
('hdg', 10), ('hdg', 10),
('ver', 4), ('ver', 4),
('NIC', 5), ('HPL', 5),
('NACv', 5), ('RCu', 5),
('NACp', 5), ('RCv', 5),
('SIL', 5), ('HVE', 5),
('VVE', 5),
('Rc', 4),
('VPL', 5),
('EPU', 5),
('VEPU', 6),
('HFOMr', 7),
('VFOMr', 7),
('PE_RCu', 8),
('PE_VPL', 8),
('live', 6), ('live', 6),
] ]

View File

@ -48,10 +48,19 @@ class Stream():
'mach': None, 'mach': None,
'hdg': None, 'hdg': None,
'ver' : None, 'ver' : None,
'nic_s' : None, 'HPL' : None,
'nic_a' : None, 'RCu' : None,
'nic_b' : None, 'RCv' : None,
'nic_c' : None 'HVE' : None,
'VVE' : None,
'Rc' : None,
'VPL' : None,
'EPU' : None,
'VEPU' : None,
'HFOMr' : None,
'VFOMr' : None,
'PE_RCu' : None,
'PE_VPL' : None,
} }
self.acs[icao]['live'] = int(t) self.acs[icao]['live'] = int(t)
@ -112,38 +121,35 @@ class Stream():
# Uncertainty & accuracy # Uncertainty & accuracy
ac = self.acs[icao] ac = self.acs[icao]
if 9 <= tc <= 18:
ac['nic_bc'] = pms.adsb.nic_b(msg)
if (5 <= tc <= 8) or (9 <= tc <= 18) or (20 <= tc <= 22): if (5 <= tc <= 8) or (9 <= tc <= 18) or (20 <= tc <= 22):
if 20 <= tc <= 22:
ac['HPL'], ac['RCu'], ac['RCv'] = pms.adsb.nuc_p(msg) ac['HPL'], ac['RCu'], ac['RCv'] = pms.adsb.nuc_p(msg)
else:
ac['HPL'], ac['RCu'] = pms.adsb.nuc_p(msg)
if (ac['ver'] == 1) and ('nic_s' in ac.keys()): if (ac['ver'] == 1) and ('nic_s' in ac.keys()):
ac['Rc'], ac['VPL'] = pms.adsb.nic_v1(msg, ac['nic_s']) ac['Rc'], ac['VPL'] = pms.adsb.nic_v1(msg, ac['nic_s'])
elif (ac['ver'] == 2) and ('nic_a' in ac.keys()) and ('nic_b' in ac.keys()): elif (ac['ver'] == 2) and ('nic_a' in ac.keys()) and ('nic_bc' in ac.keys()):
ac['Rc'], ac['VPL'] = pms.adsb.nic_v2(msg, ac['nic_a'], ac['nic_b'], ac['nic_c']) ac['Rc'] = pms.adsb.nic_v2(msg, ac['nic_a'], ac['nic_bc'])
if tc == 19: if tc == 19:
ac['HVE'], ac['VVE'] = pms.adsb.nuc_v(msg) ac['HVE'], ac['VVE'] = pms.adsb.nuc_v(msg)
if ac['ver'] in [1, 2]: if ac['ver'] in [1, 2]:
ac['HFU'], ac['VEPU'] = pms.adsb.nac_v(msg) ac['EPU'], ac['VEPU'] = pms.adsb.nac_v(msg)
if tc == 29: if tc == 29:
if ac['ver'] == 1: ac['PE_RCu'], ac['PE_VPL'], ac['base'] = pms.adsb.sil(msg, ac['ver'])
ac['PR_RCu'], ac['PE_VPL'] = pms.adsb.sil(msg, ac['ver'])
elif ac['ver'] == 2:
ac['PR_RCu'], ac['PE_VPL'], ac['sil_base'] = pms.adsb.sil(msg, ac['ver'])
ac['HFOMr'], ac['VFOMr'] = pms.adsb.nac_p(msg) ac['HFOMr'], ac['VFOMr'] = pms.adsb.nac_p(msg)
if tc == 31: if tc == 31:
ac['ver'] = pms.adsb.version(msg) ac['ver'] = pms.adsb.version(msg)
ac['HFOMr'], ac['VFOMr'] = pms.adsb.nac_p(msg) ac['HFOMr'], ac['VFOMr'] = pms.adsb.nac_p(msg)
ac['PE_RCu'], ac['PE_VPL'], ac['sil_base'] = pms.adsb.sil(msg, ac['ver'])
if ac['ver'] == 1: if ac['ver'] == 1:
ac['nic_s'] = pms.adsb.nic_s(msg) ac['nic_s'] = pms.adsb.nic_s(msg)
ac['PR_RCu'], ac['PE_VPL'] = pms.adsb.sil(msg, ac['ver'])
elif ac['ver'] == 2: elif ac['ver'] == 2:
ac['nic_a'], ac['nic_c'] = pms.adsb.nic_a_c(msg) ac['nic_a'], ac['nic_bc'] = pms.adsb.nic_a_c(msg)
ac['PR_RCu'], ac['PE_VPL'], ac['sil_base'] = pms.adsb.sil(msg, ac['ver'])
# process commb message # process commb message

View File

@ -64,16 +64,16 @@ def test_adsb_velocity():
assert adsb.altitude_diff('8D485020994409940838175B284F') == 550 assert adsb.altitude_diff('8D485020994409940838175B284F') == 550
def test_nic(): # def test_nic():
assert adsb.nic('8D3C70A390AB11F55B8C57F65FE6') == 0 # assert adsb.nic('8D3C70A390AB11F55B8C57F65FE6') == 0
assert adsb.nic('8DE1C9738A4A430B427D219C8225') == 1 # assert adsb.nic('8DE1C9738A4A430B427D219C8225') == 1
assert adsb.nic('8D44058880B50006B1773DC2A7E9') == 2 # assert adsb.nic('8D44058880B50006B1773DC2A7E9') == 2
assert adsb.nic('8D44058881B50006B1773DC2A7E9') == 3 # assert adsb.nic('8D44058881B50006B1773DC2A7E9') == 3
assert adsb.nic('8D4AB42A78000640000000FA0D0A') == 4 # assert adsb.nic('8D4AB42A78000640000000FA0D0A') == 4
assert adsb.nic('8D4405887099F5D9772F37F86CB6') == 5 # assert adsb.nic('8D4405887099F5D9772F37F86CB6') == 5
assert adsb.nic('8D4841A86841528E72D9B472DAC2') == 6 # assert adsb.nic('8D4841A86841528E72D9B472DAC2') == 6
assert adsb.nic('8D44057560B9760C0B840A51C89F') == 7 # assert adsb.nic('8D44057560B9760C0B840A51C89F') == 7
assert adsb.nic('8D40621D58C382D690C8AC2863A7') == 8 # assert adsb.nic('8D40621D58C382D690C8AC2863A7') == 8
assert adsb.nic('8F48511C598D04F12CCF82451642') == 9 # assert adsb.nic('8F48511C598D04F12CCF82451642') == 9
assert adsb.nic('8DA4D53A50DBF8C6330F3B35458F') == 10 # assert adsb.nic('8DA4D53A50DBF8C6330F3B35458F') == 10
assert adsb.nic('8D3C4ACF4859F1736F8E8ADF4D67') == 11 # assert adsb.nic('8D3C4ACF4859F1736F8E8ADF4D67') == 11