SeisCat API

Start here to navigate the SeisCat source code.

seiscat

Main script for seiscat.

copyright:

2022-2024 Claudio Satriano <satriano@ipgp.fr>

license:

GNU General Public License v3.0 or later (https://www.gnu.org/licenses/gpl-3.0-standalone.html)

seiscat.scripts.seiscat.main()[source]

Main function. Catch KeyboardInterrupt.

seiscat.scripts.seiscat.run()[source]

Run seiscat.

db

Database functions for seiscat.

copyright:

2022-2024 Claudio Satriano <satriano@ipgp.fr>

license:

GNU General Public License v3.0 or later (https://www.gnu.org/licenses/gpl-3.0-standalone.html)

seiscat.db.check_db_exists(config, initdb)[source]

Check if database file exists.

Parameters:
  • config – config object

  • initdb – if True, create new database file

Raises:
  • ValueError – if db_file is not set in config file

  • RuntimeError – if user does not want to overwrite existing database

  • FileNotFoundError – if database file does not exist

seiscat.db.delete_event_from_db(config, eventid, version=None)[source]

Delete an event from the database.

Parameters:
  • config – config object

  • eventid – event id of the event to delete (if None, delete all events for the given version)

  • version – version of the event to delete (if None, delete all versions of the event)

seiscat.db.get_catalog_stats(config)[source]

Get a string with catalog statistics.

Parameters:

config – config object

Returns:

string with catalog statistics

seiscat.db.increment_event_in_db(config, eventid, version, field, value)[source]

Increment an event in the database.

Parameters:
  • config – config object

  • eventid – event id of the event to update

  • version – version of the event to update

  • field – field to update

  • value – value to increment, must be a number

Raises:

ValueError – if field is not found in database, or if value is not a number

seiscat.db.read_events_from_db(config)[source]

Read events from database. Return a list of events.

Parameters:

config – config object

Returns:

list of events, each event is a dictionary

seiscat.db.read_fields_and_rows_from_db(config, eventid=None, version=None)[source]

Read fields and rows from database. Return a list of fields and a list of rows.

Parameters:
  • config – config object

  • eventid – limit to events with this evid

  • version – limit to events with this version

Returns:

list of fields, list of rows

Raises:

ValueError – if field is not found in database

seiscat.db.replicate_event_in_db(config, eventid, version=1)[source]

Replicate an event in the database. The new event will have the same evid as the original event, but a different version.

Parameters:
  • config – config object

  • eventid – event id of the original event

  • version – version of the original event

Raises:

ValueError – if eventid/version is not found in database

seiscat.db.update_event_in_db(config, eventid, version, field, value)[source]

Update an event in the database.

Parameters:
  • config – config object

  • eventid – event id of the event to update

  • version – version of the event to update

  • field – field to update

  • value – new value

Raises:

ValueError – if field is not found in database

seiscat.db.write_catalog_to_db(cat, config, initdb)[source]

Write catalog to database.

Parameters:
  • cat – obspy Catalog object

  • config – config object

  • initdb – if True, create new database file

download_event_details

Download event details from FDSN web services and store them to local files.

copyright:

2022-2024 Claudio Satriano <satriano@ipgp.fr>

license:

GNU General Public License v3.0 or later (https://www.gnu.org/licenses/gpl-3.0-standalone.html)

seiscat.download_event_details.download_event_details(config)[source]

Download event details from FDSN web services and store them to local files.

Parameters:

config – config object

download_event_waveforms

Uses ObsPy mass downloader to download event waveforms from FDSN web services.

copyright:

2022-2024 Claudio Satriano <satriano@ipgp.fr>

license:

GNU General Public License v3.0 or later (https://www.gnu.org/licenses/gpl-3.0-standalone.html)

seiscat.download_event_waveforms.download_event_waveforms(config)[source]

Uses ObsPy mass downloader to download event waveforms from FDSN web services.

Parameters:

config – config object

editdb

Edit functions for seiscat.

copyright:

2022-2024 Claudio Satriano <satriano@ipgp.fr>

license:

GNU General Public License v3.0 or later (https://www.gnu.org/licenses/gpl-3.0-standalone.html)

seiscat.editdb.editdb(config)[source]

Edit database.

Parameters:

config – config object

fdsnws

FDSN webservices functions for seiscat.

copyright:

2022-2024 Claudio Satriano <satriano@ipgp.fr>

license:

GNU General Public License v3.0 or later (https://www.gnu.org/licenses/gpl-3.0-standalone.html)

exception seiscat.fdsnws.InvalidQuery[source]

Bases: Exception

Invalid query exception.

class seiscat.fdsnws.QueryArgs(config, suffix, first_query)[source]

Bases: object

Build query arguments for FDSN client.

get_query()[source]

Return query arguments as a dictionary.

Returns:

dictionary of query arguments

seiscat.fdsnws.open_fdsn_connection(config)[source]

Open FDSN connection. Return a FDSN client object.

Parameters:

config – config object

Returns:

FDSN client object

seiscat.fdsnws.query_events(client, config, first_query=True)[source]

Query events from FDSN client based on criteria in config.

Parameters:
  • client – FDSN client object

  • config – config object

  • first_query – True if this is the first query

Returns:

obspy Catalog object

feeddb

Feed the database with events from FDSN web services.

copyright:

2022-2024 Claudio Satriano <satriano@ipgp.fr>

license:

GNU General Public License v3.0 or later (https://www.gnu.org/licenses/gpl-3.0-standalone.html)

seiscat.feeddb.feeddb(config, initdb)[source]

Feed the database with events from FDSN web services.

Parameters:
  • config – config object

  • initdb – if True, create new database file

parse_arguments

Argument parsing for seiscat.

copyright:

2022-2024 Claudio Satriano <satriano@ipgp.fr>

license:

GNU General Public License v3.0 or later (https://www.gnu.org/licenses/gpl-3.0-standalone.html)

class seiscat.parse_arguments.NewlineHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None)[source]

Bases: HelpFormatter

Custom help formatter that preserves newlines in help messages.

seiscat.parse_arguments.parse_arguments()[source]

Parse command line arguments.

plot_map

Plot events on a map.

copyright:

2022-2024 Claudio Satriano <satriano@ipgp.fr>

license:

GNU General Public License v3.0 or later (https://www.gnu.org/licenses/gpl-3.0-standalone.html)

seiscat.plot_map.plot_catalog_map(config)[source]

Plot the catalog map.

Parameters:

config – config object

plot_map_utils

Utility functions for the map modules.

copyright:

2022-2024 Claudio Satriano <satriano@ipgp.fr>

license:

GNU General Public License v3.0 or later (https://www.gnu.org/licenses/gpl-3.0-standalone.html)

seiscat.plot_map_utils.get_map_extent(config)[source]

Get the map extent from the config file.

Parameters:

config – config object

Returns:

lon_min, lon_max, lat_min, lat_max

plot_map_cartopy

Plot events on a map using cartopy.

copyright:

2022-2024 Claudio Satriano <satriano@ipgp.fr>

license:

GNU General Public License v3.0 or later (https://www.gnu.org/licenses/gpl-3.0-standalone.html)

seiscat.plot_map_cartopy.plot_catalog_map_with_cartopy(events, config)[source]

Plot the catalog map using cartopy.

Parameters:

config – config object

plot_map_folium

Plot events on a map using folium.

copyright:

2022-2024 Claudio Satriano <satriano@ipgp.fr>

license:

GNU General Public License v3.0 or later (https://www.gnu.org/licenses/gpl-3.0-standalone.html)

seiscat.plot_map_folium.plot_catalog_map_with_folium(events, config)[source]

Plot the catalog map with folium.

Parameters:

config – config object

print

Printing functions for seiscat.

copyright:

2022-2024 Claudio Satriano <satriano@ipgp.fr>

license:

GNU General Public License v3.0 or later (https://www.gnu.org/licenses/gpl-3.0-standalone.html)

seiscat.print.print_catalog(config)[source]

Print catalog.

Parameters:

config – config object

utils

Utility functions for seiscat.

copyright:

2022-2024 Claudio Satriano <satriano@ipgp.fr>

license:

GNU General Public License v3.0 or later (https://www.gnu.org/licenses/gpl-3.0-standalone.html)

class seiscat.utils.ExceptionExit(additional_msg=None)[source]

Bases: AbstractContextManager

Context manager to exit when an exception is raised.

seiscat.utils.err_exit(msg)[source]

Print an error message and exit.

Parameters:

msg – error message

seiscat.utils.parse_configspec()[source]

Parse the configspec file.

Returns:

configspec object

seiscat.utils.read_config(config_file, configspec=None)[source]

Read a config file.

Parameters:
  • config_file – path to the config file

  • configspec – configspec object

Returns:

config object

seiscat.utils.write_ok(filepath)[source]

Check if it is ok to write to a file.

Parameters:

filepath – path to the file

Returns:

True if it is ok to write to the file, False otherwise

seiscat.utils.write_sample_config(configspec, progname)[source]

Write a sample config file.

Parameters:
  • configspec – configspec object

  • progname – program name