Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of 2D viewer module with layer framework and persistence #805

Closed
wants to merge 108 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
0d1914e
cherry pick from `spike-layer-system`
rubenthoms Sep 16, 2024
ec5a90a
Intersection wellpicks bug fix
rubenthoms Sep 16, 2024
8b153d7
wip
rubenthoms Sep 16, 2024
7115e1b
wip
rubenthoms Sep 17, 2024
33e6d5e
Started implementing color scales
rubenthoms Sep 17, 2024
da12858
wip
rubenthoms Sep 18, 2024
e0e7f56
wip
rubenthoms Sep 18, 2024
1ac2851
Fix surface layer data
HansKallekleiv Sep 19, 2024
1e66c22
fix nginx
HansKallekleiv Sep 19, 2024
a1dee84
wip
rubenthoms Sep 19, 2024
a51eb3e
multiple fixes
rubenthoms Sep 20, 2024
2e092df
Add more shared settings
HansKallekleiv Sep 20, 2024
99ae0fd
Allow missing vertical domain
HansKallekleiv Sep 20, 2024
e212918
wip
rubenthoms Sep 20, 2024
385f70a
Merge branch 'new-2d-viewer' of https://github.com/rubenthoms/webviz …
rubenthoms Sep 20, 2024
5ff0cf8
wip
rubenthoms Sep 23, 2024
e8c603c
wip
rubenthoms Sep 23, 2024
a736927
Merge branch 'new-2d-viewer' of github.com:rubenthoms/webviz into new…
HansKallekleiv Sep 23, 2024
426cb57
Handle missing well metadata
HansKallekleiv Sep 23, 2024
02d7641
Temporarily increate trajectories cache time until we sort it out
HansKallekleiv Sep 23, 2024
23ff60c
fix color scale
rubenthoms Sep 23, 2024
101e0d3
Merge branch 'new-2d-viewer' of https://github.com/rubenthoms/webviz …
rubenthoms Sep 23, 2024
62c7ce8
Get stratigraphical column using uuid not name
HansKallekleiv Sep 23, 2024
bd6755b
Merge branch 'new-2d-viewer' of github.com:rubenthoms/webviz into new…
HansKallekleiv Sep 23, 2024
6173358
implementation of loading
rubenthoms Sep 23, 2024
0c93e1a
Merge branch 'new-2d-viewer' of https://github.com/rubenthoms/webviz …
rubenthoms Sep 23, 2024
44345db
fix color scales
rubenthoms Sep 23, 2024
faacbe7
loading/no views state + reset view port
rubenthoms Sep 24, 2024
c4a7af6
Merge remote-tracking branch 'equinor/main' into new-2d-viewer
rubenthoms Sep 26, 2024
ae5553a
Remove dup import
HansKallekleiv Sep 26, 2024
ae1fbb9
Read seismic from first valid realization
HansKallekleiv Sep 26, 2024
99616c9
Use color scale min/max in surface layers
HansKallekleiv Sep 27, 2024
a3843f0
Rewrite SMDA wip. Add well picks layer
HansKallekleiv Oct 1, 2024
e207c04
wip
HansKallekleiv Oct 2, 2024
bacc4d6
Fix well layers bounding box
HansKallekleiv Oct 2, 2024
e4bca3c
improve picks layer
HansKallekleiv Oct 2, 2024
0ab11e8
wip
HansKallekleiv Oct 2, 2024
bebec67
wip
rubenthoms Oct 8, 2024
5bafab7
Added launch config
rubenthoms Oct 9, 2024
218376e
Merge remote-tracking branch 'jorgenherje/main' into new-2d-viewer
rubenthoms Oct 9, 2024
3ca83ed
wip
rubenthoms Oct 10, 2024
6c2da4c
Merge remote-tracking branch 'equinor/main' into new-2d-viewer
rubenthoms Oct 11, 2024
2fc29c2
wip
rubenthoms Oct 11, 2024
979580b
wip
rubenthoms Oct 14, 2024
5ca22c7
wip
rubenthoms Oct 15, 2024
fe7c1fe
wip
rubenthoms Oct 15, 2024
b931aba
StatisticalSurface fix: Use wildcard when no realizationfilter is active
HansKallekleiv Oct 16, 2024
f589b86
wip
rubenthoms Oct 16, 2024
db2518b
Merge remote-tracking branch 'rubenthoms/new-2d-viewer' into new-2d-v…
rubenthoms Oct 16, 2024
553aa51
wip
rubenthoms Oct 17, 2024
e9dce08
Remove slot identifier
HansKallekleiv Oct 17, 2024
8bf4d8b
wip
rubenthoms Oct 17, 2024
5312fb5
Merge remote-tracking branch 'rubenthoms/new-2d-viewer' into new-2d-v…
rubenthoms Oct 17, 2024
3307d93
Merge remote-tracking branch 'jorgenherje/main' into new-2d-viewer
rubenthoms Oct 17, 2024
a355f05
fix format
rubenthoms Oct 17, 2024
765e861
pylint fixes
rubenthoms Oct 17, 2024
3c9e72a
fix linting issues
rubenthoms Oct 17, 2024
51d0164
wip
rubenthoms Oct 18, 2024
e7026df
wip
rubenthoms Oct 21, 2024
27d38a2
Merge remote-tracking branch 'equinor/main' into new-2d-viewer
rubenthoms Oct 22, 2024
3b176a8
Whitelist CCS polygons as polygons attribute
HansKallekleiv Oct 22, 2024
25e21e8
Merge remote-tracking branch 'origin/new-2d-viewer' into 2d-viewer-pe…
rubenthoms Oct 22, 2024
2f2e79a
wip
rubenthoms Oct 22, 2024
5f8013d
wip
rubenthoms Oct 22, 2024
a92dbc0
wip
rubenthoms Oct 22, 2024
d26329f
wip
rubenthoms Oct 23, 2024
2d0f32b
wip
rubenthoms Oct 23, 2024
5ba0b03
First working version
rubenthoms Oct 23, 2024
833d09d
wip
rubenthoms Oct 24, 2024
3a120d8
wip
rubenthoms Oct 24, 2024
d090805
fix: view could be moved into view
rubenthoms Oct 25, 2024
0df4d30
Merge branch 'new-2d-viewer' into 2d-viewer-persistence
rubenthoms Oct 25, 2024
916ad1c
Merge branch '2d-viewer-persistence' of https://github.com/rubenthoms…
rubenthoms Oct 25, 2024
e80eded
wip
rubenthoms Oct 25, 2024
df63761
wip
rubenthoms Oct 25, 2024
bc584e8
First spike definition
rubenthoms Oct 25, 2024
c58896b
wip
rubenthoms Oct 28, 2024
39c89a0
wip
rubenthoms Nov 1, 2024
aa8c61b
wip
rubenthoms Nov 5, 2024
a78a821
wip
rubenthoms Nov 5, 2024
27fb7d0
StatisticalLayer - sensitivity not working
HansKallekleiv Nov 5, 2024
cba3c1a
ObservedSurfaceLayer
HansKallekleiv Nov 5, 2024
587cfe5
Removed unused code and changed color scheme of delete button
rubenthoms Nov 6, 2024
05b4adb
wip
rubenthoms Nov 6, 2024
4c88b81
wip
rubenthoms Nov 6, 2024
a7c9e32
wip
rubenthoms Nov 6, 2024
ce540fb
Grid layer
HansKallekleiv Nov 6, 2024
09b82ed
Real polygons
HansKallekleiv Nov 6, 2024
89b7c2f
Welltraj layers
HansKallekleiv Nov 6, 2024
231f00b
wip
rubenthoms Nov 6, 2024
57479f9
Merge remote-tracking branch 'rubenthoms/2d-viewer-context-deps-spike…
rubenthoms Nov 6, 2024
e4dfcd5
Framework fixes and improvements
rubenthoms Nov 7, 2024
c99a7d2
Started some adjustments to DeckGL WellPicksLayer
rubenthoms Nov 7, 2024
35b18aa
fix
rubenthoms Nov 8, 2024
264524a
wip
rubenthoms Nov 11, 2024
6e2dcff
wip
rubenthoms Nov 12, 2024
1ca3234
Multiple bug fixes and features
rubenthoms Nov 12, 2024
6928469
Merge remote-tracking branch 'equinor/main' into 2d-viewer-context-de…
rubenthoms Nov 12, 2024
dcedae7
Minor bug fixes and improvements
rubenthoms Nov 13, 2024
9cb0a65
Code improvements
rubenthoms Nov 13, 2024
af5df06
Code improvements
rubenthoms Nov 13, 2024
6164958
Added persistence of layout and field id
rubenthoms Nov 13, 2024
34543c3
wip
rubenthoms Nov 13, 2024
6bec37c
fix: using wrong way to collect ensembles
rubenthoms Nov 14, 2024
68ca037
Merge remote-tracking branch 'origin/main' into 2d-viewer-context-dep…
rubenthoms Nov 14, 2024
c405a46
Several fixes
rubenthoms Nov 14, 2024
e322fd6
fix: keeping state when shared setting removed
rubenthoms Nov 15, 2024
4151351
fix
rubenthoms Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 28 additions & 19 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
{
"configurations": [
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": { "host": "localhost", "port": 5678 },
"pathMappings": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": { "host": "localhost", "port": 5678 },
"pathMappings": [
{
"localRoot": "${workspaceFolder}/backend_py/primary",
"remoteRoot": "/home/appuser/backend_py/primary"
}
]
},
{
"name": "TS: Launch Chrome and Attach",
"request": "launch",
"type": "chrome",
"webRoot": "${workspaceFolder}/frontend",
"url": "http://localhost:8080"
"localRoot": "${workspaceFolder}/backend_py/primary",
"remoteRoot": "/home/appuser/backend_py/primary"
}
]
]
},
{
"name": "TS: Launch Chrome and Attach",
"request": "launch",
"type": "chrome",
"webRoot": "${workspaceFolder}/frontend",
"url": "http://localhost:8080"
},
{
"name": "TS: Attach",
"request": "attach",
"type": "chrome",
"port": 8080,
"restart": true,
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/frontend/dist/**/*.js"]
}
]
}
3 changes: 3 additions & 0 deletions backend_py/primary/primary/routers/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class EnsembleInfo(BaseModel):
class EnsembleDetails(BaseModel):
name: str
field_identifier: str
stratigraphic_column_identifier: str
case_name: str
case_uuid: str
realizations: Sequence[int]
Expand Down Expand Up @@ -91,6 +92,7 @@ async def get_ensemble_details(
case_name = await case_inspector.get_case_name_async()
realizations = await case_inspector.get_realizations_in_iteration_async(ensemble_name)
field_identifiers = await case_inspector.get_field_identifiers_async()
stratigraphic_column_identifier = await case_inspector.get_stratigraphic_column_identifier_async()

if len(field_identifiers) != 1:
raise NotImplementedError("Multiple field identifiers not supported")
Expand All @@ -101,4 +103,5 @@ async def get_ensemble_details(
case_uuid=case_uuid,
realizations=realizations,
field_identifier=field_identifiers[0],
stratigraphic_column_identifier=stratigraphic_column_identifier,
)
13 changes: 7 additions & 6 deletions backend_py/primary/primary/routers/polygons/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from webviz_pkg.core_utils.perf_timer import PerfTimer

from primary.auth.auth_helper import AuthHelper
from primary.services.smda_access.mocked_drogon_smda_access import _mocked_stratigraphy_access
from primary.services.smda_access.stratigraphy_access import StratigraphyAccess
from primary.services.smda_access.drogon import DrogonSmdaAccess
from primary.services.smda_access import SmdaAccess
from primary.services.smda_access.stratigraphy_utils import sort_stratigraphic_names_by_hierarchy
from primary.services.sumo_access.case_inspector import CaseInspector
from primary.services.sumo_access.polygons_access import PolygonsAccess
Expand Down Expand Up @@ -34,14 +34,15 @@ async def get_polygons_directory(
polygons_dir = await access.get_polygons_directory_async()

case_inspector = CaseInspector.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid)
field_identifiers = await case_inspector.get_field_identifiers_async()
strat_column_identifier = await case_inspector.get_stratigraphic_column_identifier_async()
strat_access: Union[StratigraphyAccess, _mocked_stratigraphy_access.StratigraphyAccess]
smda_access: Union[SmdaAccess, DrogonSmdaAccess]

if strat_column_identifier == "DROGON_HAS_NO_STRATCOLUMN":
strat_access = _mocked_stratigraphy_access.StratigraphyAccess(authenticated_user.get_smda_access_token())
smda_access = DrogonSmdaAccess()
else:
strat_access = StratigraphyAccess(authenticated_user.get_smda_access_token())
strat_units = await strat_access.get_stratigraphic_units(strat_column_identifier)
smda_access = SmdaAccess(authenticated_user.get_smda_access_token(), field_identifier=field_identifiers[0])
strat_units = await smda_access.get_stratigraphic_units(strat_column_identifier)
sorted_stratigraphic_surfaces = sort_stratigraphic_names_by_hierarchy(strat_units)

return converters.to_api_polygons_directory(polygons_dir, sorted_stratigraphic_surfaces)
Expand Down
1 change: 1 addition & 0 deletions backend_py/primary/primary/routers/polygons/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class PolygonsAttributeType(str, Enum):
PINCHOUT = "pinchout" # Values are pinchouts
SUBCROP = "subcrop" # Values are subcrops
FAULT_LINES = "fault_lines" # Values are fault lines
NAMED_AREA = "named_area" # Values are named areas, e.g. CCS containment polygons


class PolygonsMeta(BaseModel):
Expand Down
50 changes: 50 additions & 0 deletions backend_py/primary/primary/routers/seismic/converters.py
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)
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()


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), # pylint: disable=maybe-no-member
property_data=orjson.dumps(float32_property), # pylint: disable=maybe-no-member
)
20 changes: 20 additions & 0 deletions backend_py/primary/primary/routers/seismic/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,23 @@ class SeismicFenceData(BaseModel):
num_samples_per_trace: int
min_fence_depth: float
max_fence_depth: float


