Skip to main content

A library for building and parsing Seismology API message bodies.

Project description

postprocessing_seismo_lib

postprocessing_seismo_lib is a lightweight Python library for building and parsing structured API messages, especially for use with nested JSON structures used in event-based data systems. Currently, the library works on building out the Response format for seismology associator outputs, or extracting the body out of its Response format.

Features

  • Build a full message with metadata and body using build_message
  • Build a full message with status, headers, body_meta and body using convert_file_to_json, with provided csv, arcout or quakeml files
  • Extract the body section from a structured JSON file using extract_body_from_file

Example Scenarios

Extraction of body

The below function allows for extracting out the body from csv, quakeml or arcout:

from postprocessing_seismo_lib import extract_body_from_file

body_data = extract_body_from_file("full_response_arcout.json")
body_data = extract_body_from_file("full_response_quakeml.json")
body_data = extract_body_from_file("full_response_csv.json")

Creation of full response format

Below shows how to build out the Response format for provided files. In all cases below, you provide an ID and an output file name (of type json). Also, provide the error log file, in case any errors occur. A file of the name you specified will be generated which reports the errors. If no errors exist, the output JSON file will be generated at the path where you run the python script.

If you are converting from csv to json, you provide the _events.csv and _picks.csv that are generated from pinging the associator API, and set them to event_file and pick_file. Leave the input_file blank. For quakeML or arcout conversion to json, specify the input_file.

from postprocessing_seismo_lib import convert_file_to_json

# For CSV
convert_file_to_json(
    input_file="",  # not used for CSV
    output_file="[Output file name].json",
    id="[Name of choice]",
    event_file="[xxxx]_gamma_events.csv",
    pick_file="[xxxx]_gamma_picks.csv",
    error_log_file="csv_error_log.txt"
)

# For QuakeML XML (this input file has no XML signifiers but was parsed successfully as XML here)
convert_file_to_json(
    input_file="[xxxx]_events_test",
    output_file="[xxxx]_quakeml.json",
    id="[Name of choice]",
    error_log_file="quakeml_error_log.txt"
)

#Conventional QuakeML XML here
convert_file_to_json(
    input_file="[xxxx]_events_test.xml",
    output_file="[xxxx]_quakeml.json",
    id="[Name of choice]",
    error_log_file="quakeml_error_log.txt"
)


# For ArcOut
convert_file_to_json(
    input_file="[xxxx]_api_stproc_9999.arcout",
    output_file="[Output file name].json",
    id="[Name of choice]",
    error_log_file="arcout_error_log.txt"
)

Installation

You can install the library locally for development:

pip install -e .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

postprocessing_seismo_lib-0.1.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

postprocessing_seismo_lib-0.1.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file postprocessing_seismo_lib-0.1.1.tar.gz.

File metadata

  • Download URL: postprocessing_seismo_lib-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.6 tqdm/4.60.0 importlib-metadata/4.2.0 keyring/23.4.1 rfc3986/1.4.0 colorama/0.4.5 CPython/3.6.5

File hashes

Hashes for postprocessing_seismo_lib-0.1.1.tar.gz
Algorithm Hash digest
SHA256 27e6f4ae73db61605187304da8d90324c9cb93d4f676e16fae492cb9df58f397
MD5 17156068f17212c2166023aeb2523165
BLAKE2b-256 6557c239f38e59e90bd7d707a2a4b31e9af62f0d929f612a9f9508d57013f10e

See more details on using hashes here.

File details

Details for the file postprocessing_seismo_lib-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: postprocessing_seismo_lib-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.6 tqdm/4.60.0 importlib-metadata/4.2.0 keyring/23.4.1 rfc3986/1.4.0 colorama/0.4.5 CPython/3.6.5

File hashes

Hashes for postprocessing_seismo_lib-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e324ee7d88f4b84f955f8a34df74f5d5ac7c99bc754b9f35813021754449e676
MD5 0a72c4366753786cb22e7f8709f289b0
BLAKE2b-256 e798d675f3324068bb5c8b8ac3bc627644bbd0758834f51d72e6f4a8c67e9221

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page