Merge branch 'master' into adsb_encoder

This commit is contained in:
Junzi Sun 2020-05-04 01:53:27 +02:00
commit 59d21de725
60 changed files with 404 additions and 437 deletions

View File

@ -1,6 +1,42 @@
The Python ADS-B/Mode-S Decoder
===============================
PyModeS is a Python library designed to decode Mode-S (including ADS-B) message. It can be imported to your python project or used as a standalone tool to view and save live traffic data.
This is a project created by Junzi Sun, who works at `TU Delft <https://www.tudelft.nl/en/>`_, `Aerospace Engineering Faculty <https://www.tudelft.nl/en/ae/>`_, `CNS/ATM research group <http://cs.lr.tudelft.nl/atm/>`_. It is supported by many `contributors <https://github.com/junzis/pyModeS/graphs/contributors>`_ from different institutions.
Introduction
------------
pyModeS supports the decoding of following types of messages:
- DF4 / DF20: Altitude code
- DF5 / DF21: Identity code (squawk code)
- DF17 / DF18: Automatic Dependent Surveillance-Broadcast (ADS-B)
- TC=1-4 / BDS 0,8: Aircraft identification and category
- TC=5-8 / BDS 0,6: Surface position
- TC=9-18 / BDS 0,5: Airborne position
- TC=19 / BDS 0,9: Airborne velocity
- TC=28 / BDS 6,1: Airborne status [to be implemented]
- TC=29 / BDS 6,2: Target state and status information [to be implemented]
- TC=31 / BDS 6,5: Aircraft operational status [to be implemented]
- DF20 / DF21: Mode-S Comm-B messages
- BDS 1,0: Data link capability report
- BDS 1,7: Common usage GICB capability report
- BDS 2,0: Aircraft identification
- BDS 3,0: ACAS active resolution advisory
- BDS 4,0: Selected vertical intention
- BDS 4,4: Meteorological routine air report (experimental)
- BDS 4,5: Meteorological hazard report (experimental)
- BDS 5,0: Track and turn report
- BDS 6,0: Heading and speed report
If you find this project useful for your research, please considering cite this tool as::
@article{sun2019pymodes,
@ -14,40 +50,6 @@ If you find this project useful for your research, please considering cite this
Introduction
---------------------
PyModeS is a Python library designed to decode Mode-S (including ADS-B) message. It can be imported to your python project or be used as a standalone tool to view and save live traffic data.
Messages with following Downlink Formats (DF) are supported:
**DF17 / DF18: Automatic Dependent Surveillance-Broadcast (ADS-B)**
- TC=1-4 / BDS 0,8: Aircraft identification and category
- TC=5-8 / BDS 0,6: Surface position
- TC=9-18 / BDS 0,5: Airborne position
- TC=19 / BDS 0,9: Airborne velocity
- TC=28 / BDS 6,1: Airborne status [to be implemented]
- TC=29 / BDS 6,2: Target state and status information [to be implemented]
- TC=31 / BDS 6,5: Aircraft operational status [to be implemented]
**DF20 / DF21: Mode-S Comm-B replies**
- BDS 1,0: Data link capability report
- BDS 1,7: Common usage GICB capability report
- BDS 2,0: Aircraft identification
- BDS 3,0: ACAS active resolution advisory
- BDS 4,0: Selected vertical intention
- BDS 4,4: Meteorological routine air report (experimental)
- BDS 4,5: Meteorological hazard report (experimental)
- BDS 5,0: Track and turn report
- BDS 6,0: Heading and speed report
**DF4 / DF20: Altitude code**
**DF5 / DF21: Identity code (squawk code)**
Resources
-----------
@ -55,10 +57,10 @@ Check out and contribute to this open-source project at:
https://github.com/junzis/pyModeS
Detailed manual on Mode-S decoding is published at:
https://mode-s.org/decode.
https://mode-s.org/decode
The API documentation of pyModeS is at:
http://pymodes.readthedocs.io
https://mode-s.org/api

View File

@ -17,5 +17,5 @@ help:
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
rm -f source/pyModeS*.rst source/modules.rst
sphinx-apidoc -f -e -M -o source/ ../pyModeS
sphinx-apidoc -f -e -M -o source/ ../pyModeS ../pyModeS/decoder/ehs.py ../pyModeS/decoder/els.py ../pyModeS/streamer ../pyModeS/extra
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

View File

@ -0,0 +1,17 @@
{% extends "!layout.html" %}
{% block footer %}
{{ super() }}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-74700456-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-74700456-1');
</script>
{% endblock %}

View File

@ -14,19 +14,20 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath("../.."))
# -- Project information -----------------------------------------------------
project = 'pyModeS'
copyright = '2019, Junzi Sun'
author = 'Junzi Sun'
project = "pyModeS"
copyright = "2019, Junzi Sun"
author = "Junzi Sun"
# The short X.Y version
version = ''
version = ""
# The full version, including alpha/beta/rc tags
release = ''
release = ""
# -- General configuration ---------------------------------------------------
@ -39,26 +40,24 @@ release = ''
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
'sphinx.ext.napoleon',
"sphinx.ext.autodoc",
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
"sphinx.ext.githubpages",
"sphinx.ext.napoleon",
]
# Add any paths that contain templates here, relative to this directory.
# templates_path = ['']
templates_path = ["_templates"]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"
# The master toctree document.
master_doc = 'index'
master_doc = "index"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@ -82,6 +81,10 @@ pygments_style = None
# a list of builtin themes.
#
# html_theme = 'alabaster'
html_theme = "neo_rtd_theme"
import sphinx_theme
html_theme_path = [sphinx_theme.get_html_theme_path()]
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
@ -108,7 +111,7 @@ pygments_style = None
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'pyModeSdoc'
htmlhelp_basename = "pyModeSdoc"
# -- Options for LaTeX output ------------------------------------------------
@ -117,15 +120,12 @@ latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
@ -135,8 +135,7 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'pyModeS.tex', 'pyModeS Documentation',
'Junzi Sun', 'manual'),
(master_doc, "pyModeS.tex", "pyModeS Documentation", "Junzi Sun", "manual")
]
@ -144,10 +143,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'pymodes', 'pyModeS Documentation',
[author], 1)
]
man_pages = [(master_doc, "pymodes", "pyModeS Documentation", [author], 1)]
# -- Options for Texinfo output ----------------------------------------------
@ -156,9 +152,15 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'pyModeS', 'pyModeS Documentation',
author, 'pyModeS', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"pyModeS",
"pyModeS Documentation",
author,
"pyModeS",
"One line description of project.",
"Miscellaneous",
)
]
@ -177,7 +179,7 @@ epub_title = project
# epub_uid = ''
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
epub_exclude_files = ["search.html"]
# -- Extension configuration -------------------------------------------------