class SurfaceMeshAndProperty(BaseModel):
x_ori: float
y_ori: float
x_count: int
y_count: int
x_inc: float
y_inc: float
x_min: float
x_max: float
y_min: float
y_max: float
mesh_value_min: float
mesh_value_max: float
property_value_min: float
property_value_max: float
rot_deg: float
mesh_data: str
property_data: str
20 changes: 20 additions & 0 deletions backend_py/primary/primary/routers/surface/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from primary.services.utils.surface_intersect_with_polyline import XtgeoSurfaceIntersectionResult
from primary.services.utils.surface_to_float32 import surface_to_float32_numpy_array
from primary.services.utils.surface_to_png import surface_to_png_bytes_optimized
from primary.services.smda_access import StratigraphicUnit

from . import schemas

Expand Down Expand Up @@ -174,3 +175,22 @@ def to_api_surface_intersection(
z_points=xtgeo_surface_intersection.zval,
cum_lengths=xtgeo_surface_intersection.distance,
)


def to_api_stratigraphic_unit(
stratigraphic_unit: StratigraphicUnit,
) -> schemas.StratigraphicUnit:
return schemas.StratigraphicUnit(
identifier=stratigraphic_unit.identifier,
top=stratigraphic_unit.top,
base=stratigraphic_unit.base,
stratUnitLevel=stratigraphic_unit.strat_unit_level,
stratUnitType=stratigraphic_unit.strat_unit_type,
topAge=stratigraphic_unit.top_age,
baseAge=stratigraphic_unit.base_age,
stratUnitParent=stratigraphic_unit.strat_unit_parent,
colorR=stratigraphic_unit.color_r,
colorG=stratigraphic_unit.color_g,
colorB=stratigraphic_unit.color_b,
lithologyType=stratigraphic_unit.lithology_type,
)
31 changes: 25 additions & 6 deletions backend_py/primary/primary/routers/surface/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

