Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Marius Isken committed Feb 8, 2024
1 parent 36dbbc7 commit 8e138aa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/qseek/models/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ def get_csv_dict(self) -> dict[str, Any]:
"time": self.time,
"lat": round(self.effective_lat, 6),
"lon": round(self.effective_lon, 6),
"depth": round(self.effective_depth, 2),
"depth_ellipsoid": round(self.effective_depth, 2),
"east_shift": round(self.east_shift, 2),
"north_shift": round(self.north_shift, 2),
"distance_border": round(self.distance_border, 2),
Expand Down
11 changes: 6 additions & 5 deletions src/qseek/pre_processing/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ def select_traces(self, batch: WaveformBatch) -> list[Trace]:
"""
if not self.stations:
return batch.traces
return [
trace
for trace in batch.traces
if NSL.parse(trace.nslc_id).station in self.stations
]
traces: list[Trace] = []
for trace in batch.traces:
for station in self.stations:
if station.match(NSL.parse(trace.nslc_id)):
traces.append(trace)
return traces

async def prepare(self) -> None:
"""
Expand Down
23 changes: 12 additions & 11 deletions src/qseek/pre_processing/frequency_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pydantic import Field, PositiveFloat, field_validator

from qseek.pre_processing.base import BatchPreProcessing
from qseek.utils import Range

if TYPE_CHECKING:
from qseek.waveforms.base import WaveformBatch
Expand All @@ -17,22 +18,22 @@ class Bandpass(BatchPreProcessing):
process: Literal["bandpass"] = "bandpass"

corners: int = Field(
4,
default=4,
ge=2,
description="Number of corners for the filter.",
)
bandpass: tuple[PositiveFloat, PositiveFloat] = Field(
0.1,
bandpass: Range = Field(
default=Range(0.1, 40.0),
description="The highpass frequency.",
)
demean: bool = Field(
True,
default=True,
description="If True, demean the trace before filtering.",
)

@field_validator("bandpass")
@classmethod
def _check_bandpass(cls, value) -> tuple[PositiveFloat, PositiveFloat]:
def _check_bandpass(cls, value) -> Range:
if value[0] >= value[1]:
raise ValueError(
"The lowpass frequency must be smaller than the highpass frequency."
Expand All @@ -58,16 +59,16 @@ class Highpass(BatchPreProcessing):

process: Literal["highpass"] = "highpass"
corners: int = Field(
4,
default=4,
ge=2,
description="Number of corners for the filter.",
)
frequency: PositiveFloat = Field(
0.1,
default=0.1,
description="The highpass frequency.",
)
demean: bool = Field(
True,
default=True,
description="If True, demean the trace before filtering.",
)

Expand All @@ -89,16 +90,16 @@ class Lowpass(BatchPreProcessing):

process: Literal["lowpass"] = "lowpass"
corners: int = Field(
4,
default=4,
ge=2,
description="Number of corners for the filter.",
)
frequency: PositiveFloat = Field(
0.1,
default=0.1,
description="The highpass frequency.",
)
demean: bool = Field(
True,
default=True,
description="If True, demean the trace before filtering.",
)

Expand Down
4 changes: 2 additions & 2 deletions src/qseek/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def parse(cls, nsl: str) -> NSL:
raise ValueError("invalid empty NSL")
parts = nsl.split(".")
n_parts = len(parts)
if n_parts == 3:
return cls(*parts)
if n_parts >= 3:
return cls(*parts[:3])
if n_parts == 2:
return cls(parts[0], parts[1], "")
if n_parts == 1:
Expand Down

0 comments on commit 8e138aa

Please sign in to comment.