View File

@ -9,11 +9,49 @@ Welcome to pyModeS documentation!
The source code can be found at: https://github.com/junzis/pyModeS
.. toctree::
:maxdepth: 3
:caption: Core modules
:maxdepth: 2
pyModeS.decoder.adsb
pyModeS.decoder.commb
.. toctree::
:caption: ADS-B messages
:maxdepth: 2
pyModeS.decoder.bds.bds05
pyModeS.decoder.bds.bds06
pyModeS.decoder.bds.bds08
pyModeS.decoder.bds.bds09
.. toctree::
:caption: ELS - elementary surveillance
:maxdepth: 2
pyModeS.decoder.bds.bds10
pyModeS.decoder.bds.bds17
pyModeS.decoder.bds.bds20
pyModeS.decoder.bds.bds30
.. toctree::
:caption: EHS - enhanced surveillance
:maxdepth: 2
pyModeS.decoder.bds.bds40
pyModeS.decoder.bds.bds50
pyModeS.decoder.bds.bds60
.. toctree::
:caption: MRAR / MHR
:maxdepth: 2
pyModeS.decoder.bds.bds44
pyModeS.decoder.bds.bds45
pyModeS.decoder
pyModeS.streamer
pyModeS.extra
----

View File

@ -1,35 +0,0 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
:end
popd

