-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use wsc.SubsurfaceViewer in map module (#73)
- Loading branch information
1 parent
1f486cc
commit e3fab0c
Showing
9 changed files
with
157 additions
and
62 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,25 @@ | ||
import base64 | ||
|
||
import orjson | ||
import xtgeo | ||
|
||
from src.services.utils.surface_to_png import surface_to_png_bytes_optimized | ||
from src.services.utils.surface_orientation import ( | ||
calc_surface_orientation_for_colormap_layer, | ||
) | ||
from src.services.utils.surface_to_float32 import surface_to_float32_array | ||
from . import schemas | ||
|
||
|
||
def to_api_surface_data(xtgeo_surf: xtgeo.RegularSurface) -> schemas.SurfaceData: | ||
""" | ||
Create API SurfaceData from xtgeo regular surface | ||
""" | ||
png_bytes: bytes = surface_to_png_bytes_optimized(xtgeo_surf) | ||
base64_data = base64.b64encode(png_bytes).decode("ascii") | ||
|
||
surf_orient = calc_surface_orientation_for_colormap_layer(xtgeo_surf) | ||
float32values = surface_to_float32_array(xtgeo_surf) | ||
|
||
return schemas.SurfaceData( | ||
x_min=surf_orient.x_min, | ||
x_max=surf_orient.x_max, | ||
y_min=surf_orient.y_min, | ||
y_max=surf_orient.y_max, | ||
x_ori=xtgeo_surf.xori, | ||
y_ori=xtgeo_surf.yori, | ||
x_count=xtgeo_surf.ncol, | ||
y_count=xtgeo_surf.nrow, | ||
x_inc=xtgeo_surf.xinc, | ||
y_inc=xtgeo_surf.yinc, | ||
val_min=xtgeo_surf.values.min(), | ||
val_max=xtgeo_surf.values.max(), | ||
rot_deg=surf_orient.rot_around_xmin_ymax_deg, | ||
base64_encoded_image=f"{base64_data}", | ||
rot_deg=xtgeo_surf.rotation, | ||
mesh_data=orjson.dumps(float32values), | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from typing import List | ||
|
||
import numpy as np | ||
import xtgeo | ||
|
||
|
||
def surface_to_float32_array(surface: xtgeo.RegularSurface) -> List[float]: | ||
values = surface.values.astype(np.float32) | ||
values.fill_value = np.nan | ||
values = np.ma.filled(values) | ||
|
||
# Rotate 90 deg left. | ||
# This will cause the width of to run along the X axis | ||
# and height of along Y axis (starting from bottom.) | ||
values = np.rot90(values) | ||
|
||
return values.flatten().tolist() |
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