Detections¶
The detections of a run, as loaded with EventCatalog.load_rundir(). See read the detections in Python.
EventCatalog
pydantic-model
¶
Bases: BaseModel
Fields:
-
rundir(Path) -
events(list[EventDetection])
get_event
¶
get_event(uid: UUID) -> EventDetection
Get an event by its UUID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uid
|
UUID
|
The event UUID. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
EventDetection |
EventDetection
|
The event detection object. |
filter_events_by_time
async
¶
add
async
¶
add(
detection: EventDetection, jitter_location: float = 0.0
) -> None
Add a detection to the catalog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
detection
|
EventDetection
|
The detection to add. |
required |
jitter_location
|
float
|
Randomize the location of the detection by this many meters. This is only exported to the CSV and Pyrocko detections. Defaults to 0.0. |
0.0
|
save_semblance_trace
async
¶
Add semblance trace to detection and save to file.
Data is multiplied by 1e3 and saved as int32 to leverage MiniSEED STEIM compression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
Trace
|
semblance trace. |
required |
last_modification
classmethod
¶
Last modification of the event file.
Returns:
| Name | Type | Description |
|---|---|---|
datetime |
datetime
|
Last modification of the event file. |
load_rundir
classmethod
¶
load_rundir(rundir: Path) -> EventCatalog
Load detections from files in the detections directory.
check
async
¶
check(repair: bool = True) -> None
Check the catalog for errors and inconsistencies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repair
|
bool
|
If True, attempt to repair the catalog. Defaults to True. |
True
|
save_detection
async
¶
save_detection(
detection: EventDetection,
update: bool = False,
jitter_location: float = 0.0,
) -> None
Dump a detection data to file.
After the detection is dumped, the receivers are dumped to a separate file and the receivers cache is cleared.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
detection
|
EventDetection
|
The detection to save. |
required |
update
|
bool
|
Whether to update an existing detection or append a new one. |
False
|
jitter_location
|
float
|
The amount of spatial jitter to apply to the exported detection. Defaults to 0.0. |
0.0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the detection index is not set and update is True. |
export_detections
async
¶
export_detections(jitter_location: float = 0.0) -> None
Export detections to CSV and Pyrocko event lists in the current rundir.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jitter_location
|
float
|
The amount of jitter in [m] to apply to the detection locations. Defaults to 0.0. |
0.0
|
export_csv
async
¶
export_csv(
file: Path,
jitter_location: float = 0.0,
additional_data: list[dict] | None = None,
) -> None
Export detections to a CSV file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
Path
|
The output filename. |
required |
jitter_location
|
float
|
Randomize the location of each detection by this many meters. Defaults to 0.0. |
0.0
|
additional_data
|
list[dict]
|
Additional data to include in the CSV. Defaults to None. |
None
|
as_pyrocko_events
¶
as_pyrocko_events() -> list[Event]
Convert the detections to Pyrocko Event objects.
Returns:
| Type | Description |
|---|---|
list[Event]
|
list[Event]: A list of Pyrocko Event objects. |
get_pyrocko_markers
¶
get_pyrocko_markers(
modelled: bool = True, observed: bool = True
) -> list[EventMarker | PhaseMarker]
Get Pyrocko phase pick markers for all detections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modelled
|
bool
|
Include modelled picks. Defaults to True. |
True
|
observed
|
bool
|
Include observed picks. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
list[EventMarker | PhaseMarker]
|
list[EventMarker | PhaseMarker]: A list of Pyrocko PhaseMarker. |
export_pyrocko_events
¶
EventDetection
pydantic-model
¶
Bases: Location
Fields:
-
lat(float) -
lon(float) -
east_shift(float) -
north_shift(float) -
elevation(float) -
depth(float) -
uid(UUID) -
time(AwareDatetime) -
semblance(PositiveFloat) -
n_stations(int) -
distance_border(PositiveFloat) -
in_bounds(bool) -
uncertainty(DetectionUncertainty | None) -
magnitudes(list[EventMagnitudeType]) -
features(list[EventFeaturesType])
Validators:
-
materialize_receivers -
migrate_features→features
distance_border
pydantic-field
¶
distance_border: PositiveFloat
Distance to the nearest border in meters. Only distance to NW, SW and bottom border is considered.
in_bounds
pydantic-field
¶
in_bounds: bool = True
Is detection in bounds, and inside the configured border.
magnitude
property
¶
Returns the magnitude of the event.
If there are no magnitudes available, returns None.
receivers
property
writable
¶
Retrieves the event receivers associated with the detection.
Returns:
| Name | Type | Description |
|---|---|---|
EventReceivers |
EventReceivers
|
The event receivers associated with the detection. |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If the receivers cannot be fetched without a set rundir and detection index. |
ValueError
|
If the receivers cannot be fetched due to missing rundir and index, or if there is a UID mismatch between the fetched receivers and the detection. |
rms
property
¶
rms: float | None
Root mean square of the traveltime delays of the observed arrivals.
east_shift
pydantic-field
¶
east_shift: float = 0.0
East shift towards geographical reference in meters.
north_shift
pydantic-field
¶
north_shift: float = 0.0
North shift towards geographical reference in meters.
effective_lat_lon
property
¶
Shift-corrected lat/lon pair of the location.
set_receiver_cache
¶
Set the receiver cache for the detection model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
receiver_cache
|
ReceiverCache
|
The receiver cache instance. |
required |
clear_receivers
¶
Clear the receivers associated with the detection to free memory.
write_csv_line
¶
write_pyrocko_event
¶
set_index
¶
set_uncertainty
¶
Set detection uncertainty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uncertainty
|
DetectionUncertainty
|
detection uncertainty |
required |
add_magnitude
¶
Add magnitude to detection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
magnitude
|
EventMagnitudeType
|
magnitude |
required |
add_feature
¶
Add feature to the feature set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feature
|
EventFeature
|
Feature to add |
required |
get_receiver_azimuths
¶
get_azimuthal_coverage
¶
Get azimuthal coverage of the detection.
This is the reverse of the azimuthal gap: 360 - azimuthal_gap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observed_only
|
bool
|
Consider only observed azimuths. Defaults to True. |
True
|
get_azimuthal_gap
¶
Get maximum azimuthal gap of the detection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observed_only
|
bool
|
Consider only observed azimuths. Defaults to True. |
True
|
as_pyrocko_event
¶
Get detection as Pyrocko event.
Returns:
| Name | Type | Description |
|---|---|---|
Event |
Event
|
Pyrocko event |
get_csv_dict
¶
csv_header
classmethod
¶
get_pyrocko_markers
¶
get_pyrocko_markers(
modelled: bool = True, observed: bool = True
) -> list[EventMarker | PhaseMarker]
Get detections as Pyrocko markers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modelled
|
bool
|
Include modelled arrivals. Defaults to True. |
True
|
observed
|
bool
|
Include observed arrivals. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
list[EventMarker | PhaseMarker]
|
list[marker.EventMarker | marker.PhaseMarker]: Pyrocko markers |
export_pyrocko_markers
¶
export_pyrocko_markers(filename: Path) -> None
Save detection's Pyrocko markers to file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Path
|
path to marker file |
required |
jitter_location
¶
snuffle
¶
snuffle(
waveform_provider: WaveformProvider,
stations: StationInventory | None = None,
restituted: bool | MeasurementUnit = False,
) -> None
Open snuffler for detection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waveform_provider
|
WaveformProvider
|
The waveform provider to use for retrieving waveforms. |
required |
stations
|
StationInventory
|
The station inventory to use for retrieving |
None
|
restituted
|
bool
|
Restitude the data. Defaults to False. |
False
|
surface_distance_to
¶
azimuth_to
¶
distance_to
¶
offset_from
¶
shifted_origin
¶
shifted_origin() -> Self
Shift the origin of the location to the effective lat/lon.
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The shifted location. |