# simpledali
[![PyPI](https://img.shields.io/pypi/v/simpledali)](https://pypi.org/project/simpledali/)
[![Documentation Status](https://readthedocs.org/projects/simpledali/badge/?version=latest)](https://simpledali.readthedocs.io/en/latest/?badge=latest)
Datalink in pure python.
Read the docs at [readthedocs](https://readthedocs.org/projects/simpledali/)
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](https://github.com/iris-edu/ringserver) from IRIS
for the most common datalink server instance. The public instance
at [rtserve.iris.washington.edu/](http://rtserve.iris.washington.edu/) allows access to near-realtime streaming seismic data over web sockets at [ws://rtserve.iris.washington.edu/datalink](ws://rtserve.iris.washington.edu/datalink)
For parsing for miniseed2 and
[miniseed3](http://docs.fdsn.org/projects/miniseed3/en/latest/index.html#)
see [simplemseed](https://github.com/crotwell/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](https://github.com/crotwell/simplemseed/tree/main/examples).
Raw data
{
"_id": null,
"home_page": null,
"name": "simpledali",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "datalink, fdsn, miniseed, miniseed3, sourceid",
"author": null,
"author_email": "Philip Crotwell <crotwell@seis.sc.edu>",
"download_url": "https://files.pythonhosted.org/packages/6a/ad/54ced8321674fbc65f8388a3ad4db109b6e5751015da9f82621d0fe72178/simpledali-0.8.0.tar.gz",
"platform": null,
"description": "# simpledali\n\n[![PyPI](https://img.shields.io/pypi/v/simpledali)](https://pypi.org/project/simpledali/)\n[![Documentation Status](https://readthedocs.org/projects/simpledali/badge/?version=latest)](https://simpledali.readthedocs.io/en/latest/?badge=latest)\n\nDatalink in pure python.\n\nRead the docs at [readthedocs](https://readthedocs.org/projects/simpledali/)\n\n\nDatalink 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\nhttps://iris-edu.github.io/libdali/datalink-protocol.html\n\nSee [ringserver](https://github.com/iris-edu/ringserver) from IRIS\nfor the most common datalink server instance. The public instance\nat [rtserve.iris.washington.edu/](http://rtserve.iris.washington.edu/) allows access to near-realtime streaming seismic data over web sockets at [ws://rtserve.iris.washington.edu/datalink](ws://rtserve.iris.washington.edu/datalink)\n\nFor parsing for miniseed2 and\n[miniseed3](http://docs.fdsn.org/projects/miniseed3/en/latest/index.html#)\nsee [simplemseed](https://github.com/crotwell/simplemseed), also in pure python.\n\nSupport for both regular sockets and websockets. For example:\n\n```\nimport asyncio\nimport simpledali\n\nasync def main():\n host = \"localhost\"\n port = 16000\n uri = f\"ws://{host}:{port}/datalink\"\n verbose = True\n\n programname = \"simpleDali\"\n username = \"dragrace\"\n processid = 0\n architecture = \"python\"\n\n # for regular socket (DataLinkPort)\n async with simpledali.SocketDataLink(host, port, verbose=verbose) as dali:\n serverId = await dali.id(programname, username, processid, architecture)\n print(f\"Connect to {host}:{port} via regular socket\")\n print(f\"Socket Id: {serverId.message}\")\n # for web socket (ListenPort)\n async with simpledali.WebSocketDataLink(uri, verbose=verbose) as dali:\n serverId = await dali.id(programname, username, processid, architecture)\n print(f\"Connect to {uri} via websocket\")\n print(f\"WebSocket Id: {serverId.message}\")\n\nasyncio.run(main())\n```\n\nThe 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\nvalue per line.\n\n```\ndali2jsonl --help\nusage: dali2jsonl [-h] [-v] -c CONF\n\nArchive JSON datalink packets as JSON Lines.\n\noptional arguments:\n -h, --help show this help message and exit\n -v, --verbose increase output verbosity\n -c CONF, --conf CONF Configuration as TOML\n```\n\nThe TOML configuration looks like:\n```\n[datalink]\n# datalink host, defaults to localhost\nhost='localhost'\n# datalink port, defaults to 18000\nport=15004\n# Match regular expression pattern on stream ids, ex '.*/JSON'\nmatch='.*/JSON'\n\n[jsonl]\n# JSONL Write pattern, usage similar to MSeedWrite in ringserver\nwrite='/data/scsn/www/jsonl/%n/%s/%Y/%j/%n.%s.%l.%c.%Y.%j.%H.jsonl'\n\n```\n\n# Example\n\nThere are examples of sending and receiving Datalink packets in the\n[example directory](https://github.com/crotwell/simplemseed/tree/main/examples).\n",
"bugtrack_url": null,
"license": null,
"summary": "Datalink protocol in python",
"version": "0.8.0",
"project_urls": {
"Documentation": "https://readthedocs.org",
"Homepage": "https://github.com/crotwell/simpledali",
"Issues": "https://github.com/crotwell/simpledali/issues",
"Repository": "https://github.com/crotwell/simpledali"
},
"split_keywords": [
"datalink",
" fdsn",
" miniseed",
" miniseed3",
" sourceid"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "c245f686e87cc383890be7bb959770c4e075c45db24b1a335f9f4469540ad6fc",
"md5": "7383fbb887630f4a967253a852f27d45",
"sha256": "762c61bcb9fc274df8681a269bf14db04fe2b3254929d025ca31ecf74b95a9d7"
},
"downloads": -1,
"filename": "simpledali-0.8.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7383fbb887630f4a967253a852f27d45",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 25304,
"upload_time": "2024-03-21T21:28:55",
"upload_time_iso_8601": "2024-03-21T21:28:55.102473Z",
"url": "https://files.pythonhosted.org/packages/c2/45/f686e87cc383890be7bb959770c4e075c45db24b1a335f9f4469540ad6fc/simpledali-0.8.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "6aad54ced8321674fbc65f8388a3ad4db109b6e5751015da9f82621d0fe72178",
"md5": "0b5c64ef46fcab1feca594b291512ebb",
"sha256": "1f4be2e510d2bc1be6fe293b758e1fa128a68aca1aca47961653f9fd29f139bd"
},
"downloads": -1,
"filename": "simpledali-0.8.0.tar.gz",
"has_sig": false,
"md5_digest": "0b5c64ef46fcab1feca594b291512ebb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 39779,
"upload_time": "2024-03-21T21:28:53",
"upload_time_iso_8601": "2024-03-21T21:28:53.505834Z",
"url": "https://files.pythonhosted.org/packages/6a/ad/54ced8321674fbc65f8388a3ad4db109b6e5751015da9f82621d0fe72178/simpledali-0.8.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-21 21:28:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "crotwell",
"github_project": "simpledali",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "simpledali"
}