Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
miili committed Nov 5, 2023
1 parent 8128f59 commit 20fb86b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
6 changes: 3 additions & 3 deletions lassie/models/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,16 @@ class EventDetection(Location):
)

in_bounds: bool = Field(
True,
default=True,
description="Is detection in bounds, and inside the configured border.",
)

magnitude: float | None = Field(
None,
default=None,
description="Detection magnitude or semblance.",
)
magnitude_type: str | None = Field(
None,
default=None,
description="Magnitude type.",
)

Expand Down
12 changes: 7 additions & 5 deletions lassie/octree.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,16 @@ def check_limits(self) -> Octree:
"""Check that the size limits are valid."""
if self.size_limit > self.size_initial:
raise ValueError(
f"invalid octree size limits ({self.size_initial}, {self.size_limit}),"
" expected size_limit <= size_initial"
f"invalid octree size limits ({self.size_initial}, {self.size_limit}):"
" Expected size_limit <= size_initial"
)
for ext in self.extent():
for dimension, ext in zip(
("east", "north", "depth"), self.extent(), strict=True
):
if ext % self.size_initial:
raise ValueError(
f"invalid octree size limits ({self.size_initial}, {self.size_limit}),"
" expected size_initial to be a multiple of the extent"
f"invalid octree initial_size {self.size_initial}:"
f" Not a multiple in {dimension} with size {ext}"
)
return self

Expand Down
14 changes: 8 additions & 6 deletions lassie/tracers/fast_marching/velocity_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ def depth_coords(self) -> np.ndarray:

@property
def east_size(self) -> float:
return self._east_coords.size * self.grid_spacing
return self.east_bounds[1] - self.east_bounds[0]

@property
def north_size(self) -> float:
return self._north_coords.size * self.grid_spacing
return self.north_bounds[1] - self.north_bounds[0]

@property
def depth_size(self) -> float:
return self._depth_coords.size * self.grid_spacing
return self.depth_bounds[1] - self.depth_bounds[0]

def hash(self) -> str:
"""Return hash of velocity model.
Expand Down Expand Up @@ -387,17 +387,19 @@ def grid_spacing(self) -> float:
@property
def east_bounds(self) -> tuple[float, float]:
"""Relative to center location."""
return -self.delta_x * self.nx / 2, self.delta_x * self.nx / 2
size = self.delta_x * (self.nx - 1)
return -size / 2, size / 2

@property
def north_bounds(self) -> tuple[float, float]:
"""Relative to center location."""
return -self.delta_y * self.ny / 2, self.delta_y * self.ny / 2
size = self.delta_y * (self.ny - 1)
return -size / 2, size / 2

@property
def depth_bounds(self) -> tuple[float, float]:
"""Relative to center location."""
return 0, self.delta_z * self.nz
return 0.0, self.delta_z * self.nz

@property
def center(self) -> Location:
Expand Down
11 changes: 7 additions & 4 deletions test/test_fast_marching.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,16 @@ def stations_inside(


def octree_cover(model: VelocityModel3D) -> Octree:
east_excess = KM - model.east_size % (1 * KM)
north_excess = KM - model.north_size % (1 * KM)
depth_excess = KM - model.depth_size % (1 * KM)
return Octree(
location=model.center,
size_initial=2 * KM,
size_initial=1 * KM,
size_limit=500,
east_bounds=model.east_bounds,
north_bounds=model.north_bounds,
depth_bounds=model.depth_bounds,
east_bounds=(model.east_bounds[0], model.east_bounds[1] + east_excess),
north_bounds=(model.north_bounds[0], model.north_bounds[1] + north_excess),
depth_bounds=(model.depth_bounds[0], model.depth_bounds[1] + depth_excess),
absorbing_boundary=0,
)

Expand Down

0 comments on commit 20fb86b

Please sign in to comment.