View File

@ -0,0 +1,7 @@
pyModeS.c\_common module
========================
.. automodule:: pyModeS.c_common
:members:
:undoc-members:
:show-inheritance:

View File

@ -0,0 +1,7 @@
pyModeS.common module
=====================
.. automodule:: pyModeS.common
:members:
:undoc-members:
:show-inheritance:

View File

@ -10,6 +10,7 @@ Submodules
----------
.. toctree::
:maxdepth: 4
pyModeS.decoder.bds.bds05
pyModeS.decoder.bds.bds06
@ -25,4 +26,3 @@ Submodules
pyModeS.decoder.bds.bds50
pyModeS.decoder.bds.bds53
pyModeS.decoder.bds.bds60

View File

@ -1,7 +0,0 @@
pyModeS.decoder.common module
=============================
.. automodule:: pyModeS.decoder.common
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,7 +0,0 @@
pyModeS.decoder.ehs module
==========================
.. automodule:: pyModeS.decoder.ehs
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,7 +0,0 @@
pyModeS.decoder.els module
==========================
.. automodule:: pyModeS.decoder.els
:members:
:undoc-members:
:show-inheritance:

View File

@ -10,6 +10,7 @@ Subpackages
-----------
.. toctree::
:maxdepth: 4
pyModeS.decoder.bds
@ -17,14 +18,12 @@ Submodules
----------
.. toctree::
:maxdepth: 4
pyModeS.decoder.acas
pyModeS.decoder.adsb
pyModeS.decoder.allcall
pyModeS.decoder.commb
pyModeS.decoder.common
pyModeS.decoder.ehs
pyModeS.decoder.els
pyModeS.decoder.surv
pyModeS.decoder.uncertainty
pyModeS.decoder.uplink

View File

@ -0,0 +1,7 @@
pyModeS.decoder.uplink module
=============================
.. automodule:: pyModeS.decoder.uplink
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,7 +0,0 @@
pyModeS.extra.aero module
=========================
.. automodule:: pyModeS.extra.aero
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,16 +0,0 @@
pyModeS.extra package
=====================
.. automodule:: pyModeS.extra
:members:
:undoc-members:
:show-inheritance:
Submodules
----------
.. toctree::
pyModeS.extra.aero
pyModeS.extra.tcpclient

View File

@ -1,7 +0,0 @@
pyModeS.extra.tcpclient module
==============================
.. automodule:: pyModeS.extra.tcpclient
:members:
:undoc-members:
:show-inheritance:

View File

@ -10,8 +10,15 @@ Subpackages
-----------
.. toctree::
:maxdepth: 4
pyModeS.decoder
pyModeS.extra
pyModeS.streamer
Submodules
----------
.. toctree::
:maxdepth: 4
pyModeS.c_common
pyModeS.common

View File

@ -1,16 +0,0 @@
pyModeS.streamer package
========================
.. automodule:: pyModeS.streamer
:members:
:undoc-members:
:show-inheritance:
Submodules
----------
.. toctree::
pyModeS.streamer.screen
pyModeS.streamer.stream

View File

@ -1,7 +0,0 @@
pyModeS.streamer.screen module
==============================
.. automodule:: pyModeS.streamer.screen
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,7 +0,0 @@
pyModeS.streamer.stream module
==============================
.. automodule:: pyModeS.streamer.stream
:members:
:undoc-members:
:show-inheritance:

0
doc/warnings Normal file
View File

View File

@ -15,8 +15,6 @@ from .decoder import bds
from .extra import aero
from .extra import tcpclient
from .encoder import encode_adsb
warnings.simplefilter("once", DeprecationWarning)

View File

