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):
"""Get the downlink format (DF) number
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: DF number
"""
@ -34,8 +36,10 @@ def df(msg):
def icao(msg):
"""Get the ICAO 24 bits address, bytes 3 to 8.
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
String: ICAO address in 6 bytes hexadecimal string
"""
@ -49,8 +53,10 @@ def data(msg):
def typecode(msg):
"""Type code of ADS-B message
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: type code number
"""
@ -63,8 +69,10 @@ def typecode(msg):
# ---------------------------------------------
def category(msg):
"""Aircraft category number
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: category number
"""
@ -77,8 +85,10 @@ def category(msg):
def callsign(msg):
"""Aircraft callsign
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
string: callsign
"""
@ -112,8 +122,10 @@ def callsign(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
Returns:
int: 0 or 1, for even or odd frame
"""
@ -126,8 +138,10 @@ def oe_flag(msg):
def cprlat(msg):
"""CPR encoded latitude
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: encoded latitude
"""
@ -140,8 +154,10 @@ def cprlat(msg):
def cprlon(msg):
"""CPR encoded longitude
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: encoded longitude
"""
@ -166,11 +182,13 @@ def position(msg0, msg1, t0, t1):
def airborne_position(msg0, msg1, t0, t1):
"""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.
Args:
msg0 (string): even message (28 bytes hexadecimal string)
msg1 (string): odd message (28 bytes hexadecimal string)
t0 (int): timestamps for the even message
t1 (int): timestamps for the odd message
Returns:
(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):
"""Decode airborn position with one message,
knowing previous reference location
Args:
msg (string): even message (28 bytes hexadecimal string)
lat_ref: previous known latitude
lon_ref: previous known longitude
Returns:
(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,
knowing reference nearby location, such as previously calculated location,
ground station, or airport location, etc.
Args:
msg (string): even message (28 bytes hexadecimal string)
lat_ref: previous known latitude
lon_ref: previous known longitude
Returns:
(float, float): (latitude, longitude) of the aircraft
"""
@ -335,8 +357,10 @@ def _cprNL(lat):
def altitude(msg):
"""Decode aircraft altitude
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: altitude in feet
"""
@ -355,8 +379,10 @@ def altitude(msg):
def nic(msg):
"""Calculate NIC, navigation integrity category
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: NIC number (from 0 to 11), -1 if not applicable
"""
@ -404,8 +430,10 @@ def nic(msg):
def velocity(msg):
"""Calculate the speed, heading, and vertical rate
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
(int, float, int, string): speed (kt), heading (degree),
rate of climb/descend (ft/min), and speed type
@ -452,8 +480,10 @@ def velocity(msg):
def speed_heading(msg):
"""Get speed and heading only from the velocity message
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
(int, float): speed (kt), heading (degree)
"""

View File

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