forked from equinor/webviz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved surface intersection functionality out of SurfaceAccess class (e…
- Loading branch information
Showing
5 changed files
with
73 additions
and
86 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
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
40 changes: 3 additions & 37 deletions
40
backend_py/primary/primary/services/sumo_access/surface_types.py
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 |
---|---|---|
@@ -1,47 +1,13 @@ | ||
from __future__ import annotations | ||
|
||
from typing import List, Optional | ||
|
||
from pydantic import BaseModel | ||
from .generic_types import SumoContent | ||
|
||
|
||
class SurfaceMeta(BaseModel): | ||
name: str | ||
tagname: str | ||
iso_date_or_interval: Optional[str] = None | ||
iso_date_or_interval: str | None = None | ||
content: SumoContent | ||
is_observation: bool | ||
is_stratigraphic: bool | ||
zmin: Optional[float] = None | ||
zmax: Optional[float] = None | ||
|
||
|
||
class XtgeoSurfaceIntersectionPolyline(BaseModel): | ||
""" | ||
Type definition for surface intersection polyline data needed as `fencespec` argument | ||
for the xtgeo.get_randomline() function | ||
The polyline is defined by the `X`, `Y`, `Z` and `HLEN` fields, and is provided to | ||
the `get_randomline()` function as a list of `XtgeoSurfaceIntersectionPolyline` objects | ||
""" | ||
|
||
X: List[float] | ||
Y: List[float] | ||
Z: List[float] | ||
HLEN: List[float] | ||
|
||
|
||
class XtgeoSurfaceIntersectionResult(BaseModel): | ||
""" | ||
Type definition for surface intersection data from xtgeo.get_randomline() function | ||
The `name` field is in addition to the fields returned by the `get_randomline()` function | ||
`zval` are the z values of the intersection points (depth values for each (x,y) point in polyline. | ||
`dist` are the distance at each z value (accumulated). | ||
""" | ||
|
||
name: str | ||
distance: List[float] | ||
zval: List[float] | ||
zmin: float | None = None | ||
zmax: float | None = None |
56 changes: 56 additions & 0 deletions
56
backend_py/primary/primary/services/utils/surface_intersect_with_polyline.py
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,56 @@ | ||
from pydantic import BaseModel | ||
import xtgeo | ||
import numpy as np | ||
|
||
|
||
class XtgeoSurfaceIntersectionPolyline(BaseModel): | ||
""" | ||
Type definition for surface intersection polyline data needed as `fencespec` argument | ||
for the xtgeo.get_randomline() function | ||
The polyline is defined by the `X`, `Y`, `Z` and `HLEN` fields, and is provided to | ||
the `get_randomline()` function as a list of `XtgeoSurfaceIntersectionPolyline` objects | ||
""" | ||
|
||
X: list[float] | ||
Y: list[float] | ||
Z: list[float] | ||
HLEN: list[float] | ||
|
||
|
||
class XtgeoSurfaceIntersectionResult(BaseModel): | ||
""" | ||
Type definition for surface intersection data from xtgeo.get_randomline() function | ||
The `name` field is in addition to the fields returned by the `get_randomline()` function | ||
`zval` are the z values of the intersection points (depth values for each (x,y) point in polyline. | ||
`dist` are the distance at each z value (accumulated). | ||
""" | ||
|
||
name: str | ||
distance: list[float] | ||
zval: list[float] | ||
|
||
|
||
def intersect_surface_with_polyline( | ||
surface: xtgeo.RegularSurface, | ||
polyline: XtgeoSurfaceIntersectionPolyline, | ||
) -> XtgeoSurfaceIntersectionResult: | ||
""" | ||
Get intersection of realization surface for requested surface name | ||
""" | ||
# The input fencespec is a 2D numpy where each row is X, Y, Z, HLEN, | ||
# where X, Y are UTM coordinates, Z is depth/time, and HLEN is a | ||
# length along the fence. | ||
xtgeo_fencespec = np.array([polyline.X, polyline.Y, polyline.Z, polyline.HLEN]).T | ||
|
||
line = surface.get_randomline(xtgeo_fencespec) | ||
|
||
intersection = XtgeoSurfaceIntersectionResult( | ||
name=f"{surface.name}", | ||
distance=line[:, 0].tolist(), | ||
zval=line[:, 1].tolist(), | ||
) | ||
|
||
return intersection |