INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Check if the status bit and field bits are consistency. This Function is used for checking BDS code versions.
def wrongstatus(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 = bin2int(data[msb-1:lsb]) if not status: ...
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
def is30(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 """ if allzeros(msg): return False d = hex2bin(data(msg)) if d[0:8] != '00110000': return False # t...
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 bytes hexadecimal string) msg1 (string): odd message (28 bytes hexadecimal string) t0 (int): timestamps for the even message ...
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) Args: msg0 (string): even message (28 bytes hexadecimal string) msg1 (string): odd message (28 bytes hexadec...
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. The reference position shall be with in 180NM (airborne) or 45NM (surface) of the true p...
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. The reference position shall be with in...
Decode aircraft altitude Args: msg (string): 28 bytes hexadecimal message string Returns: int: altitude in feet
def altitude(msg): """Decode aircraft altitude Args: msg (string): 28 bytes hexadecimal message string Returns: int: altitude in feet """ tc = typecode(msg) if tc<5 or tc==19 or tc>22: raise RuntimeError("%s: Not a position message" % msg) if tc>=5 and tc<=8: ...
Calculate the speed, heading, and vertical rate (handles both airborne or surface message) Args: msg (string): 28 bytes hexadecimal message string Returns: (int, float, int, string): speed (kt), ground track or heading (degree), rate of climb/descend (ft/min), and speed type ...
def velocity(msg): """Calculate the speed, heading, and vertical rate (handles both airborne or surface message) Args: msg (string): 28 bytes hexadecimal message string Returns: (int, float, int, string): speed (kt), ground track or heading (degree), rate of climb/descend (...
Get speed and ground track (or heading) from the velocity message (handles both airborne or surface message) Args: msg (string): 28 bytes hexadecimal message string Returns: (int, float): speed (kt), ground track or heading (degree)
def speed_heading(msg): """Get speed and ground track (or heading) from the velocity message (handles both airborne or surface message) Args: msg (string): 28 bytes hexadecimal message string Returns: (int, float): speed (kt), ground track or heading (degree) """ spd, trk_or_hd...
ADS-B Version Args: msg (string): 28 bytes hexadecimal message string, TC = 31 Returns: int: version number
def version(msg): """ADS-B Version Args: msg (string): 28 bytes hexadecimal message string, TC = 31 Returns: int: version number """ tc = typecode(msg) if tc != 31: raise RuntimeError("%s: Not a status operation message, expecting TC = 31" % msg) msgbin = common.h...
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)
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 -...
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
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) ...
Calculate NIC, navigation integrity category, for ADS-B version 1 Args: msg (string): 28 bytes hexadecimal message string NICs (int or string): NIC supplement Returns: int or string: Horizontal Radius of Containment int or string: Vertical Protection Limit
def nic_v1(msg, NICs): """Calculate NIC, navigation integrity category, for ADS-B version 1 Args: msg (string): 28 bytes hexadecimal message string NICs (int or string): NIC supplement Returns: int or string: Horizontal Radius of Containment int or string: Vertical Protecti...
Calculate NIC, navigation integrity category, for ADS-B version 2 Args: msg (string): 28 bytes hexadecimal message string NICa (int or string): NIC supplement - A NICbc (int or srting): NIC supplement - B or C Returns: int or string: Horizontal Radius of Containment
def nic_v2(msg, NICa, NICbc): """Calculate NIC, navigation integrity category, for ADS-B version 2 Args: msg (string): 28 bytes hexadecimal message string NICa (int or string): NIC supplement - A NICbc (int or srting): NIC supplement - B or C Returns: int or string: Horizon...
Obtain NIC supplement bit, TC=31 message Args: msg (string): 28 bytes hexadecimal message string Returns: int: NICs number (0 or 1)
def nic_s(msg): """Obtain NIC supplement bit, TC=31 message Args: msg (string): 28 bytes hexadecimal message string Returns: int: NICs number (0 or 1) """ tc = typecode(msg) if tc != 31: raise RuntimeError("%s: Not a status operation message, expecting TC = 31" % msg) ...
Obtain NICa/c, navigation integrity category supplements a and c Args: msg (string): 28 bytes hexadecimal message string Returns: (int, int): NICa and NICc number (0 or 1)
def nic_a_c(msg): """Obtain NICa/c, navigation integrity category supplements a and c Args: msg (string): 28 bytes hexadecimal message string Returns: (int, int): NICa and NICc number (0 or 1) """ tc = typecode(msg) if tc != 31: raise RuntimeError("%s: Not a status ope...
Obtain NICb, navigation integrity category supplement-b Args: msg (string): 28 bytes hexadecimal message string Returns: int: NICb number (0 or 1)
def nic_b(msg): """Obtain NICb, navigation integrity category supplement-b Args: msg (string): 28 bytes hexadecimal message string Returns: int: NICb number (0 or 1) """ tc = typecode(msg) if tc < 9 or tc > 18: raise RuntimeError("%s: Not a airborne position message, e...
Calculate NACp, Navigation Accuracy Category - Position Args: msg (string): 28 bytes hexadecimal message string, TC = 29 or 31 Returns: int or string: 95% horizontal accuracy bounds, Estimated Position Uncertainty int or string: 95% vertical accuracy bounds, Vertical Estimated Position...
def nac_p(msg): """Calculate NACp, Navigation Accuracy Category - Position Args: msg (string): 28 bytes hexadecimal message string, TC = 29 or 31 Returns: int or string: 95% horizontal accuracy bounds, Estimated Position Uncertainty int or string: 95% vertical accuracy bounds, Vert...
Calculate NACv, Navigation Accuracy Category - Velocity Args: msg (string): 28 bytes hexadecimal message string, TC = 19 Returns: int or string: 95% horizontal accuracy bounds for velocity, Horizontal Figure of Merit int or string: 95% vertical accuracy bounds for velocity, Vertical Fi...
def nac_v(msg): """Calculate NACv, Navigation Accuracy Category - Velocity Args: msg (string): 28 bytes hexadecimal message string, TC = 19 Returns: int or string: 95% horizontal accuracy bounds for velocity, Horizontal Figure of Merit int or string: 95% vertical accuracy bounds fo...
Calculate SIL, Surveillance Integrity Level Args: msg (string): 28 bytes hexadecimal message string with TC = 29, 31 Returns: int or string: Probability of exceeding Horizontal Radius of Containment RCu int or string: Probability of exceeding Vertical Integrity Containment Region VPL ...
def sil(msg, version): """Calculate SIL, Surveillance Integrity Level Args: msg (string): 28 bytes hexadecimal message string with TC = 29, 31 Returns: int or string: Probability of exceeding Horizontal Radius of Containment RCu int or string: Probability of exceeding Vertical Inte...
Check if a message is likely to be BDS code 5,0 (Track and turn report) Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False
def is50(msg): """Check if a message is likely to be BDS code 5,0 (Track and turn report) Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False """ if allzeros(msg): return False d = hex2bin(data(msg)) # status bit 1, 12, 24, 35...
Roll angle, BDS 5,0 message Args: msg (String): 28 bytes hexadecimal message (BDS50) string Returns: float: angle in degrees, negative->left wing down, positive->right wing down
def roll50(msg): """Roll angle, BDS 5,0 message Args: msg (String): 28 bytes hexadecimal message (BDS50) string Returns: float: angle in degrees, negative->left wing down, positive->right wing down """ d = hex2bin(data(msg)) if d[0] == '0': return None ...
True track angle, BDS 5,0 message Args: msg (String): 28 bytes hexadecimal message (BDS50) string Returns: float: angle in degrees to true north (from 0 to 360)
def trk50(msg): """True track angle, BDS 5,0 message Args: msg (String): 28 bytes hexadecimal message (BDS50) string Returns: float: angle in degrees to true north (from 0 to 360) """ d = hex2bin(data(msg)) if d[11] == '0': return None sign = int(d[12]) # 1 -> w...
Ground speed, BDS 5,0 message Args: msg (String): 28 bytes hexadecimal message (BDS50) string Returns: int: ground speed in knots
def gs50(msg): """Ground speed, BDS 5,0 message Args: msg (String): 28 bytes hexadecimal message (BDS50) string Returns: int: ground speed in knots """ d = hex2bin(data(msg)) if d[23] == '0': return None spd = bin2int(d[24:34]) * 2 # kts return spd
Aircraft true airspeed, BDS 5,0 message Args: msg (String): 28 bytes hexadecimal message (BDS50) string Returns: int: true airspeed in knots
def tas50(msg): """Aircraft true airspeed, BDS 5,0 message Args: msg (String): 28 bytes hexadecimal message (BDS50) string Returns: int: true airspeed in knots """ d = hex2bin(data(msg)) if d[45] == '0': return None tas = bin2int(d[46:56]) * 2 # kts return t...
Check if a message is likely to be BDS code 5,3 (Air-referenced state vector) Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False
def is53(msg): """Check if a message is likely to be BDS code 5,3 (Air-referenced state vector) Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False """ if allzeros(msg): return False d = hex2bin(data(msg)) # status bit 1, 13, ...
Indicated airspeed, DBS 5,3 message Args: msg (String): 28 bytes hexadecimal message Returns: int: indicated arispeed in knots
def ias53(msg): """Indicated airspeed, DBS 5,3 message Args: msg (String): 28 bytes hexadecimal message Returns: int: indicated arispeed in knots """ d = hex2bin(data(msg)) if d[12] == '0': return None ias = bin2int(d[13:23]) # knots return ias
MACH number, DBS 5,3 message Args: msg (String): 28 bytes hexadecimal message Returns: float: MACH number
def mach53(msg): """MACH number, DBS 5,3 message Args: msg (String): 28 bytes hexadecimal message Returns: float: MACH number """ d = hex2bin(data(msg)) if d[23] == '0': return None mach = bin2int(d[24:33]) * 0.008 return round(mach, 3)
Aircraft true airspeed, BDS 5,3 message Args: msg (String): 28 bytes hexadecimal message Returns: float: true airspeed in knots
def tas53(msg): """Aircraft true airspeed, BDS 5,3 message Args: msg (String): 28 bytes hexadecimal message Returns: float: true airspeed in knots """ d = hex2bin(data(msg)) if d[33] == '0': return None tas = bin2int(d[34:46]) * 0.5 # kts return round(tas, 1...
<esc> "1" : 6 byte MLAT timestamp, 1 byte signal level, 2 byte Mode-AC <esc> "2" : 6 byte MLAT timestamp, 1 byte signal level, 7 byte Mode-S short frame <esc> "3" : 6 byte MLAT timestamp, 1 byte signal level, 14 byte Mode-S long frame <esc> "4" : 6 byte MLAT t...
def read_beast_buffer(self): ''' <esc> "1" : 6 byte MLAT timestamp, 1 byte signal level, 2 byte Mode-AC <esc> "2" : 6 byte MLAT timestamp, 1 byte signal level, 7 byte Mode-S short frame <esc> "3" : 6 byte MLAT timestamp, 1 byte signal level, 14 byte Mo...
Skysense stream format. :: ---------------------------------------------------------------------------------- Field SS MS MS MS MS MS MS MS MS MS MS MS MS MS MS TS TS TS TS TS TS RS RS RS ---------------------------------------------------------------------------------...
def read_skysense_buffer(self): """Skysense stream format. :: ---------------------------------------------------------------------------------- Field SS MS MS MS MS MS MS MS MS MS MS MS MS MS MS TS TS TS TS TS TS RS RS RS --------------------------------------...
Check if a message is likely to be BDS code 1,0 Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False
def is10(msg): """Check if a message is likely to be BDS code 1,0 Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False """ if allzeros(msg): return False d = hex2bin(data(msg)) # first 8 bits must be 0x10 if d[0:8] != '00010000...
Check if a message is likely to be BDS code 1,7 Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False
def is17(msg): """Check if a message is likely to be BDS code 1,7 Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False """ if allzeros(msg): return False d = hex2bin(data(msg)) if bin2int(d[28:56]) != 0: return False c...
Extract capacities from BDS 1,7 message Args: msg (String): 28 bytes hexadecimal message string Returns: list: list of suport BDS codes
def cap17(msg): """Extract capacities from BDS 1,7 message Args: msg (String): 28 bytes hexadecimal message string Returns: list: list of suport BDS codes """ allbds = ['05', '06', '07', '08', '09', '0A', '20', '21', '40', '41', '42', '43', '44', '45', '48', '50', '51...
process a chunk of adsb and commb messages recieved in the same time period.
def process_raw(self, adsb_ts, adsb_msgs, commb_ts, commb_msgs, tnow=None): """process a chunk of adsb and commb messages recieved in the same time period. """ if tnow is None: tnow = time.time() self.t = tnow local_updated_acs_buffer = [] output_buf...
all aircraft that are stored in memeory
def get_aircraft(self): """all aircraft that are stored in memeory""" acs = self.acs icaos = list(acs.keys()) for icao in icaos: if acs[icao]['lat'] is None: acs.pop(icao) return acs
Calculate the speed, track (or heading), and vertical rate Args: msg (string): 28 bytes hexadecimal message string Returns: (int, float, int, string): speed (kt), ground track or heading (degree), rate of climb/descend (ft/min), and speed type ('GS' for ground speed, 'A...
def airborne_velocity(msg): """Calculate the speed, track (or heading), and vertical rate Args: msg (string): 28 bytes hexadecimal message string Returns: (int, float, int, string): speed (kt), ground track or heading (degree), rate of climb/descend (ft/min), and speed type ...
Decode the differece between GNSS and barometric altitude Args: msg (string): 28 bytes hexadecimal message string, TC=19 Returns: int: Altitude difference in ft. Negative value indicates GNSS altitude below barometric altitude.
def altitude_diff(msg): """Decode the differece between GNSS and barometric altitude Args: msg (string): 28 bytes hexadecimal message string, TC=19 Returns: int: Altitude difference in ft. Negative value indicates GNSS altitude below barometric altitude. """ tc = common...
Use reference ground speed and trk to determine BDS50 and DBS60. Args: msg (String): 28 bytes hexadecimal message string spd_ref (float): reference speed (ADS-B ground speed), kts trk_ref (float): reference track (ADS-B track angle), deg alt_ref (float): reference altitude (ADS-B al...
def is50or60(msg, spd_ref, trk_ref, alt_ref): """Use reference ground speed and trk to determine BDS50 and DBS60. Args: msg (String): 28 bytes hexadecimal message string spd_ref (float): reference speed (ADS-B ground speed), kts trk_ref (float): reference track (ADS-B track angle), deg ...
Estimate the most likely BDS code of an message. Args: msg (String): 28 bytes hexadecimal message string mrar (bool): Also infer MRAR (BDS 44) and MHR (BDS 45). Defaults to False. Returns: String or None: BDS version, or possible versions, or None if nothing matches.
def infer(msg, mrar=False): """Estimate the most likely BDS code of an message. Args: msg (String): 28 bytes hexadecimal message string mrar (bool): Also infer MRAR (BDS 44) and MHR (BDS 45). Defaults to False. Returns: String or None: BDS version, or possible versions, or None if ...
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
def is40(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 """ if allzeros(msg): return False d = hex2bin(data(msg)) # status bit 1, 14, and 27 if wrongstatus(d, 1, 2...
Selected altitude, MCP/FCU Args: msg (String): 28 bytes hexadecimal message (BDS40) string Returns: int: altitude in feet
def alt40mcp(msg): """Selected altitude, MCP/FCU Args: msg (String): 28 bytes hexadecimal message (BDS40) string Returns: int: altitude in feet """ d = hex2bin(data(msg)) if d[0] == '0': return None alt = bin2int(d[1:13]) * 16 # ft return alt
Selected altitude, FMS Args: msg (String): 28 bytes hexadecimal message (BDS40) string Returns: int: altitude in feet
def alt40fms(msg): """Selected altitude, FMS Args: msg (String): 28 bytes hexadecimal message (BDS40) string Returns: int: altitude in feet """ d = hex2bin(data(msg)) if d[13] == '0': return None alt = bin2int(d[14:26]) * 16 # ft return alt
Barometric pressure setting Args: msg (String): 28 bytes hexadecimal message (BDS40) string Returns: float: pressure in millibar
def p40baro(msg): """Barometric pressure setting Args: msg (String): 28 bytes hexadecimal message (BDS40) string Returns: float: pressure in millibar """ d = hex2bin(data(msg)) if d[26] == '0': return None p = bin2int(d[27:39]) * 0.1 + 800 # millibar return...
Check if a message is likely to be BDS code 4,4. Meteorological routine air report Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False
def is44(msg): """Check if a message is likely to be BDS code 4,4. Meteorological routine air report Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False """ if allzeros(msg): return False d = hex2bin(data(msg)) # status bit 5...
Wind speed and direction. Args: msg (String): 28 bytes hexadecimal message string Returns: (int, float): speed (kt), direction (degree)
def wind44(msg): """Wind speed and direction. Args: msg (String): 28 bytes hexadecimal message string Returns: (int, float): speed (kt), direction (degree) """ d = hex2bin(data(msg)) status = int(d[4]) if not status: return None speed = bin2int(d[5:14]) # k...
Static air temperature. Args: msg (String): 28 bytes hexadecimal message string Returns: float, float: temperature and alternative temperature in Celsius degree. Note: Two values returns due to what seems to be an inconsistancy error in ICAO 9871 (2008) Appendix A-67.
def temp44(msg): """Static air temperature. Args: msg (String): 28 bytes hexadecimal message string Returns: float, float: temperature and alternative temperature in Celsius degree. Note: Two values returns due to what seems to be an inconsistancy error in ICAO 9871...
Static pressure. Args: msg (String): 28 bytes hexadecimal message string Returns: int: static pressure in hPa
def p44(msg): """Static pressure. Args: msg (String): 28 bytes hexadecimal message string Returns: int: static pressure in hPa """ d = hex2bin(data(msg)) if d[34] == '0': return None p = bin2int(d[35:46]) # hPa return p
humidity Args: msg (String): 28 bytes hexadecimal message string Returns: float: percentage of humidity, [0 - 100] %
def hum44(msg): """humidity Args: msg (String): 28 bytes hexadecimal message string Returns: float: percentage of humidity, [0 - 100] % """ d = hex2bin(data(msg)) if d[49] == '0': return None hm = bin2int(d[50:56]) * 100.0 / 64 # % return round(hm, 1)
Turblence. Args: msg (String): 28 bytes hexadecimal message string Returns: int: turbulence level. 0=NIL, 1=Light, 2=Moderate, 3=Severe
def turb44(msg): """Turblence. Args: msg (String): 28 bytes hexadecimal message string Returns: int: turbulence level. 0=NIL, 1=Light, 2=Moderate, 3=Severe """ d = hex2bin(data(msg)) if d[46] == '0': return None turb = bin2int(d[47:49]) return turb
Decode surface position from a pair of even and odd position message, the lat/lon of receiver must be provided to yield the correct solution. Args: msg0 (string): even message (28 bytes hexadecimal string) msg1 (string): odd message (28 bytes hexadecimal string) t0 (int): timestamps for...
def surface_position(msg0, msg1, t0, t1, lat_ref, lon_ref): """Decode surface position from a pair of even and odd position message, the lat/lon of receiver must be provided to yield the correct solution. Args: msg0 (string): even message (28 bytes hexadecimal string) msg1 (string): odd mes...
Decode surface velocity from from a surface position message Args: msg (string): 28 bytes hexadecimal message string Returns: (int, float, int, string): speed (kt), ground track (degree), rate of climb/descend (ft/min), and speed type ('GS' for ground speed, 'AS' for air...
def surface_velocity(msg): """Decode surface velocity from from a surface position message Args: msg (string): 28 bytes hexadecimal message string Returns: (int, float, int, string): speed (kt), ground track (degree), rate of climb/descend (ft/min), and speed type ('...
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
def is20(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 """ if allzeros(msg): return False d = hex2bin(data(msg)) if d[0:8] != '00100000': return False cs ...
Aircraft callsign Args: msg (String): 28 bytes hexadecimal message (BDS40) string Returns: string: callsign, max. 8 chars
def cs20(msg): """Aircraft callsign Args: msg (String): 28 bytes hexadecimal message (BDS40) string Returns: string: callsign, max. 8 chars """ chars = '#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######' d = hex2bin(data(msg)) cs = '' cs += chars[bin2in...
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
def is60(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 """ if allzeros(msg): return False d = hex2bin(data(msg)) # status bit 1, 13, 24, 35, 46 if wrongstatus(d, ...
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)
def hdg60(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) """ d = hex2bin(data(msg)) if d[0] == '0': return None sign = int(d[1]) # 1 -> w...
Indicated airspeed Args: msg (String): 28 bytes hexadecimal message (BDS60) string Returns: int: indicated airspeed in knots
def ias60(msg): """Indicated airspeed Args: msg (String): 28 bytes hexadecimal message (BDS60) string Returns: int: indicated airspeed in knots """ d = hex2bin(data(msg)) if d[12] == '0': return None ias = bin2int(d[13:23]) # kts return ias
Aircraft MACH number Args: msg (String): 28 bytes hexadecimal message (BDS60) string Returns: float: MACH number
def mach60(msg): """Aircraft MACH number Args: msg (String): 28 bytes hexadecimal message (BDS60) string Returns: float: MACH number """ d = hex2bin(data(msg)) if d[23] == '0': return None mach = bin2int(d[24:34]) * 2.048 / 512.0 return round(mach, 3)
Vertical rate from barometric measurement, this value may be very noisy. Args: msg (String): 28 bytes hexadecimal message (BDS60) string Returns: int: vertical rate in feet/minutes
def vr60baro(msg): """Vertical rate from barometric measurement, this value may be very noisy. Args: msg (String): 28 bytes hexadecimal message (BDS60) string Returns: int: vertical rate in feet/minutes """ d = hex2bin(data(msg)) if d[34] == '0': return None sign ...
Check if a message is likely to be BDS code 4,5. Meteorological hazard report Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False
def is45(msg): """Check if a message is likely to be BDS code 4,5. Meteorological hazard report Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False """ if allzeros(msg): return False d = hex2bin(data(msg)) # status bit 1, 4, ...
Turbulence. Args: msg (String): 28 bytes hexadecimal message string Returns: int: Turbulence level. 0=NIL, 1=Light, 2=Moderate, 3=Severe
def turb45(msg): """Turbulence. Args: msg (String): 28 bytes hexadecimal message string Returns: int: Turbulence level. 0=NIL, 1=Light, 2=Moderate, 3=Severe """ d = hex2bin(data(msg)) if d[0] == '0': return None turb = bin2int(d[1:3]) return turb
Wind shear. Args: msg (String): 28 bytes hexadecimal message string Returns: int: Wind shear level. 0=NIL, 1=Light, 2=Moderate, 3=Severe
def ws45(msg): """Wind shear. Args: msg (String): 28 bytes hexadecimal message string Returns: int: Wind shear level. 0=NIL, 1=Light, 2=Moderate, 3=Severe """ d = hex2bin(data(msg)) if d[3] == '0': return None ws = bin2int(d[4:6]) return ws
Microburst. Args: msg (String): 28 bytes hexadecimal message string Returns: int: Microburst level. 0=NIL, 1=Light, 2=Moderate, 3=Severe
def mb45(msg): """Microburst. Args: msg (String): 28 bytes hexadecimal message string Returns: int: Microburst level. 0=NIL, 1=Light, 2=Moderate, 3=Severe """ d = hex2bin(data(msg)) if d[6] == '0': return None mb = bin2int(d[7:9]) return mb
Icing. Args: msg (String): 28 bytes hexadecimal message string Returns: int: Icing level. 0=NIL, 1=Light, 2=Moderate, 3=Severe
def ic45(msg): """Icing. Args: msg (String): 28 bytes hexadecimal message string Returns: int: Icing level. 0=NIL, 1=Light, 2=Moderate, 3=Severe """ d = hex2bin(data(msg)) if d[9] == '0': return None ic = bin2int(d[10:12]) return ic
Wake vortex. Args: msg (String): 28 bytes hexadecimal message string Returns: int: Wake vortex level. 0=NIL, 1=Light, 2=Moderate, 3=Severe
def wv45(msg): """Wake vortex. Args: msg (String): 28 bytes hexadecimal message string Returns: int: Wake vortex level. 0=NIL, 1=Light, 2=Moderate, 3=Severe """ d = hex2bin(data(msg)) if d[12] == '0': return None ws = bin2int(d[13:15]) return ws
Static air temperature. Args: msg (String): 28 bytes hexadecimal message string Returns: float: tmeperature in Celsius degree
def temp45(msg): """Static air temperature. Args: msg (String): 28 bytes hexadecimal message string Returns: float: tmeperature in Celsius degree """ d = hex2bin(data(msg)) sign = int(d[16]) value = bin2int(d[17:26]) if sign: value = value - 512 temp = v...
Average static pressure. Args: msg (String): 28 bytes hexadecimal message string Returns: int: static pressure in hPa
def p45(msg): """Average static pressure. Args: msg (String): 28 bytes hexadecimal message string Returns: int: static pressure in hPa """ d = hex2bin(data(msg)) if d[26] == '0': return None p = bin2int(d[27:38]) # hPa return p
Radio height. Args: msg (String): 28 bytes hexadecimal message string Returns: int: radio height in ft
def rh45(msg): """Radio height. Args: msg (String): 28 bytes hexadecimal message string Returns: int: radio height in ft """ d = hex2bin(data(msg)) if d[38] == '0': return None rh = bin2int(d[39:51]) * 16 return rh
Speed of sound
def vsound(H): """Speed of sound""" T = temperature(H) a = np.sqrt(gamma * R * T) return a
Compute spherical distance from spherical coordinates. For two locations in spherical coordinates (1, theta, phi) and (1, theta', phi') cosine( arc length ) = sin phi sin phi' cos(theta-theta') + cos phi cos phi' distance = rho * arc length
def distance(lat1, lon1, lat2, lon2, H=0): """ Compute spherical distance from spherical coordinates. For two locations in spherical coordinates (1, theta, phi) and (1, theta', phi') cosine( arc length ) = sin phi sin phi' cos(theta-theta') + cos phi cos phi' distance = rho * arc length ...
True Airspeed to Mach number
def tas2mach(Vtas, H): """True Airspeed to Mach number""" a = vsound(H) Mach = Vtas/a return Mach
Mach number to True Airspeed
def mach2tas(Mach, H): """Mach number to True Airspeed""" a = vsound(H) Vtas = Mach*a return Vtas
True Airspeed to Equivalent Airspeed
def tas2eas(Vtas, H): """True Airspeed to Equivalent Airspeed""" rho = density(H) Veas = Vtas * np.sqrt(rho/rho0) return Veas
Calibrated Airspeed to True Airspeed
def cas2tas(Vcas, H): """Calibrated Airspeed to True Airspeed""" p, rho, T = atmos(H) qdyn = p0*((1.+rho0*Vcas*Vcas/(7.*p0))**3.5-1.) Vtas = np.sqrt(7.*p/rho*((1.+qdyn/p)**(2./7.)-1.)) return Vtas
Mach number to Calibrated Airspeed
def mach2cas(Mach, H): """Mach number to Calibrated Airspeed""" Vtas = mach2tas(Mach, H) Vcas = tas2cas(Vtas, H) return Vcas
Calibrated Airspeed to Mach number
def cas2mach(Vcas, H): """Calibrated Airspeed to Mach number""" Vtas = cas2tas(Vcas, H) Mach = tas2mach(Vtas, H) return Mach
Makdown image upload for uploading to imgur.com and represent as json to markdown editor.
def markdown_imgur_uploader(request): """ Makdown image upload for uploading to imgur.com and represent as json to markdown editor. """ if request.method == 'POST' and request.is_ajax(): if 'markdown-image-upload' in request.FILES: image = request.FILES['markdown-image-upload'] ...
Json usernames of the users registered & actived. url(method=get): /martor/search-user/?username={username} Response: error: - `status` is status code (204) - `error` is error message. success: - `status` is status code (204) - `data` is ...
def markdown_search_user(request): """ Json usernames of the users registered & actived. url(method=get): /martor/search-user/?username={username} Response: error: - `status` is status code (204) - `error` is error message. success: - `status...
Makesure `username` is registered and actived.
def handleMatch(self, m): username = self.unescape(m.group(2)) """Makesure `username` is registered and actived.""" if MARTOR_ENABLE_CONFIGS['mention'] == 'true': if username in [u.username for u in User.objects.exclude(is_active=False)]: url = '{0}{1}/'.format(MARTO...
Basic imgur uploader return as json data. :param `image` is from `request.FILES['markdown-image-upload']` Return: success: {'status': 200, 'link': <link_image>, 'name': <image_name>} error : {'status': <error_code>, 'erorr': <erorr_message>}
def imgur_uploader(image): """ Basic imgur uploader return as json data. :param `image` is from `request.FILES['markdown-image-upload']` Return: success: {'status': 200, 'link': <link_image>, 'name': <image_name>} error : {'status': <error_code>, 'erorr': <erorr_message>} """ u...
Render the markdown content to HTML. Basic: >>> from martor.utils import markdownify >>> content = "![awesome](http://i.imgur.com/hvguiSn.jpg)" >>> markdownify(content) '<p><img alt="awesome" src="http://i.imgur.com/hvguiSn.jpg" /></p>' >>>
def markdownify(markdown_content): """ Render the markdown content to HTML. Basic: >>> from martor.utils import markdownify >>> content = "![awesome](http://i.imgur.com/hvguiSn.jpg)" >>> markdownify(content) '<p><img alt="awesome" src="http://i.imgur.com/hvguiSn.jpg" /></p>'...
:rtype: list of SliceViewContext
def _ctxs(self): """ :rtype: list of SliceViewContext """ return [self._tab_widget.widget(index).context for index in range(0, self._tab_widget.count())]
:param widget: The SegyViewWidget that will be added to the SegyTabWidget :type widget: SegyViewWidget
def add_segy_view_widget(self, ind, widget, name=None): """ :param widget: The SegyViewWidget that will be added to the SegyTabWidget :type widget: SegyViewWidget """ if self._context is None: self._segywidgets.append(widget) self.initialize() ...
:type indexes: list[int]
def indexes(self, indexes): """ :type indexes: list[int] """ self._indexes = indexes self._index = len(indexes) / 2
:type indexes: list[int]
def x_indexes(self, indexes): """ :type indexes: list[int] """ self._assert_shape(self._data, indexes, self._y_indexes) self._x_indexes = indexes self.x_index = len(indexes) / 2
:type indexes: list[int]
def y_indexes(self, indexes): """ :type indexes: list[int] """ self._assert_shape(self._data, self._x_indexes, indexes) self._y_indexes = indexes self.y_index = len(indexes) / 2
:type: numppy.ndarray
def data(self, data): """ :type: numppy.ndarray """ self._assert_shape(data, self._x_indexes, self._y_indexes) data[data == -np.inf] = 0.0 data[data == np.inf] = 0.0 self._data = data self._min_value = np.nanmin(self.data) self._max_value = np.nanmax(self.data) ...
:type index: int
def index(self, index): """ :type index: int """ if self._index != index: self._dirty = True self._index = index
:type context: dict
def create_slice(self, context): """ :type context: dict """ model = self._model axes = self._image.axes """ :type: matplotlib.axes.Axes """ axes.set_title(model.title, fontsize=12) axes.tick_params(axis='both') axes.set_ylabel(model.y_axis_name, fontsize=9) ...
:type context: dict
def data_changed(self, context): """ :type context: dict """ model = self._model self._image.set_data(model.data) self._image.set_extent((0, model.width, model.height, 0))
:type context: dict
def context_changed(self, context): """ :type context: dict """ self._image.set_cmap(context['colormap']) self._image.set_clim(context['min'], context['max']) self._image.set_interpolation(context['interpolation']) self._update_indicators(context) self._set_view_limits()...
:type context: dict
def _update_indicators(self, context): """ :type context: dict """ model = self._model self._vertical_indicator.set_height(model.height + 1) self._vertical_indicator.set_width(1) self._horizontal_indicator.set_width(model.width + 1) self._horizontal_indicator.set_height(1...
:type index_direction: SliceDirection :type index: int
def update_index_for_direction(self, index_direction, index): """ :type index_direction: SliceDirection :type index: int """ indexes = self._slice_data_source.indexes_for_direction(index_direction) if index < 0: index = 0 elif index >= len(indexes): ...
:type: QVariant
def _get_spec(self, index): user_data = self.itemData(index) """ :type: QVariant""" spec = user_data.toPyObject() return {str(key): value for key, value in spec.items()}
:type color_map_name: str :type image: QImage :type values: np.ndarray
def _create_icon(self, color_map_name, image, values): """" :type color_map_name: str :type image: QImage :type values: np.ndarray """ color_map = ScalarMappable(cmap=color_map_name) rgba = color_map.to_rgba(values, bytes=True) color_table = [qRgb(c[0], ...
:param axes: The Axes instance to find the index of. :type axes: Axes :rtype: int
def index(self, axes): """ :param axes: The Axes instance to find the index of. :type axes: Axes :rtype: int """ return None if axes is self._colormap_axes else self._axes.index(axes)
Return package version as listed in `__version__` in `init.py`.
def get_version(package): """ Return package version as listed in `__version__` in `init.py`. """ init_py = codecs.open(os.path.join(package, '__init__.py'), encoding='utf-8').read() return re.search("^__version__ = ['\"]([^'\"]+)['\"]", init_py, re.MULTILINE).group(1)
Get the entry url given and entry page a blog page instances. It will use an url or another depending if blog_page is the root page.
def get_entry_url(entry, blog_page, root_page): """ Get the entry url given and entry page a blog page instances. It will use an url or another depending if blog_page is the root page. """ if root_page == blog_page: return reverse('entry_page_serve', kwargs={ 'year': entry.date.s...
Get the feeds urls a blog page instance. It will use an url or another depending if blog_page is the root page.
def get_feeds_url(blog_page, root_page): """ Get the feeds urls a blog page instance. It will use an url or another depending if blog_page is the root page. """ if root_page == blog_page: return reverse('blog_page_feed') else: blog_path = strip_prefix_and_ending_slash(blog_page.s...
Registering the `blockquote` feature, which uses the `blockquote` Draft.js block type, and is stored as HTML with a `<blockquote>` tag.
def register_blockquote_feature(features): """ Registering the `blockquote` feature, which uses the `blockquote` Draft.js block type, and is stored as HTML with a `<blockquote>` tag. """ feature_name = 'blockquote' type_ = 'blockquote' tag = 'blockquote' control = { 'type': type...
Install all packages in dependency list via pip.
def install_dependencies(dependencies, verbose=False): """Install all packages in dependency list via pip.""" if not dependencies: return stdout = stderr = None if verbose else subprocess.DEVNULL with tempfile.TemporaryDirectory() as req_dir: req_file = Path(req_dir) / "requirements.txt...
Add check translations according to ``config`` as a fallback to existing translations
def install_translations(config): """Add check translations according to ``config`` as a fallback to existing translations""" if not config: return from . import _translation checks_translation = gettext.translation(domain=config["domain"], localedi...