Skip to content

Commit

Permalink
Merge remote-tracking branch 'equinor/main' into 216-delta-ensembles-…
Browse files Browse the repository at this point in the history
…simulation-time-series
  • Loading branch information
jorgenherje committed Dec 13, 2024
2 parents 6db040e + 3889e17 commit bbbb19f
Show file tree
Hide file tree
Showing 51 changed files with 508 additions and 258 deletions.
6 changes: 3 additions & 3 deletions backend_py/primary/primary/routers/polygons/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from primary.services.sumo_access.case_inspector import CaseInspector
from primary.services.sumo_access.polygons_access import PolygonsAccess
from primary.services.utils.authenticated_user import AuthenticatedUser
from primary.utils.drogon import is_drogon_identifier

from . import converters, schemas

Expand All @@ -34,14 +35,13 @@ 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()
smda_access: Union[SmdaAccess, DrogonSmdaAccess]

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

Expand Down
6 changes: 3 additions & 3 deletions backend_py/primary/primary/routers/surface/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from primary.services.surface_query_service.surface_query_service import batch_sample_surface_in_points_async
from primary.services.surface_query_service.surface_query_service import RealizationSampleResult
from primary.utils.response_perf_metrics import ResponsePerfMetrics
from primary.utils.drogon import is_drogon_identifier