@ -1,15 +1,11 @@
"""ADS-B Wrapper.
"""ADS-B module.
The ADS-B wrapper also imports functions from the following modules:
The ADS-B module also imports functions from the following modules:
- pyModeS.decoder.bds.bds05
Functions: ``airborne_position``, ``airborne_position_with_ref``, ``altitude``
- pyModeS.decoder.bds.bds06
Functions: ``surface_position``, ``surface_position_with_ref``, ``surface_velocity``
- pyModeS.decoder.bds.bds08
Functions: ``category``, ``callsign``
- pyModeS.decoder.bds.bds09
Functions: ``airborne_velocity``, ``altitude_diff``
- pyModeS.decoder.bds.bds05: ``airborne_position()``, ``airborne_position_with_ref()``, ``altitude()``
- pyModeS.decoder.bds.bds06: ``surface_position()``, ``surface_position_with_ref()``, ``surface_velocity()``
- pyModeS.decoder.bds.bds08: ``category()``, ``callsign()``
- pyModeS.decoder.bds.bds09: ``airborne_velocity()``, ``altitude_diff()``
"""
@ -47,27 +43,32 @@ 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 surface or airborne position from a pair of even and odd
position messages.
Note, that to decode surface position using the position message pair,
the reference position has to be provided.
Args:
msg0 (string): even message (28 hexdigits)
msg1 (string): odd message (28 hexdigits)
t0 (int): timestamps for the even message
t1 (int): timestamps for the odd message
lat_ref (float): latitude of reference position
lon_ref (float): longitude of reference position
Returns:
(float, float): (latitude, longitude) of the aircraft
"""
tc0 = typecode(msg0)
tc1 = typecode(msg1)
if 5 <= tc0 <= 8 and 5 <= tc1 <= 8:
if (not lat_ref) or (not lon_ref):
if lat_ref is None or lon_ref is None:
raise RuntimeError(
"Surface position encountered, a reference \
position lat/lon required. Location of \
receiver can be used."
"Surface position encountered, a reference position"
" lat/lon required. Location of receiver can be used."
)
else:
return surface_position(msg0, msg1, t0, t1, lat_ref, lon_ref)
@ -81,19 +82,20 @@ def position(msg0, msg1, t0, t1, lat_ref=None, lon_ref=None):
return airborne_position(msg0, msg1, t0, t1)
else:
raise RuntimeError("incorrect or inconsistent message types")
raise RuntimeError("Incorrect or inconsistent message types")
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 +116,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 +139,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).
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.
In the case of surface messages, None will be put in place
for vertical rate and its respective sources.
"""
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 +176,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 +188,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 +200,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 +222,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 +258,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 +287,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 +321,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 +359,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 +381,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 +404,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 +426,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 +461,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 +490,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

View File

@ -45,7 +45,7 @@ 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
msg (str): 28 hexdigits 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 altitude), ft
@ -108,7 +108,7 @@ def infer(msg, mrar=False):
"""Estimate the most likely BDS code of an message.
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
mrar (bool): Also infer MRAR (BDS 44) and MHR (BDS 45). Defaults to False.
Returns:

View File

