{"id":13650309,"url":"https://github.com/junzis/pyModeS","last_synced_at":"2025-04-22T18:31:13.695Z","repository":{"id":28882350,"uuid":"32406884","full_name":"junzis/pyModeS","owner":"junzis","description":"Python decoder for Mode S and ADS-B signals","archived":false,"fork":false,"pushed_at":"2025-03-19T23:40:07.000Z","size":1109,"stargazers_count":577,"open_issues_count":22,"forks_count":161,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-04-11T04:13:02.137Z","etag":null,"topics":["ads-b","adsb","aircraft","ehs","mode-s","python","tracking"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/junzis.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-03-17T16:49:21.000Z","updated_at":"2025-04-08T11:42:14.000Z","dependencies_parsed_at":"2023-02-11T03:30:32.649Z","dependency_job_id":"be671362-1a70-4ce5-ad67-f5763f9b9814","html_url":"https://github.com/junzis/pyModeS","commit_stats":{"total_commits":378,"total_committers":42,"mean_commits":9.0,"dds":0.5687830687830688,"last_synced_commit":"b4be55116c8d41c7935467e8dd997712d69d707a"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junzis%2FpyModeS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junzis%2FpyModeS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junzis%2FpyModeS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junzis%2FpyModeS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/junzis","download_url":"https://codeload.github.com/junzis/pyModeS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250297268,"owners_count":21407182,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ads-b","adsb","aircraft","ehs","mode-s","python","tracking"],"created_at":"2024-08-02T02:00:35.745Z","updated_at":"2025-04-22T18:31:13.678Z","avatar_url":"https://github.com/junzis.png","language":"Python","readme":"The Python ADS-B/Mode-S Decoder\n===============================\n\nPyModeS is a Python library designed to decode Mode-S (including ADS-B) messages. It can be imported to your python project or used as a standalone tool to view and save live traffic data.\n\nThis is a project created by Junzi Sun, who works at `TU Delft \u003chttps://www.tudelft.nl/en/\u003e`_, `Aerospace Engineering Faculty \u003chttps://www.tudelft.nl/en/ae/\u003e`_, `CNS/ATM research group \u003chttp://cs.lr.tudelft.nl/atm/\u003e`_. It is supported by many `contributors \u003chttps://github.com/junzis/pyModeS/graphs/contributors\u003e`_ from different institutions.\n\nIntroduction\n------------\n\npyModeS supports the decoding of following types of messages:\n\n- DF4 / DF20: Altitude code\n- DF5 / DF21: Identity code (squawk code)\n\n- DF17 / DF18: Automatic Dependent Surveillance-Broadcast (ADS-B)\n\n  - TC=1-4  / BDS 0,8: Aircraft identification and category\n  - TC=5-8  / BDS 0,6: Surface position\n  - TC=9-18 / BDS 0,5: Airborne position\n  - TC=19   / BDS 0,9: Airborne velocity\n  - TC=28   / BDS 6,1: Airborne status [to be implemented]\n  - TC=29   / BDS 6,2: Target state and status information [to be implemented]\n  - TC=31   / BDS 6,5: Aircraft operational status [to be implemented]\n\n- DF20 / DF21: Mode-S Comm-B messages\n\n  - BDS 1,0: Data link capability report\n  - BDS 1,7: Common usage GICB capability report\n  - BDS 2,0: Aircraft identification\n  - BDS 3,0: ACAS active resolution advisory\n  - BDS 4,0: Selected vertical intention\n  - BDS 4,4: Meteorological routine air report (experimental)\n  - BDS 4,5: Meteorological hazard report (experimental)\n  - BDS 5,0: Track and turn report\n  - BDS 6,0: Heading and speed report\n\n\n\nIf you find this project useful for your research, please considering cite this tool as::\n\n  @article{sun2019pymodes,\n      author={J. {Sun} and H. {V\\^u} and J. {Ellerbroek} and J. M. {Hoekstra}},\n      journal={IEEE Transactions on Intelligent Transportation Systems},\n      title={pyModeS: Decoding Mode-S Surveillance Data for Open Air Transportation Research},\n      year={2019},\n      doi={10.1109/TITS.2019.2914770},\n      ISSN={1524-9050},\n  }\n\n\n\n\nResources\n-----------\nCheck out and contribute to this open-source project at:\nhttps://github.com/junzis/pyModeS\n\nDetailed manual on Mode-S decoding is published at:\nhttps://mode-s.org/decode\n\nThe API documentation of pyModeS is at:\nhttps://mode-s.org/api\n\n\n\nBasic installation\n-------------------\n\nInstallation examples::\n\n  # stable version\n  pip install pyModeS\n\n  # conda (compiled) version\n  conda install -c conda-forge pymodes\n\n  # development version\n  pip install git+https://github.com/junzis/pyModeS\n\n\nDependencies ``numpy``, and ``pyzmq`` are installed automatically during previous installations processes. \n\nIf you need to connect pyModeS to a RTL-SDR receiver, ``pyrtlsdr`` need to be installed manually::\n\n  pip install pyrtlsdr\n\n\nAdvanced installation (using c modules)\n------------------------------------------\n\nIf you want to make use of the (faster) c module, install ``pyModeS`` as follows::\n\n  # conda (compiled) version\n  conda install -c conda-forge pymodes\n\n  # stable version\n  pip install pyModeS\n\n  # development version\n  git clone https://github.com/junzis/pyModeS\n  cd pyModeS\n  poetry install -E rtlsdr\n\n\nView live traffic (modeslive)\n----------------------------------------------------\n\nGeneral usage::\n\n  $ modeslive [-h] --source SOURCE [--connect SERVER PORT DATAYPE]\n              [--latlon LAT LON] [--show-uncertainty] [--dumpto DUMPTO]\n\n  arguments:\n   -h, --help            show this help message and exit\n   --source SOURCE       Choose data source, \"rtlsdr\" or \"net\"\n   --connect SERVER PORT DATATYPE\n                         Define server, port and data type. Supported data\n                         types are: ['raw', 'beast', 'skysense']\n   --latlon LAT LON      Receiver latitude and longitude, needed for the surface\n                         position, default none\n   --show-uncertainty    Display uncertainty values, default off\n   --dumpto DUMPTO       Folder to dump decoded output, default none\n\n\nLive with RTL-SDR\n*******************\n\nIf you have an RTL-SDR receiver connected to your computer, you can use the ``rtlsdr`` source switch (require ``pyrtlsdr`` package), with command::\n\n  $ modeslive --source rtlsdr\n\n\nLive with network data\n***************************\n\nIf you want to connect to a TCP server that broadcast raw data. use can use ``net`` source switch, for example::\n\n  $ modeslive --source net --connect localhost 30002 raw\n  $ modeslive --source net --connect 127.0.0.1 30005 beast\n\n\n\nExample screenshot:\n\n.. image:: https://github.com/junzis/pyModeS/raw/master/doc/modeslive-screenshot.png\n   :width: 700px\n\n\nUse the library\n---------------\n\n.. code:: python\n\n  import pyModeS as pms\n\n\nCommon functions\n*****************\n\n.. code:: python\n\n  pms.df(msg)                 # Downlink Format\n  pms.icao(msg)               # Infer the ICAO address from the message\n  pms.crc(msg, encode=False)  # Perform CRC or generate parity bit\n\n  pms.hex2bin(str)      # Convert hexadecimal string to binary string\n  pms.bin2int(str)      # Convert binary string to integer\n  pms.hex2int(str)      # Convert hexadecimal string to integer\n  pms.gray2int(str)     # Convert grey code to integer\n\n\nCore functions for ADS-B decoding\n*********************************\n\n.. code:: python\n\n  pms.adsb.icao(msg)\n  pms.adsb.typecode(msg)\n\n  # Typecode 1-4\n  pms.adsb.callsign(msg)\n\n  # Typecode 5-8 (surface), 9-18 (airborne, barometric height), and 20-22 (airborne, GNSS height)\n  pms.adsb.position(msg_even, msg_odd, t_even, t_odd, lat_ref=None, lon_ref=None)\n  pms.adsb.airborne_position(msg_even, msg_odd, t_even, t_odd)\n  pms.adsb.surface_position(msg_even, msg_odd, t_even, t_odd, lat_ref, lon_ref)\n  pms.adsb.surface_velocity(msg)\n\n  pms.adsb.position_with_ref(msg, lat_ref, lon_ref)\n  pms.adsb.airborne_position_with_ref(msg, lat_ref, lon_ref)\n  pms.adsb.surface_position_with_ref(msg, lat_ref, lon_ref)\n\n  pms.adsb.altitude(msg)\n\n  # Typecode: 19\n  pms.adsb.velocity(msg)          # Handles both surface \u0026 airborne messages\n  pms.adsb.speed_heading(msg)     # Handles both surface \u0026 airborne messages\n  pms.adsb.airborne_velocity(msg)\n\n\nNote: When you have a fix position of the aircraft, it is convenient to use `position_with_ref()` method to decode with only one position message (either odd or even). This works with both airborne and surface position messages. But the reference position shall be within 180NM (airborne) or 45NM (surface) of the true position.\n\n\nDecode altitude replies in DF4 / DF20\n**************************************\n.. code:: python\n\n  pms.common.altcode(msg)   # Downlink format must be 4 or 20\n\n\nDecode identity replies in DF5 / DF21\n**************************************\n.. code:: python\n\n  pms.common.idcode(msg)   # Downlink format must be 5 or 21\n\n\n\nCommon Mode-S functions\n************************\n\n.. code:: python\n\n  pms.icao(msg)           # Infer the ICAO address from the message\n  pms.bds.infer(msg)      # Infer the Modes-S BDS register\n\n  # Check if BDS is 5,0 or 6,0, give reference speed, track, altitude (from ADS-B)\n  pms.bds.is50or60(msg, spd_ref, trk_ref, alt_ref)\n\n  # Check each BDS explicitly\n  pms.bds.bds10.is10(msg)\n  pms.bds.bds17.is17(msg)\n  pms.bds.bds20.is20(msg)\n  pms.bds.bds30.is30(msg)\n  pms.bds.bds40.is40(msg)\n  pms.bds.bds44.is44(msg)\n  pms.bds.bds50.is50(msg)\n  pms.bds.bds60.is60(msg)\n\n\n\nMode-S Elementary Surveillance (ELS)\n*************************************\n\n.. code:: python\n\n  pms.commb.ovc10(msg)      # Overlay capability, BDS 1,0\n  pms.commb.cap17(msg)      # GICB capability, BDS 1,7\n  pms.commb.cs20(msg)       # Callsign, BDS 2,0\n\n\nMode-S Enhanced Surveillance (EHS)\n***********************************\n\n.. code:: python\n\n  # BDS 4,0\n  pms.commb.selalt40mcp(msg)   # MCP/FCU selected altitude (ft)\n  pms.commb.selalt40fms(msg)   # FMS selected altitude (ft)\n  pms.commb.p40baro(msg)    # Barometric pressure (mb)\n\n  # BDS 5,0\n  pms.commb.roll50(msg)     # Roll angle (deg)\n  pms.commb.trk50(msg)      # True track angle (deg)\n  pms.commb.gs50(msg)       # Ground speed (kt)\n  pms.commb.rtrk50(msg)     # Track angle rate (deg/sec)\n  pms.commb.tas50(msg)      # True airspeed (kt)\n\n  # BDS 6,0\n  pms.commb.hdg60(msg)      # Magnetic heading (deg)\n  pms.commb.ias60(msg)      # Indicated airspeed (kt)\n  pms.commb.mach60(msg)     # Mach number (-)\n  pms.commb.vr60baro(msg)   # Barometric altitude rate (ft/min)\n  pms.commb.vr60ins(msg)    # Inertial vertical speed (ft/min)\n\n\nMeteorological reports [Experimental]\n**************************************\n\nTo identify BDS 4,4 and 4,5 codes, you must set ``mrar`` argument to ``True`` in the ``infer()`` function:\n\n.. code:: python\n\n  pms.bds.infer(msg. mrar=True) \n\nOnce the correct MRAR and MHR messages are identified, decode them as follows:\n\n\nMeteorological routine air report (MRAR)\n+++++++++++++++++++++++++++++++++++++++++\n\n.. code:: python\n\n  # BDS 4,4\n  pms.commb.wind44(msg)     # Wind speed (kt) and direction (true) (deg)\n  pms.commb.temp44(msg)     # Static air temperature (C)\n  pms.commb.p44(msg)        # Average static pressure (hPa)\n  pms.commb.hum44(msg)      # Humidity (%)\n\n\nMeteorological hazard air report (MHR)\n+++++++++++++++++++++++++++++++++++++++++\n\n.. code:: python\n\n  # BDS 4,5\n  pms.commb.turb45(msg)     # Turbulence level (0-3)\n  pms.commb.ws45(msg)       # Wind shear level (0-3)\n  pms.commb.mb45(msg)       # Microburst level (0-3)\n  pms.commb.ic45(msg)       # Icing level (0-3)\n  pms.commb.wv45(msg)       # Wake vortex level (0-3)\n  pms.commb.temp45(msg)     # Static air temperature (C)\n  pms.commb.p45(msg)        # Average static pressure (hPa)\n  pms.commb.rh45(msg)       # Radio height (ft)\n\n\n\nCustomize the streaming module\n******************************\nThe TCP client module from pyModeS can be re-used to stream and process Mode-S data as you like. You need to re-implement the ``handle_messages()`` function from the ``TcpClient`` class to write your own logic to handle the messages.\n\nHere is an example:\n\n.. code:: python\n\n  import pyModeS as pms\n  from pyModeS.extra.tcpclient import TcpClient\n\n  # define your custom class by extending the TcpClient\n  #   - implement your handle_messages() methods\n  class ADSBClient(TcpClient):\n      def __init__(self, host, port, rawtype):\n          super(ADSBClient, self).__init__(host, port, rawtype)\n\n      def handle_messages(self, messages):\n          for msg, ts in messages:\n              if len(msg) != 28:  # wrong data length\n                  continue\n\n              df = pms.df(msg)\n\n              if df != 17:  # not ADSB\n                  continue\n\n              if pms.crc(msg) !=0:  # CRC fail\n                  continue\n\n              icao = pms.adsb.icao(msg)\n              tc = pms.adsb.typecode(msg)\n\n              # TODO: write you magic code here\n              print(ts, icao, tc, msg)\n\n  # run new client, change the host, port, and rawtype if needed\n  client = ADSBClient(host='127.0.0.1', port=30005, rawtype='beast')\n  client.run()\n\n\nUnit test\n---------\n\n.. code:: bash\n\n  uv sync --dev --all-extras\n  uv run pytest\n","funding_links":[],"categories":["Software"],"sub_categories":["General"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunzis%2FpyModeS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjunzis%2FpyModeS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunzis%2FpyModeS/lists"}