{"id":32398181,"url":"https://github.com/niyiyu/pnwstore","last_synced_at":"2026-04-03T00:58:34.217Z","repository":{"id":41149656,"uuid":"479659348","full_name":"niyiyu/pnwstore","owner":"niyiyu","description":"mSEED client for Denolle-Lab member","archived":false,"fork":false,"pushed_at":"2025-04-24T00:27:24.000Z","size":173,"stargazers_count":1,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-24T01:20:49.394Z","etag":null,"topics":["client","database","seismology"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/niyiyu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-04-09T08:01:14.000Z","updated_at":"2025-04-24T00:27:26.000Z","dependencies_parsed_at":"2025-04-24T01:30:00.354Z","dependency_job_id":null,"html_url":"https://github.com/niyiyu/pnwstore","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/niyiyu/pnwstore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niyiyu%2Fpnwstore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niyiyu%2Fpnwstore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niyiyu%2Fpnwstore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niyiyu%2Fpnwstore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niyiyu","download_url":"https://codeload.github.com/niyiyu/pnwstore/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niyiyu%2Fpnwstore/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280923460,"owners_count":26414236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","database","seismology"],"created_at":"2025-10-25T07:57:46.830Z","updated_at":"2025-10-25T07:59:51.738Z","avatar_url":"https://github.com/niyiyu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PNWstore: Pacific Northwest Storage\n[![DOI](https://zenodo.org/badge/479659348.svg)](https://zenodo.org/badge/latestdoi/479659348) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nThis is a python-based seismic data query and selection toolbox for [Denolle-lab](https://denolle-lab.github.io) members.\n\n## What data are in pnwstore?\n- mseed data at PNW (1980 - 2023)\n- network metadata (1980 - 2022)\n    - [network list here](./docs/netlist.md)\n- earthquake catalog contributed by\n    - [University of Washington/Pacific Northwest Seismic Network](https://pnsn.org/pnsn-data-products/earthquake-catalogs) (1980-2022)\n- list of known wrong data could be found [here](./docs/wrong_data.md).\n\n## Why use this toolbox?\n1. The waveforms stored in `mseed` can be indexed with [mseedindex](https://github.com/iris-edu/mseedindex), which would dramatically improve the efficieny of data streaming. This is very useful especailly when you are working on a large amount of data.\n2. Although `xml` files contain all information of events and/or seismic networks, extra costs in codes and parsing time may not be ignored especially in reading and parsing complex XML files. It's better to extract key informations and index them in a database system.\n3. The pnwstore client (is trying to) emulate ObsPy FDSN client so that transition from using IRIS to the local data requires very little changes to the codes.\n\n## Usage\n### Query and select stream\n```python\nfrom pnwstore.mseed import WaveformClient\nclient = WaveformClient()\n\ns = client.get_waveforms(network = \"UW\", station = \"SHW\", channel = \"EH?\",\n                         starttime = \"20200101T00:00:00\",\n                         endtime   = \"20200101T01:00:00\")\n```\n\n### Query earthquake catalog\n```python\nfrom obspy.core.utcdatetime import UTCDateTime\nfrom pnwstore.catalog import QuakeClient\n\nclient = QuakeClient(USERNAME, PASSWORD)\n\nclient.query(mintime = UTCDateTime(\"1980-01-01T00:00:00\"),\n             maxtime = UTCDateTime(\"2021-01-01T00:00:00\"),\n             minlatitude = 40,    maxlatitude = 50,\n             minlongitude = -128, maxlongitude = -120,\n             minmagnitude = 5.9)\n\n# A pandas DataFrame is returned.\n#   source_id   origin_timestamp year month day doy hour minute second  microsecond latitude longitude  depth  magnitude contributor number_of_pick\n# 0 uw10313718  748582000.0      1993 9     21  264 3    26     55      630000      42.316    -122.027  8.560  5.9       uw          380\n# 1 uw10313838  748590000.0      1993 9     21  264 5    45     35      230000      42.358    -122.058  8.530  6.0       uw          427\n# 2 uw10530748  983386000.0      2001 2     28  59  18   54     32      830000      47.149    -122.727  51.798 6.8       uw          98\n\n```\n\n### Query phase picks\n```python\nfrom obspy.core.utcdatetime import UTCDateTime\nfrom pnwstore.catalog import PickClient\n\nclient = PickClient(USERNAME, PASSWORD)\n\nclient.query(network = \"UW\", station = \"SHW\", phase = \"P*\",\n             mintime = UTCDateTime(\"2000-01-01\"),\n             maxtime = UTCDateTime(\"2000-01-10\"))\n\n# A pandas DataFrame is returned.\n#   pick_id   source_id network station location channel    timestamp  year month day doy  hour  minute  second  microsecond phase evaluation_mode uncertainty  backazimuth contributor\n# 0 1133412  uw10485733      UW     SHW       --     EHZ  947343000.0  2000   1    8    8    14      57      23       680000     P          manual   0.05         79.0          UW\n# 1 1133508  uw10485213      UW     SHW       --     EHZ  947142000.0  2000   1    6    6     6      52      56       790000     P          manual   0.08         63.6          UW\n# 2 1133612  uw10484688      UW     SHW       --     EHZ  946890000.0  2000   1    3    3     9       0      14       280000     P          manual   0.22        222.1          UW\n```\n\n### Query network meta\n```python\nfrom obspy.core.utcdatetime import UTCDateTime\nfrom pnwstore.station import StationClient\n\nclient = StationClient(USERNAME, PASSWORD)\nclient.query(network = \"UW\", channel = \"EH?\",\n             mintime = UTCDateTime(\"2010-01-15\"),\n             maxtime = UTCDateTime(\"2000-01-16\"))\n\n# A pandas DataFrame is returned.\n#    channel_id network station location channel  latitude  longitude elevation  depth     starttime       endtime sampling_rate azimuth\n# 0       45376      UW     SHW       --     EHZ   46.1935   -122.236   1425.00   0.00   867283200.0  1207008000.0      100.0000    None\n# 1       45377      UW     SHW       --     EHZ   46.1935   -122.236   1425.00   0.00  1207008000.0  1536105600.0      100.0000    None\n```\n\n\n## Database schema\nPNWstore uses mysql to index all seismic data. Below are the schemas for each table.\n### network schema\n```mysql\ncreate table network (                             \\\n    channel_id MEDIUMINT NOT NULL AUTO_INCREMENT,  \\\n    network VARCHAR(3) NOT NULL,                   \\\n    station VARCHAR(5) NOT NULL,                   \\\n    location VARCHAR(3) NOT NULL,                  \\\n    channel CHAR(3) NOT NULL,                      \\\n    latitude FLOAT NOT NULL,                       \\\n    longitude FLOAT NOT NULL,                      \\\n    elevation DECIMAL(6, 2) NOT NULL,              \\\n    depth DECIMAL(6, 2) NOT NULL,                  \\\n    starttime DECIMAL(16, 1) NOT NULL,             \\\n    endtime DECIMAL(16, 1) NOT NULL,               \\\n    sampling_rate     DECIMAL(10, 4) NOT NULL,     \\\n    azimuth DECIMAL(5, 2),                         \\\n    PRIMARY KEY (channel_id)                       \\\n);\n```\n### catalog schema\n```mysql\ncreate table catalog (                             \\\n    source_id VARCHAR(10) NOT NULL,                \\\n    timestamp DECIMAL(16, 6) NOT NULL,             \\\n    year SMALLINT NOT NULL,                        \\\n    month TINYINT NOT NULL,                        \\\n    day TINYINT NOT NULL,                          \\\n    doy SMALLINT NOT NULL,                         \\\n    hour TINYINT NOT NULL,                         \\\n    minute TINYINT NOT NULL,                       \\\n    second TINYINT NOT NULL,                       \\\n    microsecond MEDIUMINT NOT NULL,                \\\n    latitude FLOAT NOT NULL,                       \\\n    longitude FLOAT NOT NULL,                      \\\n    depth FLOAT NOT NULL,                          \\\n    magnitude FLOAT NOT NULL,                      \\\n    magnitude_type VARCHAR(2) NOT NULL,            \\\n    contributor VARCHAR(4) NOT NULL,               \\\n    number_of_pick SMALLINT NOT NULL,              \\\n    PRIMARY KEY (source_id)                        \\\n);\n```\n### mseed schema\nNote that each year relates to an individual table.\n```mysql\ncreate table mseed_YYYY (                         \\\n    mseed_id MEDIUMINT NOT NULL AUTO_INCREMENT,   \\\n    network VARCHAR(3) NOT NULL,                  \\\n    station VARCHAR(5) NOT NULL,                  \\\n    location VARCHAR(3) NOT NULL,                 \\\n    channel CHAR(3) NOT NULL,                     \\\n    quality CHAR(1) NOT NULL,                     \\\n    version VARCHAR(4) NOT NULL,                  \\\n    starttime VARCHAR(26) NOT NULL,               \\\n    endtime VARCHAR(26) NOT NULL,                 \\\n    samplerate FLOAT NOT NULL,                    \\\n    filename VARCHAR(48) NOT NULL,                \\\n    byteoffset INT NOT NULL,                      \\\n    bytes INT NOT NULL,                           \\\n    hash CHAR(32) NOT NULL,                       \\\n    timeindex TEXT NOT NULL,                      \\\n    timespans MEDIUMTEXT NOT NULL,                \\\n    timerates TEXT,                               \\\n    format TEXT,                                  \\\n    filemodtime VARCHAR(26) NOT NULL,             \\\n    updated VARCHAR(26) NOT NULL,                 \\\n    scanned VARCHAR(26) NOT NULL,                 \\\n    PRIMARY KEY (mseed_id)                        \\\n);\n```\n\n### pick schema\nNote that each contributor relates to an individual table.\n```mysql\ncreate table picks_CONTRIBUTOR (                  \\\n    pick_id INT NOT NULL AUTO_INCREMENT,          \\\n    source_id VARCHAR(10) NOT NULL,               \\\n    network VARCHAR(3) NOT NULL,                  \\\n    station VARCHAR(5) NOT NULL,                  \\\n    location VARCHAR(3) NOT NULL,                 \\\n    channel CHAR(3) NOT NULL,                     \\\n    timestamp DECIMAL(16, 6) NOT NULL,            \\\n    year SMALLINT NOT NULL,                       \\\n    month TINYINT NOT NULL,                       \\\n    day TINYINT NOT NULL,                         \\\n    doy SMALLINT NOT NULL,                        \\\n    hour TINYINT NOT NULL,                        \\\n    minute TINYINT NOT NULL,                      \\\n    second TINYINT NOT NULL,                      \\\n    microsecond MEDIUMINT NOT NULL,               \\\n    phase VARCHAR(6) NOT NULL,                    \\\n    evaluation_mode VARCHAR(10) NOT NULL,         \\\n    onset VARCHAR(2),                             \\\n    polarity VARCHAR(2),                          \\\n    uncertainty FLOAT,                            \\\n    backazimuth FLOAT,                            \\\n    contributor VARCHAR(6) NOT NULL,              \\\n    PRIMARY KEY (pick_id)                         \\\n);\"\n```\n\n## Reference\n* https://pnsn.org\n* https://ds.iris.edu/ds/nodes/dmc/\n* https://earthquake.usgs.gov/data/comcat/\n* https://github.com/iris-edu/mseedindex\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniyiyu%2Fpnwstore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniyiyu%2Fpnwstore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniyiyu%2Fpnwstore/lists"}