Skip to main content

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://earthscope.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.

Note starting with ringserver version 4, the stream ids have changed from the older NSLC, network_station_location_channel to the newer FDSN style source ids. See the FDSN documentation here. The protocol, dlproto, configures which of these are used. It can be set in the constructor, but it is preferrable to call id() immediately, before any other calls, so that the server's protocol is used.

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:
        # very good idea to call id at start, both for logging on server
        # side and to get capabilities like packet size, dlproto or write ability
        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.

Metadata

Release files for simpledali 0.8.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simpledali 0.8.3
File Size Uploaded
simpledali-0.8.3.tar.gz 37.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for simpledali 0.8.3
File Interpreter ABI Platform
simpledali-0.8.3-py3-none-any.whl Python 3 none any Details

Total release size: 64.3 kB

Release files / simpledali-0.8.3.tar.gz

Download URL simpledali-0.8.3.tar.gz
Size 37.7 kB
Tags Source
SHA-256 checksum
How to use checksums
eb4d3fa9fd486753f51a1a0bfc775b31a86265869b018a0f8afb6558bd63d6b2
BLAKE2b-256 checksum
How to use checksums
ade76411a1f1762e4ad33a963cb58dff86f27cb190c4b345c3924161ae4b946a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release files / simpledali-0.8.3-py3-none-any.whl

Download URL simpledali-0.8.3-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e207ea71257efb525f1304caf252ba8062c88172dc2419be1dcdc2ed8885b395
BLAKE2b-256 checksum
How to use checksums
b6c4079758c50720b254cda3cf5b6657e93eb25553414a8bb87a1ce4f46b6666
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release history Release notifications | RSS feed

This release

0.8.3 This release

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page