Skip to content

Remove/ignore SMDA wells that has undefined entries in trajectory #682

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 1 addition & 4 deletions backend_py/primary/primary/routers/well/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ async def get_field_well_trajectories(
# fmt:off
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
field_identifier: str = Query(description="Sumo field identifier"),
unique_wellbore_identifiers:List[str] = Query(None, description="Optional subset of well names")
# fmt:on
) -> List[schemas.WellboreTrajectory]:
"""Get well trajectories for field"""
Expand All @@ -60,9 +59,7 @@ async def get_field_well_trajectories(
else:
well_access = SmdaWellAccess(authenticated_user.get_smda_access_token())

wellbore_trajectories = await well_access.get_field_wellbore_trajectories(
field_identifier=field_identifier, unique_wellbore_identifiers=unique_wellbore_identifiers
)
wellbore_trajectories = await well_access.get_field_wellbore_trajectories(field_identifier=field_identifier)

return [
converters.convert_well_trajectory_to_schema(wellbore_trajectory)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import List, Optional
from typing import List

from ..types import WellborePick, WellboreTrajectory, WellboreHeader

from ._mocked_wellbore_picks import mocked_wellbore_picks


Expand All @@ -19,11 +18,7 @@ async def get_all_picks_for_wellbore(self, wellbore_uuid: str) -> List[WellboreP
well_picks = [pick for pick in mocked_wellbore_picks if pick.unique_wellbore_identifier == "55/33-1"]
return well_picks

# type: ignore
# pylint: disable=unused-argument
async def get_field_wellbore_trajectories(
self, field_identifier: str, unique_wellbore_identifiers: Optional[List[str]] = None
) -> List[WellboreTrajectory]:
async def get_field_wellbore_trajectories(self, field_identifier: str) -> List[WellboreTrajectory]:
"""Get all Drogon trajectories"""
return [
WellboreTrajectory(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from typing import List
import logging

import pandas as pd

from webviz_pkg.core_utils.perf_timer import PerfTimer
from ..types import WellboreTrajectory
from ._get_request import get

LOGGER = logging.getLogger(__name__)


async def _fetch_wellbore_trajectories(access_token: str, params: dict) -> List[WellboreTrajectory]:
endpoint = "wellbore-survey-samples"
base_params = {
"_projection": "wellbore_uuid, unique_wellbore_identifier,easting,northing,tvd_msl,md",
"_sort": "unique_wellbore_identifier,md",
}
base_params.update(params)

timer = PerfTimer()

result = await get(access_token=access_token, endpoint=endpoint, params=base_params)
LOGGER.debug(f"TIME SMDA fetch wellbore trajectories took {timer.lap_s():.2f} seconds")

resultdf = pd.DataFrame.from_dict(result)
LOGGER.debug(f"TIME SMDA wellbore trajectories to dataframe{timer.lap_s():.2f} seconds")

wellbore_trajectories: List[WellboreTrajectory] = []
for wellbore_id, df in resultdf.groupby("unique_wellbore_identifier"):
tvd_arr = df["tvd_msl"]
md_arr = df["md"]
easting_arr = df["easting"]
northing_arr = df["northing"]

if any(arr.isna().any() for arr in [tvd_arr, md_arr, easting_arr, northing_arr]):
LOGGER.warning(f"Invalid wellbore trajectory for wellbore {wellbore_id}. Skipping.")
continue

wellbore_trajectories.append(
WellboreTrajectory(
wellbore_uuid=df["wellbore_uuid"].iloc[0],
unique_wellbore_identifier=wellbore_id,
tvd_msl_arr=tvd_arr,
md_arr=md_arr,
easting_arr=easting_arr,
northing_arr=northing_arr,
)
)
LOGGER.debug(f"TIME SMDA wellbore trajectories to list and validate {timer.lap_s():.2f} seconds")
return wellbore_trajectories


async def get_wellbore_trajectories(access_token: str, wellbore_uuids: List[str]) -> List[WellboreTrajectory]:

params = {
"wellbore_uuid": ", ".join(wellbore_uuids),
}
return await _fetch_wellbore_trajectories(access_token, params)


async def get_field_wellbore_trajectories(
access_token: str,
field_identifier: str,
) -> List[WellboreTrajectory]:

params = {
"field_identifier": field_identifier,
}

return await _fetch_wellbore_trajectories(access_token, params)

This file was deleted.

11 changes: 3 additions & 8 deletions backend_py/primary/primary/services/smda_access/well_access.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from typing import List, Optional
from typing import List

from .types import WellborePick, WellboreTrajectory, WellboreHeader

from .queries.get_wellbore_headers import get_wellbore_headers
from .queries.get_wellbore_picks_for_field import get_wellbore_picks_for_field
from .queries.get_field_wellbore_trajectories import get_field_wellbore_trajectories
from .queries.get_wellbore_trajectory import get_wellbore_trajectories
from .queries.get_wellbore_trajectories import get_wellbore_trajectories, get_field_wellbore_trajectories
from .queries.get_picks_for_wellbore import get_picks_for_wellbore


Expand All @@ -21,13 +19,10 @@ async def get_field_wellbore_picks(self, field_identifier: str, pick_identifier:
)
return wellbore_picks

async def get_field_wellbore_trajectories(
self, field_identifier: str, unique_wellbore_identifiers: Optional[List[str]] = None
) -> List[WellboreTrajectory]:
async def get_field_wellbore_trajectories(self, field_identifier: str) -> List[WellboreTrajectory]:
wellbore_trajectories = await get_field_wellbore_trajectories(
access_token=self._smda_token,
field_identifier=field_identifier,
unique_wellbore_identifiers=unique_wellbore_identifiers,
)
return wellbore_trajectories

Expand Down
3 changes: 0 additions & 3 deletions frontend/src/api/services/WellService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,17 @@ export class WellService {
* Get Field Well Trajectories
* Get well trajectories for field
* @param fieldIdentifier Sumo field identifier
* @param uniqueWellboreIdentifiers Optional subset of well names
* @returns WellboreTrajectory Successful Response
* @throws ApiError
*/
public getFieldWellTrajectories(
fieldIdentifier: string,
uniqueWellboreIdentifiers?: Array<string>,
): CancelablePromise<Array<WellboreTrajectory>> {
return this.httpRequest.request({
method: 'GET',
url: '/well/field_well_trajectories/',
query: {
'field_identifier': fieldIdentifier,
'unique_wellbore_identifiers': uniqueWellboreIdentifiers,
},
errors: {
422: `Validation Error`,
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/modules/3DViewer/view/utils/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ export function makeWellsLayer(
fieldWellboreTrajectoriesData: WellboreTrajectory_api[],
selectedWellboreUuid: string | null
): WellsLayer {
const tempWorkingWellsData = fieldWellboreTrajectoriesData.filter(
(el) => el.uniqueWellboreIdentifier !== "NO 34/4-K-3 AH"
);
const wellLayerDataFeatures = tempWorkingWellsData.map((well) =>
const wellLayerDataFeatures = fieldWellboreTrajectoriesData.map((well) =>
wellTrajectoryToGeojson(well, selectedWellboreUuid)
);

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/modules/SubsurfaceMap/_utils/subsurfaceMap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SurfaceDef_api, PolygonData_api, WellboreTrajectory_api } from "@api";
import { PolygonData_api, SurfaceDef_api, WellboreTrajectory_api } from "@api";

export type SurfaceMeshLayerSettings = {
contours?: boolean | number[];
Expand Down Expand Up @@ -112,6 +112,7 @@ export function createWellboreTrajectoryLayer(wellTrajectories: WellboreTrajecto
lineStyle: { width: 2 },
wellHeadStyle: { size: 1 },
pickable: true,
ZIncreasingDownwards: false,
};
}
export function wellTrajectoryToGeojson(wellTrajectory: WellboreTrajectory_api): Record<string, unknown> {
Expand Down
Loading