|
|
|
@ -47,8 +47,9 @@ def typecode(msg):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def position(msg0, msg1, t0, t1, lat_ref=None, lon_ref=None):
|
|
|
|
|
"""Decode position from a pair of even and odd position message
|
|
|
|
|
(works with both airborne and surface position messages)
|
|
|
|
|
"""Decode position from a pair of even and odd position message.
|
|
|
|
|
|
|
|
|
|
Works with both airborne and surface position messages.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg0 (string): even message (28 hexdigits)
|
|
|
|
@ -58,6 +59,7 @@ def position(msg0, msg1, t0, t1, lat_ref=None, lon_ref=None):
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
(float, float): (latitude, longitude) of the aircraft
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
tc0 = typecode(msg0)
|
|
|
|
|
tc1 = typecode(msg1)
|
|
|
|
@ -85,15 +87,16 @@ def position(msg0, msg1, t0, t1, lat_ref=None, lon_ref=None):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def position_with_ref(msg, lat_ref, lon_ref):
|
|
|
|
|
"""Decode position with only one message,
|
|
|
|
|
knowing reference nearby location, such as previously
|
|
|
|
|
calculated location, ground station, or airport location, etc.
|
|
|
|
|
Works with both airborne and surface position messages.
|
|
|
|
|
"""Decode position with only one message.
|
|
|
|
|
|
|
|
|
|
A reference position is required, which can be previously
|
|
|
|
|
calculated location, ground station, or airport location.
|
|
|
|
|
The function works with both airborne and surface position messages.
|
|
|
|
|
The reference position shall be with in 180NM (airborne) or 45NM (surface)
|
|
|
|
|
of the true position.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): even message (28 hexdigits)
|
|
|
|
|
msg (str): even message (28 hexdigits)
|
|
|
|
|
lat_ref: previous known latitude
|
|
|
|
|
lon_ref: previous known longitude
|
|
|
|
|
|
|
|
|
@ -114,15 +117,15 @@ def position_with_ref(msg, lat_ref, lon_ref):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def altitude(msg):
|
|
|
|
|
"""Decode aircraft altitude
|
|
|
|
|
"""Decode aircraft altitude.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): 28 bytes hexadecimal message string
|
|
|
|
|
msg (str): 28 hexdigits string
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
int: altitude in feet
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
tc = typecode(msg)
|
|
|
|
|
|
|
|
|
|
if tc < 5 or tc == 19 or tc > 22:
|
|
|
|
@ -137,36 +140,31 @@ def altitude(msg):
|
|
|
|
|
return altitude05(msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def velocity(msg, rtn_sources=False):
|
|
|
|
|
"""Calculate the speed, heading, and vertical rate
|
|
|
|
|
(handles both airborne or surface message)
|
|
|
|
|
def velocity(msg, source=False):
|
|
|
|
|
"""Calculate the speed, heading, and vertical rate (handles both airborne or surface message).
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): 28 bytes hexadecimal message string
|
|
|
|
|
rtn_source (boolean): If the function will return
|
|
|
|
|
the sources for direction of travel and vertical
|
|
|
|
|
rate. This will change the return value from a four
|
|
|
|
|
element array to a six element array.
|
|
|
|
|
msg (str): 28 hexdigits string
|
|
|
|
|
source (boolean): Include direction and vertical rate sources in return. Default to False.
|
|
|
|
|
If set to True, the function will return six value instead of four.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
(int, float, int, string, string, string): speed (kt),
|
|
|
|
|
ground track or heading (degree),
|
|
|
|
|
rate of climb/descent (ft/min), speed type
|
|
|
|
|
('GS' for ground speed, 'AS' for airspeed),
|
|
|
|
|
direction source ('true_north' for ground track / true north
|
|
|
|
|
as reference, 'mag_north' for magnetic north as reference),
|
|
|
|
|
rate of climb/descent source ('Baro' for barometer, 'GNSS'
|
|
|
|
|
for GNSS constellation).
|
|
|
|
|
|
|
|
|
|
In the case of surface messages, None will be put in place
|
|
|
|
|
for vertical rate and its respective sources.
|
|
|
|
|
"""
|
|
|
|
|
int, float, int, string, [string], [string]: Four or six parameters, including:
|
|
|
|
|
- Speed (kt)
|
|
|
|
|
- Angle (degree), either ground track or heading
|
|
|
|
|
- Vertical rate (ft/min)
|
|
|
|
|
- Speed type ('GS' for ground speed, 'AS' for airspeed)
|
|
|
|
|
- [Optional] Direction source ('TRUE_NORTH' or 'MAGENTIC_NORTH')
|
|
|
|
|
- [Optional] Vertical rate source ('BARO' or 'GNSS')
|
|
|
|
|
|
|
|
|
|
For surface messages, vertical rate and its respective sources are set to None.
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
if 5 <= typecode(msg) <= 8:
|
|
|
|
|
return surface_velocity(msg, rtn_sources)
|
|
|
|
|
return surface_velocity(msg, source)
|
|
|
|
|
|
|
|
|
|
elif typecode(msg) == 19:
|
|
|
|
|
return airborne_velocity(msg, rtn_sources)
|
|
|
|
|
return airborne_velocity(msg, source)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
raise RuntimeError(
|
|
|
|
@ -179,7 +177,7 @@ def speed_heading(msg):
|
|
|
|
|
(handles both airborne or surface message)
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): 28 bytes hexadecimal message string
|
|
|
|
|
msg (str): 28 hexdigits string
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
(int, float): speed (kt), ground track or heading (degree)
|
|
|
|
@ -191,7 +189,7 @@ def speed_heading(msg):
|
|
|
|
|
def oe_flag(msg):
|
|
|
|
|
"""Check the odd/even flag. Bit 54, 0 for even, 1 for odd.
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): 28 bytes hexadecimal message string
|
|
|
|
|
msg (str): 28 hexdigits string
|
|
|
|
|
Returns:
|
|
|
|
|
int: 0 or 1, for even or odd frame
|
|
|
|
|
"""
|
|
|
|
@ -203,7 +201,7 @@ def version(msg):
|
|
|
|
|
"""ADS-B Version
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): 28 bytes hexadecimal message string, TC = 31
|
|
|
|
|
msg (str): 28 hexdigits string, TC = 31
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
int: version number
|
|
|
|
@ -225,7 +223,7 @@ def nuc_p(msg):
|
|
|
|
|
"""Calculate NUCp, Navigation Uncertainty Category - Position (ADS-B version 1)
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): 28 bytes hexadecimal message string,
|
|
|
|
|
msg (str): 28 hexdigits string,
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
int: Horizontal Protection Limit
|
|
|
|
@ -261,7 +259,7 @@ def nuc_v(msg):
|
|
|
|
|
"""Calculate NUCv, Navigation Uncertainty Category - Velocity (ADS-B version 1)
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): 28 bytes hexadecimal message string,
|
|
|
|
|
msg (str): 28 hexdigits string,
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
int or string: 95% Horizontal Velocity Error
|
|
|
|
@ -290,7 +288,7 @@ def nic_v1(msg, NICs):
|
|
|
|
|
"""Calculate NIC, navigation integrity category, for ADS-B version 1
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): 28 bytes hexadecimal message string
|
|
|
|
|
msg (str): 28 hexdigits string
|
|
|
|
|
NICs (int or string): NIC supplement
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
@ -324,7 +322,7 @@ def nic_v2(msg, NICa, NICbc):
|
|
|
|
|
"""Calculate NIC, navigation integrity category, for ADS-B version 2
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): 28 bytes hexadecimal message string
|
|
|
|
|
msg (str): 28 hexdigits string
|
|
|
|
|
NICa (int or string): NIC supplement - A
|
|
|
|
|
NICbc (int or srting): NIC supplement - B or C
|
|
|
|
|
|
|
|
|
@ -362,7 +360,7 @@ def nic_s(msg):
|
|
|
|
|
"""Obtain NIC supplement bit, TC=31 message
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): 28 bytes hexadecimal message string
|
|
|
|
|
msg (str): 28 hexdigits string
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
int: NICs number (0 or 1)
|
|
|
|
@ -384,7 +382,7 @@ def nic_a_c(msg):
|
|
|
|
|
"""Obtain NICa/c, navigation integrity category supplements a and c
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): 28 bytes hexadecimal message string
|
|
|
|
|
msg (str): 28 hexdigits string
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
(int, int): NICa and NICc number (0 or 1)
|
|
|
|
@ -407,7 +405,7 @@ def nic_b(msg):
|
|
|
|
|
"""Obtain NICb, navigation integrity category supplement-b
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): 28 bytes hexadecimal message string
|
|
|
|
|
msg (str): 28 hexdigits string
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
int: NICb number (0 or 1)
|
|
|
|
@ -429,7 +427,7 @@ def nac_p(msg):
|
|
|
|
|
"""Calculate NACp, Navigation Accuracy Category - Position
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): 28 bytes hexadecimal message string, TC = 29 or 31
|
|
|
|
|
msg (str): 28 hexdigits string, TC = 29 or 31
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
int or string: 95% horizontal accuracy bounds, Estimated Position Uncertainty
|
|
|
|
@ -464,7 +462,7 @@ def nac_v(msg):
|
|
|
|
|
"""Calculate NACv, Navigation Accuracy Category - Velocity
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): 28 bytes hexadecimal message string, TC = 19
|
|
|
|
|
msg (str): 28 hexdigits string, TC = 19
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
int or string: 95% horizontal accuracy bounds for velocity, Horizontal Figure of Merit
|
|
|
|
@ -493,7 +491,7 @@ def sil(msg, version):
|
|
|
|
|
"""Calculate SIL, Surveillance Integrity Level
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
msg (string): 28 bytes hexadecimal message string with TC = 29, 31
|
|
|
|
|
msg (str): 28 hexdigits string with TC = 29, 31
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
int or string: Probability of exceeding Horizontal Radius of Containment RCu
|
|
|
|
|