@ -85,7 +85,7 @@ def airborne_position_with_ref(msg, lat_ref, lon_ref):
be with in 180NM 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
@ -127,7 +127,7 @@ def altitude(msg):
"""Decode aircraft altitude
Args:
msg (string): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
int: altitude in feet

View File

@ -1,7 +1,7 @@
# ------------------------------------------
# BDS 0,6
# ADS-B TC=5-8
# Surface position
# Surface movment
# ------------------------------------------
from pyModeS import common
@ -89,7 +89,7 @@ def surface_position_with_ref(msg, lat_ref, lon_ref):
be with in 45NM 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
@ -127,23 +127,24 @@ def surface_position_with_ref(msg, lat_ref, lon_ref):
return round(lat, 5), round(lon, 5)
def surface_velocity(msg, rtn_sources=False):
"""Decode surface velocity from from a surface position message
def surface_velocity(msg, source=False):
"""Decode surface velocity from a surface position 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, None): speed (kt),
ground track (degree), None for rate of climb/descend (ft/min),
and speed type ('GS' for ground speed), direction source
('true_north' for ground track / true north as reference),
None rate of climb/descent source.
"""
int, float, int, string, [string], [string]: Four or six parameters, including:
- Speed (kt)
- Angle (degree), ground track
- Vertical rate, always 0
- Speed type ('GS' for ground speed, 'AS' for airspeed)
- [Optional] Direction source ('TRUE_NORTH')
- [Optional] Vertical rate source (None)
"""
if common.typecode(msg) < 5 or common.typecode(msg) > 8:
raise RuntimeError("%s: Not a surface message, expecting 5<TC<8" % msg)
@ -174,7 +175,7 @@ def surface_velocity(msg, rtn_sources=False):
spd = kts[i - 1] + (mov - movs[i - 1]) * step
spd = round(spd, 2)
if rtn_sources:
return spd, trk, 0, "GS", "true_north", None
if source:
return spd, trk, 0, "GS", "TRUE_NORTH", None
else:
return spd, trk, 0, "GS"

View File

@ -11,7 +11,7 @@ def category(msg):
"""Aircraft category number
Args:
msg (string): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
int: category number
@ -29,7 +29,7 @@ def callsign(msg):
"""Aircraft callsign
Args:
msg (string): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
string: callsign

View File

@ -10,27 +10,24 @@ from pyModeS import common
import math
def airborne_velocity(msg, rtn_sources=False):
"""Calculate the speed, track (or heading), and vertical rate
def airborne_velocity(msg, source=False):
"""Decode airborne velocity.
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).
"""
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')
"""
if common.typecode(msg) != 19:
raise RuntimeError("%s: Not a airborne velocity message, expecting TC=19" % msg)
@ -62,9 +59,9 @@ def airborne_velocity(msg, rtn_sources=False):
trk = math.degrees(trk) # convert to degrees
trk = trk if trk >= 0 else trk + 360 # no negative val
tag = "GS"
spd_type = "GS"
trk_or_hdg = round(trk, 2)
dir_type = "true_north"
dir_type = "TRUE_NORTH"
else:
if mb[13] == "0":
@ -81,32 +78,33 @@ def airborne_velocity(msg, rtn_sources=False):
spd *= 4
if mb[24] == "0":
tag = "IAS"
spd_type = "IAS"
else:
tag = "TAS"
spd_type = "TAS"
dir_type = "mag_north"
dir_type = "MAGENTIC_NORTH"
vr_source = "GNSS" if mb[35] == "0" else "Baro"
vr_source = "GNSS" if mb[35] == "0" else "BARO"
vr_sign = -1 if mb[36] == "1" else 1
vr = common.bin2int(mb[37:46])
rocd = None if vr == 0 else int(vr_sign * (vr - 1) * 64)
vs = None if vr == 0 else int(vr_sign * (vr - 1) * 64)
if rtn_sources:
return spd, trk_or_hdg, rocd, tag, dir_type, vr_source
if source:
return spd, trk_or_hdg, vs, spd_type, dir_type, vr_source
else:
return spd, trk_or_hdg, rocd, tag
return spd, trk_or_hdg, vs, spd_type
def altitude_diff(msg):
"""Decode the differece between GNSS and barometric altitude
"""Decode the differece between GNSS and barometric altitude.
Args:
msg (string): 28 bytes hexadecimal message string, TC=19
msg (str): 28 hexdigits string, TC=19
Returns:
int: Altitude difference in ft. Negative value indicates GNSS altitude
int: Altitude difference in feet. Negative value indicates GNSS altitude
below barometric altitude.
"""
tc = common.typecode(msg)

View File

@ -10,7 +10,7 @@ def is10(msg):
"""Check if a message is likely to be BDS code 1,0
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
bool: True or False
@ -42,7 +42,7 @@ def ovc10(msg):
"""Return the overlay control capability
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
int: Whether the transponder is OVC capable

View File

@ -10,7 +10,7 @@ def is17(msg):
"""Check if a message is likely to be BDS code 1,7
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
bool: True or False
@ -42,7 +42,7 @@ def cap17(msg):
"""Extract capacities from BDS 1,7 message
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
list: list of support BDS codes

