Skip to content

Commit

Permalink
Refactor get_receiver method to use NSL object instead of tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
Marius Isken committed Jan 5, 2024
1 parent 670a525 commit 432bbc6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/qseek/models/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from qseek.stats import Stats
from qseek.tracers.tracers import RayTracerArrival
from qseek.utils import (
NSL,
MeasurementUnit,
PhaseDescription,
Symbols,
Expand Down Expand Up @@ -343,7 +344,7 @@ async def get_waveforms_restituted(
)
return restituted_traces

def get_receiver(self, nsl: tuple[str, str, str]) -> Receiver:
def get_receiver(self, nsl: NSL) -> Receiver:
"""
Get the receiver object based on given NSL tuple.
Expand All @@ -359,7 +360,7 @@ def get_receiver(self, nsl: tuple[str, str, str]) -> Receiver:
for receiver in self:
if receiver.nsl == nsl:
return receiver
raise KeyError(f"cannot find station {'.'.join(nsl)}")
raise KeyError(f"cannot find station {nsl.pretty}")

def add(
self,
Expand All @@ -385,12 +386,12 @@ def add(
self.receivers.append(receiver)
receiver.add_phase_detection(arrival)

def get_by_nsl(self, nsl: tuple[str, str, str]) -> Receiver:
def get_by_nsl(self, nsl: NSL) -> Receiver:
"""
Retrieves a receiver object by its NSL (network, station, location) tuple.
Args:
nsl (tuple[str, str, str]): The NSL tuple representing
nsl (NSL): The NSL tuple representing
the network, station, and location.
Returns:
Expand All @@ -402,7 +403,7 @@ def get_by_nsl(self, nsl: tuple[str, str, str]) -> Receiver:
for receiver in self:
if receiver.nsl == nsl:
return receiver
raise KeyError(f"cannot find station {nsl}")
raise KeyError(f"cannot find station {nsl.pretty}")

def get_pyrocko_markers(self) -> list[marker.PhaseMarker]:
"""
Expand Down

0 comments on commit 432bbc6

Please sign in to comment.