from . import converters
from . import schemas
Expand Down Expand Up @@ -319,15 +320,14 @@ async def _get_stratigraphic_units_for_case_async(
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")

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

strat_units = await smda_access.get_stratigraphic_units(strat_column_identifier)
perf_metrics.record_lap("get-strat-units")
Expand Down
6 changes: 6 additions & 0 deletions backend_py/primary/primary/routers/surface/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ class PointSetXY(BaseModel):


class StratigraphicUnit(BaseModel):
"""
Stratigraphic unit from SMDA
Camel case attributes needed for esvIntersection component in front-end
"""

identifier: str
top: str
base: str
Expand Down
21 changes: 1 addition & 20 deletions backend_py/primary/primary/routers/well/converters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from primary.services.smda_access.types import WellboreHeader, WellboreTrajectory, WellborePick, StratigraphicUnit
from primary.services.smda_access.types import WellboreHeader, WellboreTrajectory, WellborePick
from primary.services.ssdl_access.types import (
WellboreCasing,
WellboreCompletion,
Expand Down Expand Up @@ -27,25 +27,6 @@ def convert_wellbore_pick_to_schema(wellbore_pick: WellborePick) -> schemas.Well
)


def convert_stratigraphic_unit_to_schema(
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,
)


def convert_wellbore_header_to_schema(
drilled_wellbore_header: WellboreHeader,
) -> schemas.WellboreHeader:
Expand Down
46 changes: 26 additions & 20 deletions backend_py/primary/primary/routers/well/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from primary.services.smda_access import SmdaAccess
from primary.services.utils.authenticated_user import AuthenticatedUser
from primary.auth.auth_helper import AuthHelper
from primary.utils.drogon import is_drogon_identifier

from primary.services.ssdl_access.well_access import WellAccess as SsdlWellAccess

Expand All @@ -27,13 +28,13 @@ async def get_drilled_wellbore_headers(
) -> List[schemas.WellboreHeader]:
"""Get wellbore headers for all wells in the field"""
well_access: Union[SmdaAccess, DrogonSmdaAccess]
if field_identifier == "DROGON":
if is_drogon_identifier(field_identifier=field_identifier):
# Handle DROGON
well_access = DrogonSmdaAccess()
else:
well_access = SmdaAccess(authenticated_user.get_smda_access_token(), field_identifier=field_identifier)
well_access = SmdaAccess(authenticated_user.get_smda_access_token())

wellbore_headers = await well_access.get_wellbore_headers()
wellbore_headers = await well_access.get_wellbore_headers(field_identifier)

return [converters.convert_wellbore_header_to_schema(wellbore_header) for wellbore_header in wellbore_headers]

Expand All @@ -48,13 +49,16 @@ async def get_well_trajectories(
) -> List[schemas.WellboreTrajectory]:
"""Get well trajectories for field"""
well_access: Union[SmdaAccess, DrogonSmdaAccess]
if field_identifier == "DROGON":
if is_drogon_identifier(field_identifier=field_identifier):
# Handle DROGON
well_access = DrogonSmdaAccess()
else:
well_access = SmdaAccess(authenticated_user.get_smda_access_token(), field_identifier=field_identifier)
well_access = SmdaAccess(authenticated_user.get_smda_access_token())

wellbore_trajectories = await well_access.get_wellbore_trajectories(wellbore_uuids=wellbore_uuids)
wellbore_trajectories = await well_access.get_wellbore_trajectories(
field_identifier=field_identifier,
wellbore_uuids=wellbore_uuids,
)

return [
converters.convert_well_trajectory_to_schema(wellbore_trajectory)
Expand All @@ -66,18 +70,17 @@ async def get_well_trajectories(
async def get_wellbore_pick_identifiers(
# fmt:off
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
field_identifier: str = Query(description="Official field identifier"),
strat_column_identifier: str = Query(description="Stratigraphic column identifier")
# fmt:on
) -> List[str]:
"""Get wellbore pick identifiers for field and stratigraphic column"""
well_access: Union[SmdaAccess, DrogonSmdaAccess]
if field_identifier == "DROGON":
if is_drogon_identifier(strat_column_identifier=strat_column_identifier):
# Handle DROGON
well_access = DrogonSmdaAccess()

else:
well_access = SmdaAccess(authenticated_user.get_smda_access_token(), field_identifier=field_identifier)
well_access = SmdaAccess(authenticated_user.get_smda_access_token())

wellbore_picks = await well_access.get_wellbore_pick_identifiers_in_stratigraphic_column(
strat_column_identifier=strat_column_identifier
Expand All @@ -95,33 +98,36 @@ async def get_wellbore_picks_for_pick_identifier(
) -> List[schemas.WellborePick]:
"""Get wellbore picks for field and pick identifier"""
well_access: Union[SmdaAccess, DrogonSmdaAccess]
if field_identifier == "DROGON":
if is_drogon_identifier(field_identifier=field_identifier):
# Handle DROGON
well_access = DrogonSmdaAccess()

else:
well_access = SmdaAccess(authenticated_user.get_smda_access_token(), field_identifier=field_identifier)
well_access = SmdaAccess(authenticated_user.get_smda_access_token())

wellbore_picks = await well_access.get_wellbore_picks_for_pick_identifier(pick_identifier=pick_identifier)
wellbore_picks = await well_access.get_wellbore_picks_for_pick_identifier(
field_identifier=field_identifier,
pick_identifier=pick_identifier,
)
return [converters.convert_wellbore_pick_to_schema(wellbore_pick) for wellbore_pick in wellbore_picks]


@router.get("/wellbore_picks_for_wellbore/")
async def get_wellbore_picks_for_wellbore(
# fmt:off
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
field_identifier: str = Query(description="Official field identifier"),
wellbore_uuid: str = Query(description="Wellbore uuid")
# fmt:on
) -> List[schemas.WellborePick]:
"""Get wellbore picks for field and pick identifier"""
well_access: Union[SmdaAccess, DrogonSmdaAccess]
if field_identifier == "DROGON":

if is_drogon_identifier(wellbore_uuid=wellbore_uuid):
# Handle DROGON
well_access = DrogonSmdaAccess()

else:
well_access = SmdaAccess(authenticated_user.get_smda_access_token(), field_identifier=field_identifier)
well_access = SmdaAccess(authenticated_user.get_smda_access_token())

wellbore_picks = await well_access.get_wellbore_picks_for_wellbore(wellbore_uuid=wellbore_uuid)
return [converters.convert_wellbore_pick_to_schema(wellbore_pick) for wellbore_pick in wellbore_picks]
Expand All @@ -137,7 +143,7 @@ async def get_wellbore_completions(
"""Get well bore completions for a single well bore"""

# Handle DROGON
if wellbore_uuid in ["drogon_horizontal", "drogon_vertical"]:
if is_drogon_identifier(wellbore_uuid=wellbore_uuid):
return []

well_access = SsdlWellAccess(authenticated_user.get_ssdl_access_token())
Expand All @@ -159,7 +165,7 @@ async def get_wellbore_casings(
"""Get well bore casings for a single well bore"""

# Handle DROGON
if wellbore_uuid in ["drogon_horizontal", "drogon_vertical"]:
if is_drogon_identifier(wellbore_uuid=wellbore_uuid):
return []

well_access = SsdlWellAccess(authenticated_user.get_ssdl_access_token())
Expand All @@ -179,7 +185,7 @@ async def get_wellbore_perforations(
"""Get well bore casing for a single well bore"""

# Handle DROGON
if wellbore_uuid in ["drogon_horizontal", "drogon_vertical"]:
if is_drogon_identifier(wellbore_uuid=wellbore_uuid):
return []

well_access = SsdlWellAccess(authenticated_user.get_ssdl_access_token())
Expand All @@ -202,7 +208,7 @@ async def get_wellbore_log_curve_headers(
"""Get all log curve headers for a single well bore"""

# Handle DROGON
if wellbore_uuid in ["drogon_horizontal", "drogon_vertical"]:
if is_drogon_identifier(wellbore_uuid=wellbore_uuid):
return []

well_access = SsdlWellAccess(authenticated_user.get_ssdl_access_token())
Expand All @@ -228,7 +234,7 @@ async def get_log_curve_data(
"""Get log curve data"""

# Handle DROGON
if wellbore_uuid in ["drogon_horizontal", "drogon_vertical"]:
if is_drogon_identifier(wellbore_uuid=wellbore_uuid):
raise NotImplementedError("DROGON log curve data not implemented")

well_access = SsdlWellAccess(authenticated_user.get_ssdl_access_token())
Expand Down
26 changes: 0 additions & 26 deletions backend_py/primary/primary/routers/well/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,6 @@
from pydantic import BaseModel


class StratigraphicUnit(BaseModel):
"""
Stratigraphic unit from SMDA
Camel case attributes needed for esvIntersection component in front-end
"""

identifier: str
top: str
base: str
stratUnitLevel: int
stratUnitType: str
topAge: int | float
baseAge: int | float
stratUnitParent: Optional[str] = None
colorR: int
colorG: int
colorB: int
lithologyType: int | float | str = "unknown"


class WellboreHeader(BaseModel):
wellboreUuid: str
uniqueWellboreIdentifier: str
Expand Down Expand Up @@ -66,11 +45,6 @@ class WellborePick(BaseModel):
mdUnit: str


class WellborePicksAndStratigraphicUnits(BaseModel):
wellbore_picks: List[WellborePick] = []
stratigraphic_units: List[StratigraphicUnit] = []


class WellboreCompletion(BaseModel):
mdTop: float
mdBottom: float
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ def __init__(self) -> None:
async def get_stratigraphic_units(self, stratigraphic_column_identifier: str) -> List[StratigraphicUnit]:
return get_drogon_strat_units()

async def get_wellbore_headers(self) -> List[WellboreHeader]:
# pylint: disable=unused-argument
async def get_wellbore_headers(self, field_identififer: str) -> List[WellboreHeader]:
"""Get Drogon wellbore headers"""
return get_drogon_well_headers()

async def get_wellbore_trajectories(self, wellbore_uuids: Optional[List[str]] = None) -> List[WellboreTrajectory]:
async def get_wellbore_trajectories(
self, field_identifier: str, wellbore_uuids: Optional[List[str]] = None
) -> List[WellboreTrajectory]:
"""Get all Drogon trajectories"""
all_well_trajs = get_drogon_well_trajectories()
if wellbore_uuids:
Expand All @@ -40,6 +43,7 @@ async def get_wellbore_picks_for_wellbore(
# pylint: disable=unused-argument
async def get_wellbore_picks_for_pick_identifier(
self,
field_identifier: str,
pick_identifier: str,
interpreter: str = "STAT",
obs_no: Optional[int] = None,
Expand Down
Loading

0 comments on commit bbbb19f

Please sign in to comment.