fix docstrings

This commit is contained in:
junzis 2016-08-16 16:48:13 +02:00
parent 700b290047
commit fc286299ec
2 changed files with 79 additions and 3 deletions

View File

@ -24,8 +24,10 @@ from .util import crc
def df(msg): def df(msg):
"""Get the downlink format (DF) number """Get the downlink format (DF) number
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
Returns: Returns:
int: DF number int: DF number
""" """
@ -34,8 +36,10 @@ def df(msg):
def icao(msg): def icao(msg):
"""Get the ICAO 24 bits address, bytes 3 to 8. """Get the ICAO 24 bits address, bytes 3 to 8.
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
Returns: Returns:
String: ICAO address in 6 bytes hexadecimal string String: ICAO address in 6 bytes hexadecimal string
""" """
@ -49,8 +53,10 @@ def data(msg):
def typecode(msg): def typecode(msg):
"""Type code of ADS-B message """Type code of ADS-B message
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
Returns: Returns:
int: type code number int: type code number
""" """
@ -63,8 +69,10 @@ def typecode(msg):
# --------------------------------------------- # ---------------------------------------------
def category(msg): def category(msg):
"""Aircraft category number """Aircraft category number
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
Returns: Returns:
int: category number int: category number
""" """
@ -77,8 +85,10 @@ def category(msg):
def callsign(msg): def callsign(msg):
"""Aircraft callsign """Aircraft callsign
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
Returns: Returns:
string: callsign string: callsign
""" """
@ -112,8 +122,10 @@ def callsign(msg):
def oe_flag(msg): def oe_flag(msg):
"""Check the odd/even flag. Bit 54, 0 for even, 1 for odd. """Check the odd/even flag. Bit 54, 0 for even, 1 for odd.
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
Returns: Returns:
int: 0 or 1, for even or odd frame int: 0 or 1, for even or odd frame
""" """
@ -126,8 +138,10 @@ def oe_flag(msg):
def cprlat(msg): def cprlat(msg):
"""CPR encoded latitude """CPR encoded latitude
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
Returns: Returns:
int: encoded latitude int: encoded latitude
""" """
@ -140,8 +154,10 @@ def cprlat(msg):
def cprlon(msg): def cprlon(msg):
"""CPR encoded longitude """CPR encoded longitude
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
Returns: Returns:
int: encoded longitude int: encoded longitude
""" """
@ -165,12 +181,14 @@ def position(msg0, msg1, t0, t1):
def airborne_position(msg0, msg1, t0, t1): def airborne_position(msg0, msg1, t0, t1):
"""Decode airborn position from a pair of even and odd position message """Decode airborn position from a pair of even and odd position message
131072 is 2^17, since CPR lat and lon are 17 bits each. 131072 is 2^17, since CPR lat and lon are 17 bits each.
Args: Args:
msg0 (string): even message (28 bytes hexadecimal string) msg0 (string): even message (28 bytes hexadecimal string)
msg1 (string): odd message (28 bytes hexadecimal string) msg1 (string): odd message (28 bytes hexadecimal string)
t0 (int): timestamps for the even message t0 (int): timestamps for the even message
t1 (int): timestamps for the odd message t1 (int): timestamps for the odd message
Returns: Returns:
(float, float): (latitude, longitude) of the aircraft (float, float): (latitude, longitude) of the aircraft
""" """
@ -236,10 +254,12 @@ def position_with_ref(msg, lat_ref, lon_ref):
def airborne_position_with_ref(msg, lat_ref, lon_ref): def airborne_position_with_ref(msg, lat_ref, lon_ref):
"""Decode airborn position with one message, """Decode airborn position with one message,
knowing previous reference location knowing previous reference location
Args: Args:
msg (string): even message (28 bytes hexadecimal string) msg (string): even message (28 bytes hexadecimal string)
lat_ref: previous known latitude lat_ref: previous known latitude
lon_ref: previous known longitude lon_ref: previous known longitude
Returns: Returns:
(float, float): (latitude, longitude) of the aircraft (float, float): (latitude, longitude) of the aircraft
""" """
@ -280,10 +300,12 @@ def surface_position_with_ref(msg, lat_ref, lon_ref):
"""Decode surface position with one message, """Decode surface position with one message,
knowing reference nearby location, such as previously calculated location, knowing reference nearby location, such as previously calculated location,
ground station, or airport location, etc. ground station, or airport location, etc.
Args: Args:
msg (string): even message (28 bytes hexadecimal string) msg (string): even message (28 bytes hexadecimal string)
lat_ref: previous known latitude lat_ref: previous known latitude
lon_ref: previous known longitude lon_ref: previous known longitude
Returns: Returns:
(float, float): (latitude, longitude) of the aircraft (float, float): (latitude, longitude) of the aircraft
""" """
@ -335,8 +357,10 @@ def _cprNL(lat):
def altitude(msg): def altitude(msg):
"""Decode aircraft altitude """Decode aircraft altitude
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
Returns: Returns:
int: altitude in feet int: altitude in feet
""" """
@ -355,8 +379,10 @@ def altitude(msg):
def nic(msg): def nic(msg):
"""Calculate NIC, navigation integrity category """Calculate NIC, navigation integrity category
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
Returns: Returns:
int: NIC number (from 0 to 11), -1 if not applicable int: NIC number (from 0 to 11), -1 if not applicable
""" """
@ -404,8 +430,10 @@ def nic(msg):
def velocity(msg): def velocity(msg):
"""Calculate the speed, heading, and vertical rate """Calculate the speed, heading, and vertical rate
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
Returns: Returns:
(int, float, int, string): speed (kt), heading (degree), (int, float, int, string): speed (kt), heading (degree),
rate of climb/descend (ft/min), and speed type rate of climb/descend (ft/min), and speed type
@ -452,8 +480,10 @@ def velocity(msg):
def speed_heading(msg): def speed_heading(msg):
"""Get speed and heading only from the velocity message """Get speed and heading only from the velocity message
Args: Args:
msg (string): 28 bytes hexadecimal message string msg (string): 28 bytes hexadecimal message string
Returns: Returns:
(int, float): speed (kt), heading (degree) (int, float): speed (kt), heading (degree)
""" """