from primary.services.sumo_access.case_inspector import CaseInspector
from primary.services.sumo_access.surface_access import SurfaceAccess
from primary.services.smda_access.stratigraphy_access import StratigraphyAccess, StratigraphicUnit
from primary.services.smda_access import SmdaAccess, StratigraphicUnit
from primary.services.smda_access.stratigraphy_utils import sort_stratigraphic_names_by_hierarchy
from primary.services.smda_access.mocked_drogon_smda_access import _mocked_stratigraphy_access
from primary.services.smda_access.drogon import DrogonSmdaAccess
from primary.services.utils.statistic_function import StatisticFunction
from primary.services.utils.surface_intersect_with_polyline import intersect_surface_with_polyline
from primary.services.utils.authenticated_user import AuthenticatedUser
Expand Down Expand Up @@ -295,22 +295,41 @@ async def get_misfit_surface_data(
raise HTTPException(status.HTTP_501_NOT_IMPLEMENTED)


@router.get("/stratigraphic_units")
async def get_stratigraphic_units(
# fmt:off
response: Response,
authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)],
case_uuid: Annotated[str, Query(description="Sumo case uuid")],
# fmt:on
) -> list[schemas.StratigraphicUnit]:
perf_metrics = ResponsePerfMetrics(response)

strat_units = await _get_stratigraphic_units_for_case_async(authenticated_user, case_uuid)
api_strat_units = [converters.to_api_stratigraphic_unit(strat_unit) for strat_unit in strat_units]

