Skip to content

Commit

Permalink
moment magnitudes
Browse files Browse the repository at this point in the history
  • Loading branch information
Marius Isken committed Jan 5, 2024
1 parent 9405960 commit e709451
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 290 deletions.
2 changes: 1 addition & 1 deletion src/qseek/features/ground_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

from qseek.features.base import EventFeature, FeatureExtractor, ReceiverFeature
from qseek.features.utils import ChannelSelectors
from qseek.utils import ChannelSelectors

if TYPE_CHECKING:
from pyrocko.squirrel import Squirrel
Expand Down
41 changes: 0 additions & 41 deletions src/qseek/features/utils.py

This file was deleted.

29 changes: 29 additions & 0 deletions src/qseek/magnitudes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from pyrocko.squirrel import Squirrel

from qseek.models.detection import EventDetection
from qseek.models.station import Stations
from qseek.octree import Octree


class EventMagnitude(BaseModel):
Expand Down Expand Up @@ -59,4 +61,31 @@ async def add_magnitude(
squirrel: Squirrel,
event: EventDetection,
) -> None:
"""
Adds a magnitude to the squirrel for the given event.
Args:
squirrel (Squirrel): The squirrel object to add the magnitude to.
event (EventDetection): The event detection object.
Raises:
NotImplementedError: This method is not implemented in the base class.
"""
raise NotImplementedError

async def prepare(
self,
octree: Octree,
stations: Stations,
) -> None:
"""
Prepare the magnitudes calculation by initializing necessary data structures.
Args:
octree (Octree): The octree containing seismic event data.
stations (Stations): The stations containing seismic station data.
Raises:
NotImplementedError: This method must be implemented by subclasses.
"""
raise NotImplementedError
5 changes: 3 additions & 2 deletions src/qseek/magnitudes/local_magnitude_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import numpy as np
from pyrocko.trace import PoleZeroResponse

from qseek.features.utils import ChannelSelector, ChannelSelectors
from qseek.utils import MeasurementUnit
from qseek.utils import ChannelSelector, ChannelSelectors, MeasurementUnit

if TYPE_CHECKING:
from pyrocko.trace import Trace
Expand Down Expand Up @@ -109,6 +108,8 @@ class StationAmplitudes(NamedTuple):
@property
def anr(self) -> float:
"""Amplitude to noise ratio."""
if self.noise == 0.0:
return 0.0
return self.peak / self.noise

@classmethod
Expand Down
Loading

0 comments on commit e709451

Please sign in to comment.