pyrocko.squirrel.elk

Functions

add_events(connection, prefix, events)

Add events to database.

content_hash(source, source_id, time, lat, ...)

Get hash identifying an event revision from a specific catalog.

get_event_groups(connection, prefix[, ...])

Query groups of events, page by page.

get_events(connection, prefix[, nlatest, ...])

Query events.

get_largest_events(connection, prefix, n[, ...])

Get the largest events in a given region and time span.

new_elk_id()

Create new time-ordered event ID (UUID version 7).

resolve_elk_id(connection, prefix, elk_id)

Get current ID for a given ID, which may have been given up as alias.

split_lon_range(lon_min, lon_max)

Get longitude range as list of non-wrapping ranges.

new_elk_id()[source]

Create new time-ordered event ID (UUID version 7).

content_hash(source, source_id, time, lat, lon, north_shift, east_shift, depth, magnitude, magnitude_type)[source]

Get hash identifying an event revision from a specific catalog.

Two events with the same hash are considered to be the same event. The hash covers catalog name, catalog event ID and quantized source parameters, but not moment tensor, duration, region, tags and extras.

add_events(connection, prefix, events)[source]

Add events to database.

Events already in the database (same catalog, catalog event ID and source parameters) are skipped. New events get a new time-ordered ID, unless they carry an ID in extras['elk_id'], e.g. when they have been obtained from another ELK database. If the same event is known under two different IDs, the older ID is kept and the newer one is registered as alias.

resolve_elk_id(connection, prefix, elk_id)[source]

Get current ID for a given ID, which may have been given up as alias.

get_events(connection, prefix, nlatest=None, filter=None, include_superseded=False)[source]

Query events.

Limits are treated as half-open intervals, e.g. [tmin, tmax).

get_event_groups(connection, prefix, filter=None, limit=None, after=None, include_superseded=False)[source]

Query groups of events, page by page.

Groups are ordered by descending group key (time, group_id), where time is the time of the event the group is named after. Only groups with at least one event matching the filter are returned and only the matching events of each group are included.

Parameters:
  • limit – Maximum number of groups to return.

  • after – Group key of the last group of the previous page. Only groups with smaller key are returned.

Returns:

List of (group_key, events) tuples.

split_lon_range(lon_min, lon_max)[source]

Get longitude range as list of non-wrapping ranges.

If lon_min > lon_max, the range crosses the date line and is split in two. Without limits, [(None, None)] is returned.

get_largest_events(connection, prefix, n, filter=None, lat_min=None, lat_max=None, lon_min=None, lon_max=None, include_superseded=False)[source]

Get the largest events in a given region and time span.

Events are selected by magnitude, using the spatio-temporal index. Events without magnitude come last. Group membership is not taken into account: several events of a group may be selected. They can be combined using extras['group_id']. Cartesian offsets of the events (north_shift, east_shift) are not taken into account.

Parameters:
  • n – Maximum number of events to return.

  • filter – Event filter (time, magnitude and depth limits).

  • lat_min – Southern limit of the region [deg].

  • lat_max – Northern limit of the region [deg].

  • lon_min – Western limit of the region [deg].

  • lon_max – Eastern limit of the region [deg]. If lon_min > lon_max, the region crosses the date line.

Returns:

List of events, ordered by descending magnitude.