From e8dcfa0146712e997a10635d20b78fe5b0170d0c Mon Sep 17 00:00:00 2001 From: miili Date: Thu, 28 Nov 2024 21:37:04 +0100 Subject: [PATCH] search: better defaults small bugfixes --- README.md | 4 ++-- src/qseek/models/detection.py | 11 +++++++---- src/qseek/models/station.py | 2 +- src/qseek/search.py | 16 ++++++++-------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 6bfde267..83ef4265 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ Key features are of the earthquake detection and localisation framework are: * 1D Layered velocity model * 3D fast-marching velocity model (NonLinLoc compatible) * Extraction of earthquake event features: + * Local magnitudes (ML), different attenuation models * Moment Magnitudes (MW) based on modelled peak ground motions - * Local magnitudes (ML), different models - * Ground motion attributes (e.g. PGA, PGV, ...) + * Different ground motion attributes (e.g. PGA, PGV, ...) * Automatic extraction of modelled and picked travel times * Station Corrections * station specific corrections (SST) diff --git a/src/qseek/models/detection.py b/src/qseek/models/detection.py index 685685a1..aa559599 100644 --- a/src/qseek/models/detection.py +++ b/src/qseek/models/detection.py @@ -2,6 +2,7 @@ import asyncio import logging +from contextlib import suppress from datetime import datetime, timedelta from functools import cached_property from itertools import chain @@ -119,10 +120,12 @@ def find_uid(self, uid: UUID, start_idx: int = 0) -> tuple[int, str]: right_idx = start_idx + offset if start_idx + offset >= n_lines and start_idx - offset < 0: break - if left_idx >= 0 and find_uid in self.lines[left_idx]: - return left_idx, self.lines[left_idx] - if right_idx < n_lines and find_uid in self.lines[right_idx]: - return right_idx, self.lines[right_idx] + with suppress(IndexError): + if left_idx >= 0 and find_uid in self.lines[left_idx]: + return left_idx, self.lines[left_idx] + with suppress(IndexError): + if right_idx < n_lines and find_uid in self.lines[right_idx]: + return right_idx, self.lines[right_idx] offset += 1 raise KeyError(f"UID {find_uid} not found in receiver cache.") diff --git a/src/qseek/models/station.py b/src/qseek/models/station.py index f168878b..52b53527 100644 --- a/src/qseek/models/station.py +++ b/src/qseek/models/station.py @@ -132,7 +132,7 @@ def weed_stations(self) -> None: for sta in self.stations.copy(): if sta.lat == 0.0 or sta.lon == 0.0: logger.warning( - "removing station %s: bad coordinates (%.2f, %.2f)", + "removing station %s with bad coordinates: lat %.4f, lon %.4f", sta.nsl.pretty, sta.lat, sta.lon, diff --git a/src/qseek/search.py b/src/qseek/search.py index 5e41d638..31367c57 100644 --- a/src/qseek/search.py +++ b/src/qseek/search.py @@ -281,7 +281,7 @@ class Search(BaseModel): description="Detection threshold for semblance.", ) pick_confidence_threshold: float = Field( - default=0.1, + default=0.2, gt=0.0, le=1.0, description="Confidence threshold for picking.", @@ -310,7 +310,7 @@ class Search(BaseModel): "the event hypocentre.", ) detection_blinding: timedelta = Field( - default=timedelta(seconds=2.0), + default=timedelta(seconds=1.0), description="Blinding time in seconds before and after the detection peak. " "This is used to avoid detecting the same event multiple times. " "Default is 2 seconds.", @@ -521,6 +521,12 @@ async def prepare(self) -> None: self.stations.prepare(self.octree) self.data_provider.prepare(self.stations) await self.pre_processing.prepare() + await self.ray_tracers.prepare( + self.octree, + self.stations, + phases=self.image_functions.get_phases(), + rundir=self._rundir, + ) if self.distance_weights: self.distance_weights.prepare(self.stations, self.octree) @@ -532,12 +538,6 @@ async def prepare(self) -> None: self.image_functions.get_phases(), self._rundir, ) - await self.ray_tracers.prepare( - self.octree, - self.stations, - phases=self.image_functions.get_phases(), - rundir=self._rundir, - ) for magnitude in self.magnitudes: await magnitude.prepare(self.octree, self.stations) await self.init_boundaries()