Skip to main content

Ais message decoding

Project description

pyais

codecov

AIS message decoding. 100% pure Python.

General

This module contains functions to decode and parse Automatic Identification System (AIS) serial messages. For detailed information about AIS refer to the AIS standard.

Usage

Using this module is easy. If you want to parse a file, that contains AIS messages, just copy the following code and replace filename with your desired filename.

from pyais import FileReaderStream

filename = "sample.ais"

for msg in FileReaderStream(filename):
    decoded_message = msg.decode()
    ais_content = decoded_message.content

It is possible to directly convert messages into JSON.

from pyais import TCPStream

for msg in TCPStream('ais.exploratorium.edu'):
    json_data = msg.decode().to_json()

You can also parse a single message encoded as bytes or from a string:

message = NMEAMessage(b"!AIVDM,1,1,,B,15M67FC000G?ufbE`FepT@3n00Sa,0*5C")
message = NMEAMessage.from_string("!AIVDM,1,1,,B,15M67FC000G?ufbE`FepT@3n00Sa,0*5C")

See the example folder for more examples.

Performance Considerations

You may refer to the Code Review Stack Exchange question. After a some research I decided to use the bitarray module as foundation. This module uses a C extension under the hood and has a nice user interface in Python. Performance is also great. Decoding this sample with roughly 85k messages takes less than 6 seconds on my machine. For comparison, the C++ based libais module parses the same file in ~ 2 seconds.

Disclaimer

This module is a private project of mine and does not claim to be complete. I try to improve and extend it, but there may be bugs. If you find such a bug feel free to submit an issue or even better create a pull-request. :-)

Coverage

Currently this module is able to decode most message types. There are only a few exceptions. These are messages that only occur in very rare cases and that you will probably never observe. The module was able to completely decode a 4 hour stream with real-time data from San Francisco Bay Area without any errors or problems. If you find a bug or missing feature, please create an issue.

Tests

You should run all tests before you submit a new pull request to prevent regressions. Also run flake8.

Without Coverage

  • python -m unittest discover tests && flake8

With Coverage

  • pip install coverage
  • coverage run --source=pyais -m unittest discover tests && coverage report -m && flake8

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyais-1.0.0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyais-1.0.0-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file pyais-1.0.0.tar.gz.

File metadata

  • Download URL: pyais-1.0.0.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for pyais-1.0.0.tar.gz
Algorithm Hash digest
SHA256 85c365aaecb3f63fc1d1617c333ea962241f37bc50b88f21d05aebbd4982aab3
MD5 440ce1ecafd1c19481e39aad6399883f
BLAKE2b-256 87610e8b67e289874d0a6f4205ef20142dce814efbbafc021edba332f48ac647

See more details on using hashes here.

File details

Details for the file pyais-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyais-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for pyais-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f92e54cce8c101b88170eee6cca5edd1f8bb318ae0507e61e171e5e1519e541
MD5 3f68f8b6e1dfd42d7b79a9c2724b3734
BLAKE2b-256 75e9d14e588e529fef6d5da75613513e76e184dd8623251897462d5ffb74d5d0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page