forked from equinor/webviz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce0d50b
commit 303a5f1
Showing
12 changed files
with
256 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { SeismicFenceData_api } from "@api"; | ||
import { b64DecodeFloatArrayToFloat32 } from "@modules_shared/base64"; | ||
|
||
// Data structure for transformed data | ||
// Remove the base64 encoded data and replace with a Float32Array | ||
export type SeismicFenceData_trans = Omit<SeismicFenceData_api, "fence_traces_b64arr"> & { | ||
fenceTracesFloat32Arr: Float32Array; | ||
}; | ||
|
||
export function transformSeismicFenceData(apiData: SeismicFenceData_api): SeismicFenceData_trans { | ||
const startTS = performance.now(); | ||
|
||
const { fence_traces_b64arr, ...untransformedData } = apiData; | ||
const dataFloat32Arr = b64DecodeFloatArrayToFloat32(fence_traces_b64arr); | ||
|
||
console.debug(`transformSurfaceData() took: ${(performance.now() - startTS).toFixed(1)}ms`); | ||
|
||
return { | ||
...untransformedData, | ||
fenceTracesFloat32Arr: dataFloat32Arr, | ||
}; | ||
} |
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
160 changes: 160 additions & 0 deletions
160
frontend/src/modules/Intersection/view/atoms/atomDefinitions.ts
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,160 @@ | ||
import { IntersectionReferenceSystem } from "@equinor/esv-intersection"; | ||
import { apiService } from "@framework/ApiService"; | ||
import { ModuleAtoms } from "@framework/Module"; | ||
import { UniDirectionalSettingsToViewInterface } from "@framework/UniDirectionalSettingsToViewInterface"; | ||
import { IntersectionType } from "@framework/types/intersection"; | ||
import { IntersectionPolylinesAtom } from "@framework/userCreatedItems/IntersectionPolylines"; | ||
import { transformSeismicFenceData } from "@modules/Intersection/queryDataTransforms"; | ||
import { SettingsToViewInterface } from "@modules/Intersection/settingsToViewInterface"; | ||
import { SeismicDataType } from "@modules/Intersection/typesAndEnums"; | ||
import { SeismicFenceData_trans } from "@modules/SeismicIntersection/utils/queryDataTransforms"; | ||
import { calcExtendedSimplifiedWellboreTrajectoryInXYPlane } from "@modules/_shared/utils/wellbore"; | ||
import { QueryObserverResult } from "@tanstack/react-query"; | ||
|
||
import { atom } from "jotai"; | ||
import { atomWithQuery } from "jotai-tanstack-query"; | ||
|
||
import { wellboreTrajectoryQueryAtom } from "./queryAtoms"; | ||
|
||
export type ViewAtoms = { | ||
seismicFenceDataQueryAtom: QueryObserverResult<SeismicFenceData_trans>; | ||
intersectionReferenceSystemAtom: IntersectionReferenceSystem | null; | ||
}; | ||
|
||
const STALE_TIME = 60 * 1000; | ||
const CACHE_TIME = 60 * 1000; | ||
|
||
export function viewAtomsInitialization( | ||
settingsToViewInterface: UniDirectionalSettingsToViewInterface<SettingsToViewInterface> | ||
): ModuleAtoms<ViewAtoms> { | ||
const selectedCustomIntersectionPolylineAtom = atom((get) => { | ||
const customIntersectionPolylineId = get( | ||
settingsToViewInterface.getAtom("selectedCustomIntersectionPolylineId") | ||
); | ||
const customIntersectionPolylines = get(IntersectionPolylinesAtom); | ||
|
||
return customIntersectionPolylines.find((el) => el.id === customIntersectionPolylineId); | ||
}); | ||
|
||
const intersectionReferenceSystemAtom = atom((get) => { | ||
const wellboreTrajectoryQuery = get(wellboreTrajectoryQueryAtom); | ||
const customIntersectionPolyline = get(selectedCustomIntersectionPolylineAtom); | ||
const intersectionType = get(settingsToViewInterface.getAtom("intersectionType")); | ||
|
||
if (intersectionType === IntersectionType.WELLBORE) { | ||
if (!wellboreTrajectoryQuery.data) { | ||
return null; | ||
} | ||
|
||
const wellboreTrajectory = wellboreTrajectoryQuery.data; | ||
|
||
if (wellboreTrajectoryQuery) { | ||
const path: number[][] = []; | ||
for (const [index, northing] of wellboreTrajectory.northing_arr.entries()) { | ||
const easting = wellboreTrajectory.easting_arr[index]; | ||
const tvd_msl = wellboreTrajectory.tvd_msl_arr[index]; | ||
|
||
path.push([easting, northing, tvd_msl]); | ||
} | ||
const offset = wellboreTrajectory.tvd_msl_arr[0]; | ||
|
||
const referenceSystem = new IntersectionReferenceSystem(path); | ||
referenceSystem.offset = offset; | ||
|
||
return referenceSystem; | ||
} | ||
} else if (intersectionType === IntersectionType.CUSTOM_POLYLINE && customIntersectionPolyline) { | ||
if (customIntersectionPolyline.points.length < 2) { | ||
return null; | ||
} | ||
const referenceSystem = new IntersectionReferenceSystem( | ||
customIntersectionPolyline.points.map((point) => [point[0], point[1], 0]) | ||
); | ||
referenceSystem.offset = 0; | ||
|
||
return referenceSystem; | ||
} | ||
|
||
return null; | ||
}); | ||
|
||
const polylineAtom = atom((get) => { | ||
const intersectionType = get(settingsToViewInterface.getAtom("intersectionType")); | ||
const intersectionExtensionLength = get(settingsToViewInterface.getAtom("intersectionExtensionLength")); | ||
const curveFittingEpsilon = get(settingsToViewInterface.getAtom("curveFittingEpsilon")); | ||
const selectedCustomIntersectionPolyline = get(selectedCustomIntersectionPolylineAtom); | ||
const intersectionReferenceSystem = get(intersectionReferenceSystemAtom); | ||
|
||
const polylineUtmXy: number[] = []; | ||
|
||
if (intersectionReferenceSystem) { | ||
if (intersectionType === IntersectionType.WELLBORE) { | ||
const path = intersectionReferenceSystem.path; | ||
polylineUtmXy.push( | ||
...calcExtendedSimplifiedWellboreTrajectoryInXYPlane( | ||
path, | ||
intersectionExtensionLength, | ||
curveFittingEpsilon | ||
).flat() | ||
); | ||
} else if (intersectionType === IntersectionType.CUSTOM_POLYLINE && selectedCustomIntersectionPolyline) { | ||
for (const point of selectedCustomIntersectionPolyline.points) { | ||
polylineUtmXy.push(point[0], point[1]); | ||
} | ||
} | ||
} | ||
|
||
return polylineUtmXy; | ||
}); | ||
|
||
const seismicFenceDataQueryAtom = atomWithQuery((get) => { | ||
const ensembleIdent = get(settingsToViewInterface.getAtom("ensembleIdent")); | ||
const realizationNum = get(settingsToViewInterface.getAtom("realization")); | ||
const seismicAttribute = get(settingsToViewInterface.getAtom("seismicAttribute")); | ||
const timeOrIntervalStr = get(settingsToViewInterface.getAtom("seismicDateOrIntervalString")); | ||
const observed = get(settingsToViewInterface.getAtom("seismicDataType")) === SeismicDataType.OBSERVED; | ||
const polyline = get(polylineAtom); | ||
|
||
const caseUuid = ensembleIdent?.getCaseUuid(); | ||
const ensembleName = ensembleIdent?.getEnsembleName(); | ||
|
||
const xPoints: number[] = []; | ||
const yPoints: number[] = []; | ||
for (let i = 0; i < polyline.length; i += 2) { | ||
xPoints.push(polyline[i]); | ||
yPoints.push(polyline[i + 1]); | ||
} | ||
|
||
return { | ||
queryKey: [ | ||
"postGetSeismicFence", | ||
caseUuid, | ||
ensembleName, | ||
realizationNum, | ||
seismicAttribute, | ||
timeOrIntervalStr, | ||
observed, | ||
polyline, | ||
], | ||
queryFn: () => | ||
apiService.seismic.postGetSeismicFence( | ||
caseUuid ?? "", | ||
ensembleName ?? "", | ||
realizationNum ?? 0, | ||
seismicAttribute ?? "", | ||
timeOrIntervalStr ?? "", | ||
observed ?? false, | ||
{ polyline: { x_points: xPoints, y_points: yPoints } } | ||
), | ||
select: transformSeismicFenceData, | ||
staleTime: STALE_TIME, | ||
gcTime: CACHE_TIME, | ||
enabled: !!(caseUuid && ensembleName && realizationNum !== null && seismicAttribute && timeOrIntervalStr), | ||
}; | ||
}); | ||
|
||
return { | ||
seismicFenceDataQueryAtom, | ||
intersectionReferenceSystemAtom, | ||
}; | ||
} |
Oops, something went wrong.