@@ -311,10 +311,12 @@ def get_crs_origin_offset(crs_obj: Any) -> List[float | int]:
311311 return crs_point_offset
312312
313313
314- def get_datum_information (datum_obj : Any , workspace : Optional [EnergymlStorageInterface ] = None ):
315- "From a ObjMdDatum or a ReferencePointInACrs, return x, y, z, z_increas_downward, projected_epsg_code, vertical_epsg_code"
314+ def get_datum_information (
315+ datum_obj : Any , workspace : Optional [EnergymlStorageInterface ] = None
316+ ) -> Tuple [float , float , float , bool , Optional [str ], Optional [str ], Optional [Any ]]:
317+ "From a ObjMdDatum or a ReferencePointInACrs, return x, y, z, z_increas_downward, projected_epsg_code, vertical_epsg_code, crs object"
316318 if datum_obj is None :
317- return 0.0 , 0.0 , 0.0 , False , None , None
319+ return 0.0 , 0.0 , 0.0 , False , None , None , None
318320
319321 t_lw = type (datum_obj ).__name__ .lower ()
320322
@@ -333,12 +335,18 @@ def get_datum_information(datum_obj: Any, workspace: Optional[EnergymlStorageInt
333335 z_increasing_downward ,
334336 projected_epsg_code ,
335337 vertical_epsg_code ,
338+ datum_obj ,
336339 )
337340 elif "referencepointinacrs" in t_lw :
338341 x = get_object_attribute_rgx (datum_obj , "horizontal_coordinates.coordinate1" )
339342 y = get_object_attribute_rgx (datum_obj , "horizontal_coordinates.coordinate2" )
340343 z = get_object_attribute_rgx (datum_obj , "vertical_coordinate" )
341- z_increasing_downward = get_object_attribute (datum_obj , "ZIncreasingDownward" ) or False
344+ z_increasing_downward = False
345+ v_crs_dor = get_object_attribute_rgx (datum_obj , "vertical_crs" )
346+ if v_crs_dor is not None and workspace is not None :
347+ v_crs = workspace .get_object (get_obj_uri (v_crs_dor ))
348+ if v_crs is not None :
349+ z_increasing_downward = is_z_reversed (v_crs )
342350 p_crs = get_object_attribute (datum_obj , "horizontal_coordinates.crs" )
343351 projected_epsg_code = (
344352 get_projected_epsg_code (workspace .get_object (get_obj_uri (p_crs )), workspace )
@@ -354,22 +362,26 @@ def get_datum_information(datum_obj: Any, workspace: Optional[EnergymlStorageInt
354362 z_increasing_downward ,
355363 projected_epsg_code ,
356364 vertical_epsg_code ,
365+ p_crs ,
357366 )
358367 elif "mddatum" in t_lw :
359368 x = get_object_attribute_rgx (datum_obj , "location.coordinate1" )
360369 y = get_object_attribute_rgx (datum_obj , "location.coordinate2" )
361370 z = get_object_attribute_rgx (datum_obj , "location.coordinate3" )
362371 crs = get_object_attribute (datum_obj , "LocalCrs" )
363- _ , _ , _ , z_increasing_downward , projected_epsg_code , vertical_epsg_code = get_datum_information (crs , workspace )
372+ _ , _ , _ , z_increasing_downward , projected_epsg_code , vertical_epsg_code , _ = get_datum_information (
373+ crs , workspace
374+ )
364375 return (
365376 float (x ) if x is not None else 0.0 ,
366377 float (y ) if y is not None else 0.0 ,
367378 float (z ) if z is not None else 0.0 ,
368379 z_increasing_downward ,
369380 projected_epsg_code ,
370381 vertical_epsg_code ,
382+ crs ,
371383 )
372- return 0.0 , 0.0 , 0.0 , False , None , None
384+ return 0.0 , 0.0 , 0.0 , False , None , None , None
373385
374386
375387# ==================================================
@@ -659,7 +671,9 @@ def generate_smooth_trajectory(
659671 return np .array (smooth_points )
660672
661673
662- def generate_vertical_well_points (wellbore_mds : np .ndarray , head_x : float , head_y : float , head_z : float ) -> np .ndarray :
674+ def generate_vertical_well_points (
675+ wellbore_mds : np .ndarray , head_x : float , head_y : float , head_z : float , z_increasing_downward : bool = False
676+ ) -> np .ndarray :
663677 """
664678 Generates local 3D coordinates for a perfectly vertical wellbore.
665679
@@ -684,8 +698,12 @@ def generate_vertical_well_points(wellbore_mds: np.ndarray, head_x: float, head_
684698 # In a vertical well, Z_point = Z_datum + (MD_point - MD_datum_at_0)
685699 # Most of the time, MD at head is 0.
686700 # If wellbore_mds start at 0, Z starts at head_z.
701+ # if z_increasing_downward is False, we add the MD to head_z, otherwise we subtract it.
687702 md_start = wellbore_mds [0 ]
688- local_points [:, 2 ] = head_z + (wellbore_mds - md_start )
703+ if z_increasing_downward :
704+ local_points [:, 2 ] = head_z - (wellbore_mds - md_start )
705+ else :
706+ local_points [:, 2 ] = head_z + (wellbore_mds - md_start )
689707
690708 return local_points
691709
0 commit comments