LOGGER.info(f"Got stratigraphic units in: {perf_metrics.to_string()}")

return api_strat_units


async def _get_stratigraphic_units_for_case_async(
authenticated_user: AuthenticatedUser, case_uuid: str
) -> list[StratigraphicUnit]:
perf_metrics = PerfMetrics()

case_inspector = CaseInspector.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid)
field_identifiers = await case_inspector.get_field_identifiers_async()
strat_column_identifier = await case_inspector.get_stratigraphic_column_identifier_async()
perf_metrics.record_lap("get-strat-ident")

strat_access: StratigraphyAccess | _mocked_stratigraphy_access.StratigraphyAccess
smda_access: SmdaAccess | DrogonSmdaAccess
if strat_column_identifier == "DROGON_HAS_NO_STRATCOLUMN":
strat_access = _mocked_stratigraphy_access.StratigraphyAccess(authenticated_user.get_smda_access_token())
smda_access = DrogonSmdaAccess()
else:
strat_access = StratigraphyAccess(authenticated_user.get_smda_access_token())
smda_access = SmdaAccess(authenticated_user.get_smda_access_token(), field_identifier=field_identifiers[0])

strat_units = await strat_access.get_stratigraphic_units(strat_column_identifier)
strat_units = await smda_access.get_stratigraphic_units(strat_column_identifier)
perf_metrics.record_lap("get-strat-units")