View File

@ -23,8 +23,10 @@ from .util import crc
def df(msg): def df(msg):
"""Get the downlink format (DF) number """Get the downlink format (DF) number
Args: Args:
msg (String): 28 bytes hexadecimal message string msg (String): 28 bytes hexadecimal message string
Returns: Returns:
int: DF number int: DF number
""" """
@ -38,9 +40,11 @@ def data(msg):
def icao(msg): def icao(msg):
"""Calculate the ICAO address from an Mode-S message """Calculate the ICAO address from an Mode-S message
with DF4, DF5, DF20, DF21 with DF4, DF5, DF20, DF21
Args: Args:
msg (String): 28 bytes hexadecimal message string msg (String): 28 bytes hexadecimal message string
Returns: Returns:
String: ICAO address in 6 bytes hexadecimal string String: ICAO address in 6 bytes hexadecimal string
""" """
@ -57,8 +61,9 @@ def icao(msg):
def checkbits(data, sb, msb, lsb): def checkbits(data, sb, msb, lsb):
"""Check if the status bit and field bits are consistency. This Function """Check if the status bit and field bits are consistency. This Function
is used for checking BDS code versions. is used for checking BDS code versions.
""" """
# status bit, most significant bit, least significant bit # status bit, most significant bit, least significant bit
status = int(data[sb-1]) status = int(data[sb-1])
value = util.bin2int(data[msb-1:lsb]) value = util.bin2int(data[msb-1:lsb])
@ -76,11 +81,14 @@ def checkbits(data, sb, msb, lsb):
def isBDS20(msg): def isBDS20(msg):
"""Check if a message is likely to be BDS code 2,0 """Check if a message is likely to be BDS code 2,0
Args: Args:
msg (String): 28 bytes hexadecimal message string msg (String): 28 bytes hexadecimal message string
Returns: Returns:
bool: True or False bool: True or False
""" """
# status bit 1, 14, and 27 # status bit 1, 14, and 27
d = util.hex2bin(data(msg)) d = util.hex2bin(data(msg))
@ -99,8 +107,10 @@ def isBDS20(msg):
def callsign(msg): def callsign(msg):
"""Aircraft callsign """Aircraft callsign
Args: Args:
msg (String): 28 bytes hexadecimal message (BDS40) string msg (String): 28 bytes hexadecimal message (BDS40) string
Returns: Returns:
string: callsign, max. 8 chars string: callsign, max. 8 chars
""" """
@ -127,11 +137,14 @@ def callsign(msg):
def isBDS40(msg): def isBDS40(msg):
"""Check if a message is likely to be BDS code 4,0 """Check if a message is likely to be BDS code 4,0
Args: Args:
msg (String): 28 bytes hexadecimal message string msg (String): 28 bytes hexadecimal message string
Returns: Returns:
bool: True or False bool: True or False
""" """
# status bit 1, 14, and 27 # status bit 1, 14, and 27
d = util.hex2bin(data(msg)) d = util.hex2bin(data(msg))
@ -152,8 +165,10 @@ def isBDS40(msg):
def alt_mcp(msg): def alt_mcp(msg):
"""Selected altitude, MCP/FCU """Selected altitude, MCP/FCU
Args: Args:
msg (String): 28 bytes hexadecimal message (BDS40) string msg (String): 28 bytes hexadecimal message (BDS40) string
Returns: Returns:
int: altitude in feet int: altitude in feet
""" """
@ -164,8 +179,10 @@ def alt_mcp(msg):
def alt_fms(msg): def alt_fms(msg):
"""Selected altitude, FMS """Selected altitude, FMS
Args: Args:
msg (String): 28 bytes hexadecimal message (BDS40) string msg (String): 28 bytes hexadecimal message (BDS40) string
Returns: Returns:
int: altitude in feet int: altitude in feet
""" """
@ -176,8 +193,10 @@ def alt_fms(msg):
def pbaro(msg): def pbaro(msg):
"""Barometric pressure setting """Barometric pressure setting
Args: Args:
msg (String): 28 bytes hexadecimal message (BDS40) string msg (String): 28 bytes hexadecimal message (BDS40) string
Returns: Returns:
float: pressure in millibar float: pressure in millibar
""" """
@ -192,11 +211,14 @@ def pbaro(msg):
def isBDS50(msg): def isBDS50(msg):
"""Check if a message is likely to be BDS code 5,0 """Check if a message is likely to be BDS code 5,0
Args: Args:
msg (String): 28 bytes hexadecimal message string msg (String): 28 bytes hexadecimal message string
Returns: Returns:
bool: True or False bool: True or False
""" """
# status bit 1, 12, 24, 35, 46 # status bit 1, 12, 24, 35, 46
d = util.hex2bin(data(msg)) d = util.hex2bin(data(msg))
@ -226,8 +248,10 @@ def isBDS50(msg):
def roll(msg): def roll(msg):
"""Aircraft roll angle """Aircraft roll angle
Args: Args:
msg (String): 28 bytes hexadecimal message (BDS50) string msg (String): 28 bytes hexadecimal message (BDS50) string
Returns: Returns:
float: angle in degrees, float: angle in degrees,
negative->left wing down, positive->right wing down negative->left wing down, positive->right wing down
@ -241,8 +265,10 @@ def roll(msg):
def track(msg): def track(msg):
"""True track angle """True track angle
Args: Args:
msg (String): 28 bytes hexadecimal message (BDS50) string msg (String): 28 bytes hexadecimal message (BDS50) string
Returns: Returns:
float: angle in degrees to true north (from 0 to 360) float: angle in degrees to true north (from 0 to 360)
""" """
@ -255,8 +281,10 @@ def track(msg):
def gs(msg): def gs(msg):
"""Aircraft ground speed """Aircraft ground speed
Args: Args:
msg (String): 28 bytes hexadecimal message (BDS50) string msg (String): 28 bytes hexadecimal message (BDS50) string
Returns: Returns:
int: ground speed in knots int: ground speed in knots
""" """
@ -267,8 +295,10 @@ def gs(msg):
def rtrack(msg): def rtrack(msg):
"""Track angle rate """Track angle rate
Args: Args:
msg (String): 28 bytes hexadecimal message (BDS50) string msg (String): 28 bytes hexadecimal message (BDS50) string
Returns: Returns:
float: angle rate in degrees/second float: angle rate in degrees/second
""" """
@ -281,8 +311,10 @@ def rtrack(msg):
def tas(msg): def tas(msg):
"""Aircraft true airspeed """Aircraft true airspeed
Args: Args:
msg (String): 28 bytes hexadecimal message (BDS50) string msg (String): 28 bytes hexadecimal message (BDS50) string
Returns: Returns:
int: true airspeed in knots int: true airspeed in knots
""" """
@ -297,8 +329,10 @@ def tas(msg):
def isBDS60(msg): def isBDS60(msg):
"""Check if a message is likely to be BDS code 6,0 """Check if a message is likely to be BDS code 6,0
Args: Args:
msg (String): 28 bytes hexadecimal message string msg (String): 28 bytes hexadecimal message string
Returns: Returns:
bool: True or False bool: True or False
""" """
@ -328,8 +362,10 @@ def isBDS60(msg):
def heading(msg): def heading(msg):
"""Megnetic heading of aircraft """Megnetic heading of aircraft
Args: Args:
msg (String): 28 bytes hexadecimal message (BDS60) string msg (String): 28 bytes hexadecimal message (BDS60) string
Returns: Returns:
float: heading in degrees to megnetic north (from 0 to 360) float: heading in degrees to megnetic north (from 0 to 360)
""" """
@ -342,8 +378,10 @@ def heading(msg):
def ias(msg): def ias(msg):
"""Indicated airspeed """Indicated airspeed
Args: Args:
msg (String): 28 bytes hexadecimal message (BDS60) string msg (String): 28 bytes hexadecimal message (BDS60) string
Returns: Returns:
int: indicated airspeed in knots int: indicated airspeed in knots
""" """
@ -354,8 +392,10 @@ def ias(msg):
def mach(msg): def mach(msg):
"""Aircraft MACH number """Aircraft MACH number
Args: Args:
msg (String): 28 bytes hexadecimal message (BDS60) string msg (String): 28 bytes hexadecimal message (BDS60) string
Returns: Returns:
float: MACH number float: MACH number
""" """
@ -366,8 +406,10 @@ def mach(msg):
def baro_vr(msg): def baro_vr(msg):
"""Vertical rate from barometric measurement """Vertical rate from barometric measurement
Args: Args:
msg (String): 28 bytes hexadecimal message (BDS60) string msg (String): 28 bytes hexadecimal message (BDS60) string
Returns: Returns:
int: vertical rate in feet/minutes int: vertical rate in feet/minutes
""" """
@ -380,8 +422,10 @@ def baro_vr(msg):
def ins_vr(msg): def ins_vr(msg):
"""Vertical rate messured by onbard equiments (IRS, AHRS) """Vertical rate messured by onbard equiments (IRS, AHRS)
Args: Args:
msg (String): 28 bytes hexadecimal message (BDS60) string msg (String): 28 bytes hexadecimal message (BDS60) string
Returns: Returns:
int: vertical rate in feet/minutes int: vertical rate in feet/minutes
""" """
@ -394,8 +438,10 @@ def ins_vr(msg):
def BDS(msg): def BDS(msg):
"""Estimate the most likely BDS code of an message """Estimate the most likely BDS code of an message
Args: Args:
msg (String): 28 bytes hexadecimal message string msg (String): 28 bytes hexadecimal message string
Returns: Returns:
String|None: Version: "BDS40", "BDS50", or "BDS60". Or None, if nothing String|None: Version: "BDS40", "BDS50", or "BDS60". Or None, if nothing
matched matched