View File

@ -10,7 +10,7 @@ def is20(msg):
"""Check if a message is likely to be BDS code 2,0
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
bool: True or False
@ -36,7 +36,7 @@ def cs20(msg):
"""Aircraft callsign
Args:
msg (String): 28 bytes hexadecimal message (BDS40) string
msg (str): 28 hexdigits string
Returns:
string: callsign, max. 8 chars

View File

@ -10,7 +10,7 @@ def is30(msg):
"""Check if a message is likely to be BDS code 2,0
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
bool: True or False

View File

@ -11,7 +11,7 @@ def is40(msg):
"""Check if a message is likely to be BDS code 4,0
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
bool: True or False
@ -54,7 +54,7 @@ def selalt40mcp(msg):
"""Selected altitude, MCP/FCU
Args:
msg (String): 28 bytes hexadecimal message (BDS40) string
msg (str): 28 hexdigits string
Returns:
int: altitude in feet
@ -72,7 +72,7 @@ def selalt40fms(msg):
"""Selected altitude, FMS
Args:
msg (String): 28 bytes hexadecimal message (BDS40) string
msg (str): 28 hexdigits string
Returns:
int: altitude in feet
@ -90,7 +90,7 @@ def p40baro(msg):
"""Barometric pressure setting
Args:
msg (String): 28 bytes hexadecimal message (BDS40) string
msg (str): 28 hexdigits string
Returns:
float: pressure in millibar

View File

@ -12,7 +12,7 @@ def is44(msg):
Meteorological routine air report
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
bool: True or False
@ -55,7 +55,7 @@ def wind44(msg):
"""Wind speed and direction.
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
(int, float): speed (kt), direction (degree)
@ -77,7 +77,7 @@ def temp44(msg):
"""Static air temperature.
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
float, float: temperature and alternative temperature in Celsius degree.
@ -106,7 +106,7 @@ def p44(msg):
"""Static pressure.
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
int: static pressure in hPa
@ -126,7 +126,7 @@ def hum44(msg):
"""humidity
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
float: percentage of humidity, [0 - 100] %
@ -145,7 +145,7 @@ def turb44(msg):
"""Turblence.
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
int: turbulence level. 0=NIL, 1=Light, 2=Moderate, 3=Severe

View File

@ -12,7 +12,7 @@ def is45(msg):
Meteorological hazard report
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
bool: True or False
@ -64,7 +64,7 @@ def turb45(msg):
"""Turbulence.
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
int: Turbulence level. 0=NIL, 1=Light, 2=Moderate, 3=Severe
@ -82,7 +82,7 @@ def ws45(msg):
"""Wind shear.
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
int: Wind shear level. 0=NIL, 1=Light, 2=Moderate, 3=Severe
@ -100,7 +100,7 @@ def mb45(msg):
"""Microburst.
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
int: Microburst level. 0=NIL, 1=Light, 2=Moderate, 3=Severe
@ -118,7 +118,7 @@ def ic45(msg):
"""Icing.
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
int: Icing level. 0=NIL, 1=Light, 2=Moderate, 3=Severe
@ -136,7 +136,7 @@ def wv45(msg):
"""Wake vortex.
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
int: Wake vortex level. 0=NIL, 1=Light, 2=Moderate, 3=Severe
@ -154,7 +154,7 @@ def temp45(msg):
"""Static air temperature.
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
float: tmeperature in Celsius degree
@ -178,7 +178,7 @@ def p45(msg):
"""Average static pressure.
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
int: static pressure in hPa
@ -195,7 +195,7 @@ def rh45(msg):
"""Radio height.
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
int: radio height in ft

View File