LOGGER.info(f"Got stratigraphic units for case in : {perf_metrics.to_string()}")
Expand Down
15 changes: 15 additions & 0 deletions backend_py/primary/primary/routers/surface/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,18 @@ class SurfaceRealizationSampleValues(BaseModel):
class PointSetXY(BaseModel):
x_points: list[float]
y_points: list[float]


class StratigraphicUnit(BaseModel):
identifier: str
top: str
base: str
stratUnitLevel: int
stratUnitType: str
topAge: int | float
baseAge: int | float
stratUnitParent: str | None
colorR: int
colorG: int
colorB: int
lithologyType: int | float | str = "unknown"
3 changes: 3 additions & 0 deletions backend_py/primary/primary/routers/well/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def convert_wellbore_pick_to_schema(wellbore_pick: WellborePick) -> schemas.Well
md=wellbore_pick.md,
mdMsl=wellbore_pick.md_msl,
uniqueWellboreIdentifier=wellbore_pick.unique_wellbore_identifier,
wellboreUuid=wellbore_pick.wellbore_uuid,
pickIdentifier=wellbore_pick.pick_identifier,
confidence=wellbore_pick.confidence,
depthReferencePoint=wellbore_pick.depth_reference_point,
Expand Down Expand Up @@ -57,6 +58,8 @@ def convert_wellbore_header_to_schema(
wellNorthing=drilled_wellbore_header.well_northing,
depthReferencePoint=drilled_wellbore_header.depth_reference_point,
depthReferenceElevation=drilled_wellbore_header.depth_reference_elevation,
wellborePurpose=(drilled_wellbore_header.wellbore_purpose if drilled_wellbore_header.wellbore_purpose else ""),
wellboreStatus=drilled_wellbore_header.wellbore_status if drilled_wellbore_header.wellbore_status else "",
)


Expand Down
Loading
Loading