-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
97 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from typing import Iterable, Literal | ||
|
||
import numpy as np | ||
|
||
from qseek.corrections.base import NSL, StationCorrections | ||
from qseek.utils import PhaseDescription | ||
|
||
|
||
class SimpleCorrections(StationCorrections): | ||
corrections: Literal["SimpleCorrections"] = "SimpleCorrections" | ||
|
||
stations: dict[NSL, dict[PhaseDescription, float]] = {} | ||
|
||
@property | ||
def n_stations(self) -> int: | ||
return len(self.stations) | ||
|
||
def get_delay(self, station_nsl: NSL, phase: PhaseDescription) -> float: | ||
if station_nsl not in self.stations: | ||
return 0.0 | ||
if phase not in self.stations[station_nsl]: | ||
return 0.0 | ||
return self.stations[station_nsl][phase] | ||
|
||
def get_delays( | ||
self, | ||
station_nsls: Iterable[NSL], | ||
phase: PhaseDescription, | ||
) -> np.ndarray: | ||
return np.array( | ||
[self.get_delay(station_nsl, phase) for station_nsl in station_nsls] | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
import numpy as np | ||
from pydantic import BaseModel, Field | ||
from typing_extensions import Self | ||
|
||
if TYPE_CHECKING: | ||
from qseek.octree import Node, Octree | ||
|
||
|
||
# Equivalent to one standard deviation | ||
THRESHOLD = 1.0 / np.sqrt(np.e) | ||
|
||
|
||
class DetectionUncertainty(BaseModel): | ||
east_uncertainties: tuple[float, float] = Field( | ||
..., | ||
description="Uncertainty in east direction in [m].", | ||
) | ||
north_uncertainties: tuple[float, float] = Field( | ||
..., | ||
description="Uncertainty in north direction in [m].", | ||
) | ||
depth_uncertainties: tuple[float, float] = Field( | ||
..., | ||
description="Uncertainty in depth in [m].", | ||
) | ||
|
||
@classmethod | ||
def from_event( | ||
cls, source_node: Node, octree: Octree, width: float = THRESHOLD | ||
) -> Self: | ||
""" | ||
Calculate the uncertainty of an event detection. | ||
Args: | ||
event: The event detection to calculate the uncertainty for. | ||
octree: The octree to use for the calculation. | ||
Returns: | ||
The calculated uncertainty. | ||
""" | ||
nodes = octree.get_nodes(semblance_threshold=width) | ||
vicinity_coords = np.array( | ||
[(node.east, node.north, node.depth) for node in nodes] | ||
) | ||
relative_node_offsets = vicinity_coords - np.array( | ||
[source_node.east, source_node.north, source_node.depth] | ||
) | ||
min_offsets = np.min(relative_node_offsets, axis=0) | ||
max_offsets = np.max(relative_node_offsets, axis=0) | ||
|
||
return cls( | ||
east_uncertainties=(float(min_offsets[0]), float(max_offsets[0])), | ||
north_uncertainties=(float(min_offsets[1]), float(max_offsets[1])), | ||
depth_uncertainties=(float(min_offsets[2]), float(max_offsets[2])), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters