# mseedlib - a Python package to read and write miniSEED formatted data
The mseedlib package allows for reading and writing of [miniSEED](https://docs.fdsn.org/projects/miniseed3)
formatted data, which is commonly used for seismological and other geophysical
time series data.
The module leverages the C-language [libmseed](https://earthscope.github.io/libmseed)
for most of the heavy data format and manipulation work.
## Installation
The [releases](https://pypi.org/project/mseedlib/) should be installed
directly from PyPI with, for example, `pip install mseedlib`.
The package does not depend on anything other than the Python standard library.
## Example usage
Working programs for a variety of use cases ca be found in the
[examples](https://github.com/EarthScope/mseedlib/tree/main/examples) directory of the repository.
Read a file and print details from each record:
```Python
from mseedlib import MS3RecordReader,TimeFormat
input_file = 'testdata-3channel-signal.mseed3'
with MS3RecordReader(input_file) as msreader:
for msr in msreader:
# Print values directly
print(f' SourceID: {msr.sourceid}, record length {msr.reclen}')
print(f' Start Time: {msr.starttime_str(timeformat=TimeFormat.ISOMONTHDAY_SPACE_Z)}')
print(f' Samples: {msr.samplecnt}')
# Alternatively, use the library print function
msr.print()
```
Read a file into a trace list and print the list:
```Python
from mseedlib import MSTraceList
input_file = 'testdata-3channel-signal.mseed3'
mstl = MSTraceList(input_file)
# Print the trace list using the library print function
mstl.print(details=1, gaps=True)
# Alternatively, traverse the data structures and print each trace ID and segment
for traceid in mstl.traceids():
print(traceid)
for segment in traceid.segments():
print(' ', segment)
```
Writing miniSEED requires specifying a "record handler" function that is
a callback to consume, and do whatever you want, with generated records.
Simple example of writing multiple channels of data:
```Python
import math
from mseedlib import MSTraceList, timestr2nstime
# Generate synthetic sinusoid data, starting at 0, 45, and 90 degrees
data0 = list(map(lambda x: int(math.sin(math.radians(x)) * 500), range(0, 500)))
data1 = list(map(lambda x: int(math.sin(math.radians(x)) * 500), range(45, 500 + 45)))
data2 = list(map(lambda x: int(math.sin(math.radians(x)) * 500), range(90, 500 + 90)))
mstl = MSTraceList()
sample_rate = 40.0
start_time = timestr2nstime("2024-01-01T15:13:55.123456789Z")
format_version = 2
record_length = 512
# Add synthetic data to the trace list
mstl.add_data(sourceid="FDSN:XX_TEST__B_S_0",
data_samples=data0, sample_type='i',
sample_rate=sample_rate, start_time=start_time)
mstl.add_data(sourceid="FDSN:XX_TEST__B_S_0",
data_samples=data1, sample_type='i',
sample_rate=sample_rate, start_time=start_time)
mstl.add_data(sourceid="FDSN:XX_TEST__B_S_0",
data_samples=data2, sample_type='i',
sample_rate=sample_rate, start_time=start_time)
# Record handler called for each generated record
def record_handler(record, handler_data):
handler_data['fh'].write(record)
output_file = 'output.mseed'
with open(output_file, 'wb') as file_handle:
# Generate miniSEED records
mstl.pack(record_handler,
{'fh':file_handle},
flush_data=True)
```
## Package design rationale
The package functionality and exposed API are designed to support the most
common use cases of reading and writing miniSEED data using `libmseed`.
Extensions of data handling beyond the functionality of the library are
out-of-scope for this package. Furthermore, the naming of functions,
classes, arguments, etc. follows the naming used in the library in order
to reference their fundamentals at the C level if needed; even though this
leaves some names distinctly non-Pythonic.
In a nutshell, the goal of this package is to provide just enough of a Python
layer to `libmseed` to handle the most common cases of miniSEED data without
needing to know any of the C-level details.
## License
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Copyright (C) 2024 Chad Trabant, EarthScope Data Services
Raw data
{
"_id": null,
"home_page": null,
"name": "mseedlib",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "data, miniseed, mseed, seismic, seismology, waveform",
"author": null,
"author_email": "EarthScope Data Services <software@earthscope.org>",
"download_url": "https://files.pythonhosted.org/packages/ba/62/7cba66383ef3a69cda24aeadc9b1af79ce1a80f4161c14f316163fd7880d/mseedlib-0.0.6.tar.gz",
"platform": null,
"description": "# mseedlib - a Python package to read and write miniSEED formatted data\n\nThe mseedlib package allows for reading and writing of [miniSEED](https://docs.fdsn.org/projects/miniseed3)\nformatted data, which is commonly used for seismological and other geophysical\ntime series data.\n\nThe module leverages the C-language [libmseed](https://earthscope.github.io/libmseed)\nfor most of the heavy data format and manipulation work.\n\n## Installation\n\nThe [releases](https://pypi.org/project/mseedlib/) should be installed\ndirectly from PyPI with, for example, `pip install mseedlib`.\nThe package does not depend on anything other than the Python standard library.\n\n## Example usage\n\nWorking programs for a variety of use cases ca be found in the\n[examples](https://github.com/EarthScope/mseedlib/tree/main/examples) directory of the repository.\n\nRead a file and print details from each record:\n```Python\nfrom mseedlib import MS3RecordReader,TimeFormat\n\ninput_file = 'testdata-3channel-signal.mseed3'\n\nwith MS3RecordReader(input_file) as msreader:\n for msr in msreader:\n # Print values directly\n print(f' SourceID: {msr.sourceid}, record length {msr.reclen}')\n print(f' Start Time: {msr.starttime_str(timeformat=TimeFormat.ISOMONTHDAY_SPACE_Z)}')\n print(f' Samples: {msr.samplecnt}')\n\n # Alternatively, use the library print function\n msr.print()\n```\n\nRead a file into a trace list and print the list:\n```Python\nfrom mseedlib import MSTraceList\n\ninput_file = 'testdata-3channel-signal.mseed3'\n\nmstl = MSTraceList(input_file)\n\n# Print the trace list using the library print function\nmstl.print(details=1, gaps=True)\n\n# Alternatively, traverse the data structures and print each trace ID and segment\nfor traceid in mstl.traceids():\n print(traceid)\n\n for segment in traceid.segments():\n print(' ', segment)\n```\n\nWriting miniSEED requires specifying a \"record handler\" function that is\na callback to consume, and do whatever you want, with generated records.\n\nSimple example of writing multiple channels of data:\n```Python\nimport math\nfrom mseedlib import MSTraceList, timestr2nstime\n\n# Generate synthetic sinusoid data, starting at 0, 45, and 90 degrees\ndata0 = list(map(lambda x: int(math.sin(math.radians(x)) * 500), range(0, 500)))\ndata1 = list(map(lambda x: int(math.sin(math.radians(x)) * 500), range(45, 500 + 45)))\ndata2 = list(map(lambda x: int(math.sin(math.radians(x)) * 500), range(90, 500 + 90)))\n\nmstl = MSTraceList()\n\nsample_rate = 40.0\nstart_time = timestr2nstime(\"2024-01-01T15:13:55.123456789Z\")\nformat_version = 2\nrecord_length = 512\n\n# Add synthetic data to the trace list\nmstl.add_data(sourceid=\"FDSN:XX_TEST__B_S_0\",\n data_samples=data0, sample_type='i',\n sample_rate=sample_rate, start_time=start_time)\n\nmstl.add_data(sourceid=\"FDSN:XX_TEST__B_S_0\",\n data_samples=data1, sample_type='i',\n sample_rate=sample_rate, start_time=start_time)\n\nmstl.add_data(sourceid=\"FDSN:XX_TEST__B_S_0\",\n data_samples=data2, sample_type='i',\n sample_rate=sample_rate, start_time=start_time)\n\n# Record handler called for each generated record\ndef record_handler(record, handler_data):\n handler_data['fh'].write(record)\n\noutput_file = 'output.mseed'\n\nwith open(output_file, 'wb') as file_handle:\n # Generate miniSEED records\n mstl.pack(record_handler,\n {'fh':file_handle},\n flush_data=True)\n```\n\n## Package design rationale\n\nThe package functionality and exposed API are designed to support the most\ncommon use cases of reading and writing miniSEED data using `libmseed`.\nExtensions of data handling beyond the functionality of the library are\nout-of-scope for this package. Furthermore, the naming of functions,\nclasses, arguments, etc. follows the naming used in the library in order\nto reference their fundamentals at the C level if needed; even though this\nleaves some names distinctly non-Pythonic.\n\nIn a nutshell, the goal of this package is to provide just enough of a Python\nlayer to `libmseed` to handle the most common cases of miniSEED data without\nneeding to know any of the C-level details.\n\n## License\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\nCopyright (C) 2024 Chad Trabant, EarthScope Data Services\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "A Python package for reading and writing miniSEED formatted data",
"version": "0.0.6",
"project_urls": {
"Homepage": "https://github.com/EarthScope/mseedlib",
"Issues": "https://github.com/EarthScope/mseedlib/issues"
},
"split_keywords": [
"data",
" miniseed",
" mseed",
" seismic",
" seismology",
" waveform"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b62f585c60f7875afd98f1aba44b7185253c08ea63fb05e211bc3c3c35efe7d7",
"md5": "2158859cb7137aa409db908e746c3572",
"sha256": "8c369786635f0de89c6790fef94dfb341ea564aaee99a956fe5fe7913f233db1"
},
"downloads": -1,
"filename": "mseedlib-0.0.6-py3-none-macosx_13_0_x86_64.whl",
"has_sig": false,
"md5_digest": "2158859cb7137aa409db908e746c3572",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 228410,
"upload_time": "2024-06-14T04:33:56",
"upload_time_iso_8601": "2024-06-14T04:33:56.187846Z",
"url": "https://files.pythonhosted.org/packages/b6/2f/585c60f7875afd98f1aba44b7185253c08ea63fb05e211bc3c3c35efe7d7/mseedlib-0.0.6-py3-none-macosx_13_0_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "203859c56c759562eff9de37cc0755f98fd44db859e6d5bdb1253312db1abffd",
"md5": "d1de610bf849cd7c164012766f389111",
"sha256": "2f3d71f45490cc89ab62ffc58972da85d7f088147670a7dee2a5a0f184a946ef"
},
"downloads": -1,
"filename": "mseedlib-0.0.6-py3-none-macosx_14_0_arm64.whl",
"has_sig": false,
"md5_digest": "d1de610bf849cd7c164012766f389111",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 209927,
"upload_time": "2024-06-14T04:33:57",
"upload_time_iso_8601": "2024-06-14T04:33:57.458000Z",
"url": "https://files.pythonhosted.org/packages/20/38/59c56c759562eff9de37cc0755f98fd44db859e6d5bdb1253312db1abffd/mseedlib-0.0.6-py3-none-macosx_14_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5ef9b601d714a7e19b726e501c49480429a0d523593ccd70d4189a91b55b58e6",
"md5": "7b846b18e484b0a23cdf892c58ec8ca2",
"sha256": "c670248496960b765ff7f371b3218dcc793474d97c86d28cdf3fbd7ca6444c98"
},
"downloads": -1,
"filename": "mseedlib-0.0.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"has_sig": false,
"md5_digest": "7b846b18e484b0a23cdf892c58ec8ca2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 241175,
"upload_time": "2024-06-14T04:33:58",
"upload_time_iso_8601": "2024-06-14T04:33:58.951888Z",
"url": "https://files.pythonhosted.org/packages/5e/f9/b601d714a7e19b726e501c49480429a0d523593ccd70d4189a91b55b58e6/mseedlib-0.0.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b140b9de8703584ab7771613f0ace139bf14697fa895196bbf37278397a3dce9",
"md5": "68f35ebeb9d966930b62029b41d809ce",
"sha256": "b7dd8a0519363366403008c56889610967f02d20780c0fd6d6152eb577afce19"
},
"downloads": -1,
"filename": "mseedlib-0.0.6-py3-none-manylinux_2_17_i686.manylinux_2_12_i686.manylinux2010_i686.manylinux2014_i686.whl",
"has_sig": false,
"md5_digest": "68f35ebeb9d966930b62029b41d809ce",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 276123,
"upload_time": "2024-06-14T04:34:00",
"upload_time_iso_8601": "2024-06-14T04:34:00.422835Z",
"url": "https://files.pythonhosted.org/packages/b1/40/b9de8703584ab7771613f0ace139bf14697fa895196bbf37278397a3dce9/mseedlib-0.0.6-py3-none-manylinux_2_17_i686.manylinux_2_12_i686.manylinux2010_i686.manylinux2014_i686.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "deec086b18cfe3593480a0bc57aa4949b1d2317bc2a10fb86b1ed67cd3148fee",
"md5": "d82c6fc674c3618a9e710164ed6a4aad",
"sha256": "2abc5f419afeb066c8c50e5054d282117675eb6846abee36d802beb381d5a0a6"
},
"downloads": -1,
"filename": "mseedlib-0.0.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "d82c6fc674c3618a9e710164ed6a4aad",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 243523,
"upload_time": "2024-06-14T04:34:01",
"upload_time_iso_8601": "2024-06-14T04:34:01.921934Z",
"url": "https://files.pythonhosted.org/packages/de/ec/086b18cfe3593480a0bc57aa4949b1d2317bc2a10fb86b1ed67cd3148fee/mseedlib-0.0.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9c116b4f1f344143bde8c86e739723c1973c1377ec446dc37d11e3d76bb1868c",
"md5": "206b12174029bedfc7c276ca8037e1d5",
"sha256": "c5e5c1a8390d3626f7742195777c880a7a9d3b7e618bfb640c6507659831c9ab"
},
"downloads": -1,
"filename": "mseedlib-0.0.6-py3-none-musllinux_1_2_aarch64.whl",
"has_sig": false,
"md5_digest": "206b12174029bedfc7c276ca8037e1d5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 248982,
"upload_time": "2024-06-14T04:34:03",
"upload_time_iso_8601": "2024-06-14T04:34:03.306027Z",
"url": "https://files.pythonhosted.org/packages/9c/11/6b4f1f344143bde8c86e739723c1973c1377ec446dc37d11e3d76bb1868c/mseedlib-0.0.6-py3-none-musllinux_1_2_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9ecafcf338b4a17237471c9a7b67dffe1e6d91138b5e2b67bb9ff3620e2dfda5",
"md5": "ffe23cda2de59a29c2cb4810493851af",
"sha256": "f8d92ea72ca98966fd76e3eff375dfaf62b4baa685bc3377940a2435889d944f"
},
"downloads": -1,
"filename": "mseedlib-0.0.6-py3-none-musllinux_1_2_i686.whl",
"has_sig": false,
"md5_digest": "ffe23cda2de59a29c2cb4810493851af",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 285197,
"upload_time": "2024-06-14T04:34:04",
"upload_time_iso_8601": "2024-06-14T04:34:04.959816Z",
"url": "https://files.pythonhosted.org/packages/9e/ca/fcf338b4a17237471c9a7b67dffe1e6d91138b5e2b67bb9ff3620e2dfda5/mseedlib-0.0.6-py3-none-musllinux_1_2_i686.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5cea661e34bcbca3441f9428d2eca66a820055260b57975da6f2ee8c9c374410",
"md5": "eaaeba8d79ee4d52003bef3424c8ff6f",
"sha256": "2e4b6c98c8bfa9e0d3a83b8a174cb92e62b90b12083da4f5f3070f8789a588e1"
},
"downloads": -1,
"filename": "mseedlib-0.0.6-py3-none-musllinux_1_2_x86_64.whl",
"has_sig": false,
"md5_digest": "eaaeba8d79ee4d52003bef3424c8ff6f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 246894,
"upload_time": "2024-06-14T04:34:06",
"upload_time_iso_8601": "2024-06-14T04:34:06.438891Z",
"url": "https://files.pythonhosted.org/packages/5c/ea/661e34bcbca3441f9428d2eca66a820055260b57975da6f2ee8c9c374410/mseedlib-0.0.6-py3-none-musllinux_1_2_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0983f892c6f9952564b1dd07ade5c0dda9eb0077042b8eb2681037c60df501d6",
"md5": "ec6731107fd9a9850fea0df3fab9d92d",
"sha256": "799bdc70c85e3a60943ee596c8ddd8e79a2268966faecba86e61c226b15dcdd7"
},
"downloads": -1,
"filename": "mseedlib-0.0.6-py3-none-win32.whl",
"has_sig": false,
"md5_digest": "ec6731107fd9a9850fea0df3fab9d92d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 294769,
"upload_time": "2024-06-14T04:34:07",
"upload_time_iso_8601": "2024-06-14T04:34:07.698301Z",
"url": "https://files.pythonhosted.org/packages/09/83/f892c6f9952564b1dd07ade5c0dda9eb0077042b8eb2681037c60df501d6/mseedlib-0.0.6-py3-none-win32.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "90e486abaa71d9c29f7a9849c22b3475c60e39a90b47692fd5be2e5f178364e4",
"md5": "2be33a8f762417064bce0c06f940f9db",
"sha256": "a04a2bc202ee547affdc916616a7ce93537890f189e5616df2900fa8cd0a92b5"
},
"downloads": -1,
"filename": "mseedlib-0.0.6-py3-none-win_amd64.whl",
"has_sig": false,
"md5_digest": "2be33a8f762417064bce0c06f940f9db",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 294776,
"upload_time": "2024-06-14T04:34:09",
"upload_time_iso_8601": "2024-06-14T04:34:09.381178Z",
"url": "https://files.pythonhosted.org/packages/90/e4/86abaa71d9c29f7a9849c22b3475c60e39a90b47692fd5be2e5f178364e4/mseedlib-0.0.6-py3-none-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ba627cba66383ef3a69cda24aeadc9b1af79ce1a80f4161c14f316163fd7880d",
"md5": "7e01f2918e2ade58792dba1d5a6930ac",
"sha256": "ceea0ea9fee075f5c3222837d23f2c196f7dd6012bdd96f3c54fc72ef0d1c540"
},
"downloads": -1,
"filename": "mseedlib-0.0.6.tar.gz",
"has_sig": false,
"md5_digest": "7e01f2918e2ade58792dba1d5a6930ac",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 1278258,
"upload_time": "2024-06-14T04:34:10",
"upload_time_iso_8601": "2024-06-14T04:34:10.891326Z",
"url": "https://files.pythonhosted.org/packages/ba/62/7cba66383ef3a69cda24aeadc9b1af79ce1a80f4161c14f316163fd7880d/mseedlib-0.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-14 04:34:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "EarthScope",
"github_project": "mseedlib",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "mseedlib"
}