Skip to main content

Datalink protocol in python

Project description

simpledali

PyPI Documentation Status

Datalink in pure python.

Read the docs at readthedocs

Datalink is a protocol for near-realtime transfer of seismic data, usually in miniseed, but has flexibility to carry any payload such as JSON. The Protocol is defined at https://iris-edu.github.io/libdali/datalink-protocol.html

See ringserver from IRIS for the most common datalink server instance. The public instance at rtserve.iris.washington.edu/ allows access to near-realtime streaming seismic data over web sockets at ws://rtserve.iris.washington.edu/datalink

For parsing for miniseed2 and miniseed3 see simplemseed, also in pure python.

Support for both regular sockets and websockets. For example:

import asyncio
import simpledali

async def main():
    host = "localhost"
    port = 16000
    uri = f"ws://{host}:{port}/datalink"
    verbose = True

    programname = "simpleDali"
    username = "dragrace"
    processid = 0
    architecture = "python"

    # for regular socket (DataLinkPort)
    async with simpledali.SocketDataLink(host, port, verbose=verbose) as dali:
        serverId = await dali.id(programname, username, processid, architecture)
        print(f"Connect to {host}:{port} via regular socket")
        print(f"Socket Id: {serverId.message}")
    # for web socket (ListenPort)
    async with simpledali.WebSocketDataLink(uri, verbose=verbose) as dali:
        serverId = await dali.id(programname, username, processid, architecture)
        print(f"Connect to {uri} via websocket")
        print(f"WebSocket Id: {serverId.message}")

asyncio.run(main())

The dali2jsonl script will archive '/JSON' packets as JSON Lines. This is a similar function to the MSeedWrite configuration on ringserver, but in a separate process and saves JSON packets instead of miniseed. See jsonlines.org for the file format, basically one JSON value per line.

dali2jsonl --help
usage: dali2jsonl [-h] [-v] -c CONF

Archive JSON datalink packets as JSON Lines.

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         increase output verbosity
  -c CONF, --conf CONF  Configuration as TOML

The TOML configuration looks like:

[datalink]
# datalink host, defaults to localhost
host='localhost'
# datalink port, defaults to 18000
port=15004
# Match regular expression pattern on stream ids, ex '.*/JSON'
match='.*/JSON'

[jsonl]
# JSONL Write pattern, usage similar to MSeedWrite in ringserver
write='/data/scsn/www/jsonl/%n/%s/%Y/%j/%n.%s.%l.%c.%Y.%j.%H.jsonl'

Example

There are examples of sending and receiving Datalink packets in the example directory.

Project details


Download files

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

Source Distribution

simpledali-0.8.1.tar.gz (45.3 kB view details)

Uploaded Source

Built Distribution

simpledali-0.8.1-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file simpledali-0.8.1.tar.gz.

File metadata

  • Download URL: simpledali-0.8.1.tar.gz
  • Upload date:
  • Size: 45.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for simpledali-0.8.1.tar.gz
Algorithm Hash digest
SHA256 be5a750c8ec015664f2b711196d1b4daeccc0e5eba897daa591b05754692a646
MD5 a1559afba3f9382cf7cacb0bd9a7124f
BLAKE2b-256 aed5b5da7675e122e06790ec11564a021edc07cfd635092ab834e1684936963b

See more details on using hashes here.

File details

Details for the file simpledali-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: simpledali-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for simpledali-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa724ba71ebeed4a69172752fccdff68a3a5fe18bf6f8f916d77110b1fe3bd96
MD5 8674cc1215f4e65d51a9ba4187521bbd
BLAKE2b-256 319f258f0ef236fe486ce1bb90d089f48f99f90b8c2c6f1505759dd833fd4349

See more details on using hashes here.

Supported by

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