simplemseed


Namesimplemseed JSON
Version 0.3.1 PyPI version JSON
download
home_pageNone
Summaryminiseed3 in pure python
upload_time2024-05-15 13:58:50
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords fdsn miniseed miniseed3 seed sourceid steim1 steim2
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # simplemseed


[![PyPI](https://img.shields.io/pypi/v/simplemseed)](https://pypi.org/project/simplemseed/)
[![Documentation Status](https://readthedocs.org/projects/simplemseed/badge/?version=latest)](https://simplemseed.readthedocs.io/en/latest/?badge=latest)

[Miniseed3](http://docs.fdsn.org/projects/miniseed3) (and reading 2) in pure python.

Read the docs at [readthedocs](https://readthedocs.org/projects/simplemseed/)

# Miniseed3

Write and read mseed3 records like:

```
#!/usr/bin/env python3

from simplemseed import MSeed3Header, MSeed3Record, FDSNSourceId, readMSeed3Records

data = [(i % 99 - 49) for i in range(0, 1000)]
header = MSeed3Header()
header.starttime = "2024-01-01T15:13:55.123456Z"
header.sampleRatePeriod = 20
sid = FDSNSourceId.createUnknown(header.sampleRatePeriod)
ms3record = MSeed3Record(header, sid, data)

ms3filename = "test.ms3"
with open(ms3filename, "wb") as of:
    of.write(ms3record.pack())
    print(f"  save: {ms3record.details()} ")
    print(f"    to: {ms3filename} ")
print()
with open(ms3filename, "rb") as infile:
    for readms3record in readMSeed3Records(infile):
        print(f"  extract: {readms3record.details()} ")
        print(f"     from: {ms3filename} ")
```

Access uncompressed timeseries data as numpy ndarray with:
```
dataArray = ms3record.decompress()
```


Also includes parsing for miniseed2 and
[miniseed3](http://docs.fdsn.org/projects/miniseed3/en/latest/index.html#) for primitive data arrays and
for Steim1 and Steim2 decompression, in pure python.

Read miniseed2:
```
with open(ms2filename, "rb") as inms2:
    for ms2rec in simplemseed.readMiniseed2Records(inms2):
        print(ms2rec.summary())
```
or read and convert to miniseed3:
```
with open(ms3filename, "wb") as outms3:
    with open(ms2filename, "rb") as inms2:
        for ms2rec in simplemseed.readMiniseed2Records(inms2):
            ms3rec = simplemseed.mseed2to3(ms2rec)
            outms3.write(ms3rec.pack())
```

# Command line tools:


#  mseed3details
- print details about each miniseed3 record
```
mseed3details casee.mseed3
          FDSN:CO_CASEE_00_H_H_Z, version 4, 285 bytes (format: 3)
                       start time: 2023-06-17T04:53:54.468392Z (168)
                number of samples: 104
                 sample rate (Hz): 100.0
                            flags: [00000000] 8 bits$
                              CRC: 0x4D467F27
              extra header length: 31 bytes
              data payload length: 192 bytes
                 payload encoding: STEIM-2 integer compression (val: 11)
                    extra headers:

Total 104 samples in 1 records
```

# getting and setting extra header values

```
% mseed3details --get "/FDSN/Time" casee_two.ms3
  {"Quality": 0}
% mseed3details --getall "/FDSN/Time/Quality" casee_two.ms3 --verbose
file: casee_two.ms3
FDSN:CO_CASEE_00_H_H_Z 2023-06-17T04:53:50.008392Z 2023-06-17T04:53:50.178392Z (18 pts)
  0
FDSN:CO_CASEE_00_H_H_Z 2023-06-17T04:53:50.188392Z 2023-06-17T04:53:55.498392Z (532 pts)
  0
% mseed3details --set "/data" '{ "key": "val", "keyb": 3 }' casee_two.ms3
% mseed3details --getall "/data" casee_two.ms3 --verbose
file: casee_two.ms3
FDSN:CO_CASEE_00_H_H_Z 2023-06-17T04:53:50.008392Z 2023-06-17T04:53:50.178392Z (18 pts)
  {"key": "val", "keyb": 3}
FDSN:CO_CASEE_00_H_H_Z 2023-06-17T04:53:50.188392Z 2023-06-17T04:53:55.498392Z (532 pts)
  pointer not found in extra headers
% mseed3details --setall "/data" '{ "key": "else", "keyb": 4 }' casee_two.ms3
% mseed3details --set "/data/keyb" 42 casee_two.ms3
% mseed3details --getall "/data" casee_two.ms3 --verbose
file: casee_two.ms3
FDSN:CO_CASEE_00_H_H_Z 2023-06-17T04:53:50.008392Z 2023-06-17T04:53:50.178392Z (18 pts)
  {"key": "else", "keyb": 42}
FDSN:CO_CASEE_00_H_H_Z 2023-06-17T04:53:50.188392Z 2023-06-17T04:53:55.498392Z (532 pts)
  {"key": "else", "keyb": 4}
```

#  mseed3merge
- merge contiguous, in order, mseed3 records into larger records. Decompression
is needed as steim1 and 2 cannot be merged without decompression, primitive
types are already decompressed.
```
mseed3merge -o merged.ms3 --decomp  bird_jsc.ms3
```

#  mseed2to3
- convert miniseed 2 to miniseed3.

Note most blockettes are ignored, other than 100, 1000, 1001

```
mseed2to3 --ms2 casee.ms2 --ms3 casee.ms3
```


# fdsnsourceid
- parse FDSN sourceids

Split a FDSN source id:
```
fdsnsourceid FDSN:CO_JSC_00_H_H_Z
      FDSN:CO_JSC_00_H_H_Z
       Net: CO
       Sta: JSC
       Loc: 00
      Band: H - High Broadband, >= 80 to < 250 Hz, response period >= 10 sec
    Source: H - High Gain Seismometer
 Subsource: Z
```   

Describe a band code:
```
fdsnsourceid -b Q
      Band: Q - Q - Greater than 10 days , < 0.000001 Hz
```

Find the correct band code for a sample rate:
```
fdsnsourceid --sps 87
      Rate: 87.0 - H - H - High Broadband , >= 80 to < 250 Hz, response period >= 10 sec
      Rate: 87.0 - E - E - Extremely Short Period, >= 80 to < 250 Hz, response period < 10 sec
```

Describe a source code:
```
fdsnsourceid --source H N
    Source: H - High Gain Seismometer
       Measures displacement/velocity/acceleration along a line defined by the the dip and azimuth.
    Source: N - Accelerometer
       Measures displacement/velocity/acceleration along a line defined by the the dip and azimuth.
```

# Example

There are more examples in the examples directory.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "simplemseed",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "fdsn, miniseed, miniseed3, seed, sourceid, steim1, steim2",
    "author": null,
    "author_email": "Philip Crotwell <crotwell@seis.sc.edu>",
    "download_url": "https://files.pythonhosted.org/packages/82/8b/dd4abea994a03995659ac68c2c28025ddeb347f885be355347ebb12ddff4/simplemseed-0.3.1.tar.gz",
    "platform": null,
    "description": "# simplemseed\n\n\n[![PyPI](https://img.shields.io/pypi/v/simplemseed)](https://pypi.org/project/simplemseed/)\n[![Documentation Status](https://readthedocs.org/projects/simplemseed/badge/?version=latest)](https://simplemseed.readthedocs.io/en/latest/?badge=latest)\n\n[Miniseed3](http://docs.fdsn.org/projects/miniseed3) (and reading 2) in pure python.\n\nRead the docs at [readthedocs](https://readthedocs.org/projects/simplemseed/)\n\n# Miniseed3\n\nWrite and read mseed3 records like:\n\n```\n#!/usr/bin/env python3\n\nfrom simplemseed import MSeed3Header, MSeed3Record, FDSNSourceId, readMSeed3Records\n\ndata = [(i % 99 - 49) for i in range(0, 1000)]\nheader = MSeed3Header()\nheader.starttime = \"2024-01-01T15:13:55.123456Z\"\nheader.sampleRatePeriod = 20\nsid = FDSNSourceId.createUnknown(header.sampleRatePeriod)\nms3record = MSeed3Record(header, sid, data)\n\nms3filename = \"test.ms3\"\nwith open(ms3filename, \"wb\") as of:\n    of.write(ms3record.pack())\n    print(f\"  save: {ms3record.details()} \")\n    print(f\"    to: {ms3filename} \")\nprint()\nwith open(ms3filename, \"rb\") as infile:\n    for readms3record in readMSeed3Records(infile):\n        print(f\"  extract: {readms3record.details()} \")\n        print(f\"     from: {ms3filename} \")\n```\n\nAccess uncompressed timeseries data as numpy ndarray with:\n```\ndataArray = ms3record.decompress()\n```\n\n\nAlso includes parsing for miniseed2 and\n[miniseed3](http://docs.fdsn.org/projects/miniseed3/en/latest/index.html#) for primitive data arrays and\nfor Steim1 and Steim2 decompression, in pure python.\n\nRead miniseed2:\n```\nwith open(ms2filename, \"rb\") as inms2:\n    for ms2rec in simplemseed.readMiniseed2Records(inms2):\n        print(ms2rec.summary())\n```\nor read and convert to miniseed3:\n```\nwith open(ms3filename, \"wb\") as outms3:\n    with open(ms2filename, \"rb\") as inms2:\n        for ms2rec in simplemseed.readMiniseed2Records(inms2):\n            ms3rec = simplemseed.mseed2to3(ms2rec)\n            outms3.write(ms3rec.pack())\n```\n\n# Command line tools:\n\n\n#  mseed3details\n- print details about each miniseed3 record\n```\nmseed3details casee.mseed3\n          FDSN:CO_CASEE_00_H_H_Z, version 4, 285 bytes (format: 3)\n                       start time: 2023-06-17T04:53:54.468392Z (168)\n                number of samples: 104\n                 sample rate (Hz): 100.0\n                            flags: [00000000] 8 bits$\n                              CRC: 0x4D467F27\n              extra header length: 31 bytes\n              data payload length: 192 bytes\n                 payload encoding: STEIM-2 integer compression (val: 11)\n                    extra headers:\n\nTotal 104 samples in 1 records\n```\n\n# getting and setting extra header values\n\n```\n% mseed3details --get \"/FDSN/Time\" casee_two.ms3\n  {\"Quality\": 0}\n% mseed3details --getall \"/FDSN/Time/Quality\" casee_two.ms3 --verbose\nfile: casee_two.ms3\nFDSN:CO_CASEE_00_H_H_Z 2023-06-17T04:53:50.008392Z 2023-06-17T04:53:50.178392Z (18 pts)\n  0\nFDSN:CO_CASEE_00_H_H_Z 2023-06-17T04:53:50.188392Z 2023-06-17T04:53:55.498392Z (532 pts)\n  0\n% mseed3details --set \"/data\" '{ \"key\": \"val\", \"keyb\": 3 }' casee_two.ms3\n% mseed3details --getall \"/data\" casee_two.ms3 --verbose\nfile: casee_two.ms3\nFDSN:CO_CASEE_00_H_H_Z 2023-06-17T04:53:50.008392Z 2023-06-17T04:53:50.178392Z (18 pts)\n  {\"key\": \"val\", \"keyb\": 3}\nFDSN:CO_CASEE_00_H_H_Z 2023-06-17T04:53:50.188392Z 2023-06-17T04:53:55.498392Z (532 pts)\n  pointer not found in extra headers\n% mseed3details --setall \"/data\" '{ \"key\": \"else\", \"keyb\": 4 }' casee_two.ms3\n% mseed3details --set \"/data/keyb\" 42 casee_two.ms3\n% mseed3details --getall \"/data\" casee_two.ms3 --verbose\nfile: casee_two.ms3\nFDSN:CO_CASEE_00_H_H_Z 2023-06-17T04:53:50.008392Z 2023-06-17T04:53:50.178392Z (18 pts)\n  {\"key\": \"else\", \"keyb\": 42}\nFDSN:CO_CASEE_00_H_H_Z 2023-06-17T04:53:50.188392Z 2023-06-17T04:53:55.498392Z (532 pts)\n  {\"key\": \"else\", \"keyb\": 4}\n```\n\n#  mseed3merge\n- merge contiguous, in order, mseed3 records into larger records. Decompression\nis needed as steim1 and 2 cannot be merged without decompression, primitive\ntypes are already decompressed.\n```\nmseed3merge -o merged.ms3 --decomp  bird_jsc.ms3\n```\n\n#  mseed2to3\n- convert miniseed 2 to miniseed3.\n\nNote most blockettes are ignored, other than 100, 1000, 1001\n\n```\nmseed2to3 --ms2 casee.ms2 --ms3 casee.ms3\n```\n\n\n# fdsnsourceid\n- parse FDSN sourceids\n\nSplit a FDSN source id:\n```\nfdsnsourceid FDSN:CO_JSC_00_H_H_Z\n      FDSN:CO_JSC_00_H_H_Z\n       Net: CO\n       Sta: JSC\n       Loc: 00\n      Band: H - High Broadband, >= 80 to < 250 Hz, response period >= 10 sec\n    Source: H - High Gain Seismometer\n Subsource: Z\n```   \n\nDescribe a band code:\n```\nfdsnsourceid -b Q\n      Band: Q - Q - Greater than 10 days , < 0.000001 Hz\n```\n\nFind the correct band code for a sample rate:\n```\nfdsnsourceid --sps 87\n      Rate: 87.0 - H - H - High Broadband , >= 80 to < 250 Hz, response period >= 10 sec\n      Rate: 87.0 - E - E - Extremely Short Period, >= 80 to < 250 Hz, response period < 10 sec\n```\n\nDescribe a source code:\n```\nfdsnsourceid --source H N\n    Source: H - High Gain Seismometer\n       Measures displacement/velocity/acceleration along a line defined by the the dip and azimuth.\n    Source: N - Accelerometer\n       Measures displacement/velocity/acceleration along a line defined by the the dip and azimuth.\n```\n\n# Example\n\nThere are more examples in the examples directory.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "miniseed3 in pure python",
    "version": "0.3.1",
    "project_urls": {
        "Documentation": "https://simplemseed.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/crotwell/simplemseed",
        "Issues": "https://github.com/crotwell/simplemseed/issues",
        "Repository": "https://github.com/crotwell/simplemseed"
    },
    "split_keywords": [
        "fdsn",
        " miniseed",
        " miniseed3",
        " seed",
        " sourceid",
        " steim1",
        " steim2"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "dde3ba25e47e1d950a3fa56439c25fbcb34b525eb34c5d791157d9ddf153d78e",
                "md5": "ab857368c923b85ea3e331876b299de0",
                "sha256": "6be0f206623d8b596c197052cfc5fa1890065eec2471d4b268fecb6cf0ef80bb"
            },
            "downloads": -1,
            "filename": "simplemseed-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ab857368c923b85ea3e331876b299de0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 50553,
            "upload_time": "2024-05-15T13:58:49",
            "upload_time_iso_8601": "2024-05-15T13:58:49.317942Z",
            "url": "https://files.pythonhosted.org/packages/dd/e3/ba25e47e1d950a3fa56439c25fbcb34b525eb34c5d791157d9ddf153d78e/simplemseed-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "828bdd4abea994a03995659ac68c2c28025ddeb347f885be355347ebb12ddff4",
                "md5": "a094f98254e4a4336fa08ace2ae38278",
                "sha256": "7c268a35441d7e85d8078ee57b9c20cf2b9fcf23481a9c3548565ffbf37cd401"
            },
            "downloads": -1,
            "filename": "simplemseed-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a094f98254e4a4336fa08ace2ae38278",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 343666,
            "upload_time": "2024-05-15T13:58:50",
            "upload_time_iso_8601": "2024-05-15T13:58:50.683395Z",
            "url": "https://files.pythonhosted.org/packages/82/8b/dd4abea994a03995659ac68c2c28025ddeb347f885be355347ebb12ddff4/simplemseed-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-15 13:58:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "crotwell",
    "github_project": "simplemseed",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "simplemseed"
}
        
Elapsed time: 0.26405s