-
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.
Adjustments to backend (and related required changes to frontend) in …
…preparation of 2D viewer (#808) Co-authored-by: Hans Kallekleiv <[email protected]>
- Loading branch information
1 parent
a028574
commit 20542c9
Showing
64 changed files
with
1,122 additions
and
881 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
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,50 @@ | ||
from typing import List | ||
|
||
import orjson | ||
import numpy as np | ||
import xtgeo | ||
|
||
from . import schemas | ||
|
||
|
||
def surface_to_float32_array(values: np.ndarray) -> List[float]: | ||
values = values.astype(np.float32) | ||
np.ma.set_fill_value(values, 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() | ||
|
||
|
||
def to_api_surface_data( | ||
xtgeo_surf: xtgeo.RegularSurface, property_values: np.ndarray | ||
) -> schemas.SurfaceMeshAndProperty: | ||
""" | ||
Create API SurfaceData from xtgeo regular surface | ||
""" | ||
float32_mesh = surface_to_float32_array(xtgeo_surf.values) | ||
float32_property = surface_to_float32_array(property_values) | ||
|
||
return schemas.SurfaceMeshAndProperty( | ||
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, | ||
x_min=xtgeo_surf.xmin, | ||
x_max=xtgeo_surf.xmax, | ||
y_min=xtgeo_surf.ymin, | ||
y_max=xtgeo_surf.ymax, | ||
mesh_value_min=xtgeo_surf.values.min(), | ||
mesh_value_max=xtgeo_surf.values.max(), | ||
property_value_min=property_values.min(), | ||
property_value_max=property_values.max(), | ||
rot_deg=xtgeo_surf.rotation, | ||
mesh_data=orjson.dumps(float32_mesh).decode("utf-8"), # pylint: disable=maybe-no-member | ||
property_data=orjson.dumps(float32_property).decode("utf-8"), # pylint: disable=maybe-no-member | ||
) |
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
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
Oops, something went wrong.