@ -11,7 +11,7 @@ def is50(msg):
(Track and turn report)
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
bool: True or False
@ -61,7 +61,7 @@ def roll50(msg):
"""Roll angle, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
msg (str): 28 hexdigits string
Returns:
float: angle in degrees,
@ -86,7 +86,7 @@ def trk50(msg):
"""True track angle, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
msg (str): 28 hexdigits string
Returns:
float: angle in degrees to true north (from 0 to 360)
@ -115,7 +115,7 @@ def gs50(msg):
"""Ground speed, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
msg (str): 28 hexdigits string
Returns:
int: ground speed in knots
@ -133,7 +133,7 @@ def rtrk50(msg):
"""Track angle rate, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
msg (str): 28 hexdigits string
Returns:
float: angle rate in degrees/second
@ -159,7 +159,7 @@ def tas50(msg):
"""Aircraft true airspeed, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
msg (str): 28 hexdigits string
Returns:
int: true airspeed in knots

View File

@ -11,7 +11,7 @@ def is53(msg):
(Air-referenced state vector)
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
bool: True or False
@ -62,7 +62,7 @@ def hdg53(msg):
"""Magnetic heading, BDS 5,3 message
Args:
msg (String): 28 bytes hexadecimal message (BDS53) string
msg (str): 28 hexdigits string
Returns:
float: angle in degrees to true north (from 0 to 360)
@ -91,7 +91,7 @@ def ias53(msg):
"""Indicated airspeed, DBS 5,3 message
Args:
msg (String): 28 bytes hexadecimal message
msg (str): 28 hexdigits
Returns:
int: indicated arispeed in knots
@ -109,7 +109,7 @@ def mach53(msg):
"""MACH number, DBS 5,3 message
Args:
msg (String): 28 bytes hexadecimal message
msg (str): 28 hexdigits
Returns:
float: MACH number
@ -127,7 +127,7 @@ def tas53(msg):
"""Aircraft true airspeed, BDS 5,3 message
Args:
msg (String): 28 bytes hexadecimal message
msg (str): 28 hexdigits
Returns:
float: true airspeed in knots
@ -145,7 +145,7 @@ def vr53(msg):
"""Vertical rate
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string
msg (str): 28 hexdigits (BDS60) string
Returns:
int: vertical rate in feet/minutes

View File

@ -10,7 +10,7 @@ def is60(msg):
"""Check if a message is likely to be BDS code 6,0
Args:
msg (String): 28 bytes hexadecimal message string
msg (str): 28 hexdigits string
Returns:
bool: True or False
@ -61,7 +61,7 @@ def hdg60(msg):
"""Megnetic heading of aircraft
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string
msg (str): 28 hexdigits string
Returns:
float: heading in degrees to megnetic north (from 0 to 360)
@ -90,7 +90,7 @@ def ias60(msg):
"""Indicated airspeed
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string
msg (str): 28 hexdigits string
Returns:
int: indicated airspeed in knots
@ -108,7 +108,7 @@ def mach60(msg):
"""Aircraft MACH number
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string
msg (str): 28 hexdigits string
Returns:
float: MACH number
@ -126,7 +126,7 @@ def vr60baro(msg):
"""Vertical rate from barometric measurement, this value may be very noisy.
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string
msg (str): 28 hexdigits string
Returns:
int: vertical rate in feet/minutes
@ -152,7 +152,7 @@ def vr60ins(msg):
"""Vertical rate measurd by onbard equiments (IRS, AHRS)
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string
msg (str): 28 hexdigits string
Returns:
int: vertical rate in feet/minutes

View File

@ -1,19 +1,22 @@
"""Comm-B Wrapper.
"""Comm-B module.
The Comm-B wrapper imports all functions from the following modules:
The Comm-B module imports all functions from the following modules:
ELS - elementary surveillance
**ELS - elementary surveillance**
- pyModeS.decoder.bds.bds10
- pyModeS.decoder.bds.bds17
- pyModeS.decoder.bds.bds20
- pyModeS.decoder.bds.bds30
**EHS - enhanced surveillance**
EHS - enhanced surveillance
- pyModeS.decoder.bds.bds40
- pyModeS.decoder.bds.bds50
- pyModeS.decoder.bds.bds60
**MRAR and MHR**
MRAR and MHR
- pyModeS.decoder.bds.bds44
- pyModeS.decoder.bds.bds45