Skip to content

Commit 13aa0b2

Browse files
Updates 07 24 (#7)
* Utility functions to ease the creation of an epc from scratch * Removing crs ZincreasingDownard displacement in default Grid2D read. The CRS displacement has been moved in a specific function * subrepresentation read as Mesh
1 parent e81186f commit 13aa0b2

15 files changed

Lines changed: 1086 additions & 1290 deletions

File tree

energyml-utils/example/main_data.py

Lines changed: 94 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,19 @@
88
StringXmlArray,
99
IntegerXmlArray,
1010
)
11-
from energyml.resqml.v2_0_1.resqmlv2 import WellboreMarkerFrameRepresentation
1211

1312
from src.energyml.utils.data.hdf import (
1413
get_hdf_reference_with_path,
15-
get_hdf5_path_from_external_path,
1614
)
1715
from src.energyml.utils.data.helper import (
1816
get_array_reader_function,
19-
get_supported_array,
20-
get_not_supported_array,
2117
)
2218
from src.energyml.utils.data.mesh import *
2319
from src.energyml.utils.data.mesh import _create_shape, _write_geojson_shape
24-
from src.energyml.utils.epc import gen_energyml_object_path
20+
from src.energyml.utils.epc import gen_energyml_object_path, get_hdf5_path_from_external_path
2521
from src.energyml.utils.introspection import (
2622
is_abstract,
2723
get_obj_uuid,
28-
get_class_fields,
2924
)
3025
from src.energyml.utils.manager import get_sub_classes
3126
from src.energyml.utils.serialization import (
@@ -35,8 +30,7 @@
3530
read_energyml_xml_tree,
3631
)
3732
from src.energyml.utils.validation import validate_epc
38-
from src.energyml.utils.xml import RGX_CONTENT_TYPE, get_tree
39-
33+
from src.energyml.utils.xml import get_tree
4034

4135
logger = logging.getLogger(__name__)
4236

@@ -129,7 +123,7 @@ def read_h5_datasets():
129123
print(epc201.epc_file_path)
130124

131125
pt_set_list = read_point_representation(
132-
energyml_object=psr, workspace=EPCWorkspace(epc=epc201)
126+
energyml_object=psr, workspace=epc201
133127
)
134128

135129
with open("../example/result/file_point_set.off", "wb") as f:
@@ -153,7 +147,7 @@ def read_h5_polyline():
153147
poly = epc201.get_object_by_uuid("77bfb696-1bc0-4858-a304-f8faeb37d809")[0]
154148
poly_set_list = read_polyline_representation(
155149
energyml_object=poly,
156-
workspace=EPCWorkspace(epc201),
150+
workspace=epc201,
157151
)
158152
with open("../example/result/polyline_set.obj", "wb") as f:
159153
export_obj(
@@ -215,7 +209,7 @@ def read_h5_grid2d():
215209
grid = epc22.get_object_by_uuid(uuid)[0]
216210
grid_list = read_mesh_object(
217211
energyml_object=grid,
218-
workspace=EPCWorkspace(epc22),
212+
workspace=epc22,
219213
# keep_holes=False
220214
)
221215
print("Exporting")
@@ -240,7 +234,7 @@ def read_meshes():
240234
energyml_obj = epc22.get_object_by_uuid(uuid)[0]
241235
mesh_list = read_mesh_object(
242236
energyml_object=energyml_obj,
243-
workspace=EPCWorkspace(epc22),
237+
workspace=epc22,
244238
)
245239
print("Exporting")
246240
with open(
@@ -374,6 +368,31 @@ def test_export_multiple_geojson_volve():
374368
)
375369

376370

371+
def test_export_multiple_geojson_volve_struct():
372+
uuid_list = [
373+
"c2f53ce1-1b2d-4819-b397-f174bc8c23e0", # depthVolve_F11_2011_MBA
374+
"d9b95bb5-019d-4341-bcf6-df392338187f", # depth_Ty_Fm_Top_MBA
375+
]
376+
export_multiple_data(
377+
epc_path="D:/Geosiris/OSDU/manifestTranslation/#Data/VOLVE_STRUCT.epc",
378+
uuid_list=uuid_list,
379+
output_folder_path="../example/result/export-energyml-utils/VOLVE_STRUCT",
380+
# output_folder_path="D:/Geosiris/Cloud/Resqml_Tools/2023-DATA/03_VOLVE/V2.0.1/EQN_ORIGIN_PLUS_TRIANG_SET/export-energyml-utils",
381+
file_format=MeshFileFormat.GEOJSON,
382+
use_crs_displacement=False,
383+
logger=logger,
384+
)
385+
export_multiple_data(
386+
epc_path="D:/Geosiris/OSDU/manifestTranslation/#Data/VOLVE_STRUCT.epc",
387+
uuid_list=uuid_list,
388+
output_folder_path="../example/result/export-energyml-utils/VOLVE_STRUCT_CRS_displaced",
389+
# output_folder_path="D:/Geosiris/Cloud/Resqml_Tools/2023-DATA/03_VOLVE/V2.0.1/EQN_ORIGIN_PLUS_TRIANG_SET/export-energyml-utils",
390+
file_format=MeshFileFormat.GEOJSON,
391+
use_crs_displacement=True,
392+
logger=logger,
393+
)
394+
395+
377396
def test_export_multiple_testing_package():
378397
uuid_list = [
379398
"030a82f6-10a7-4ecf-af03-54749e098624", # grid2d
@@ -407,29 +426,42 @@ def test_export_multiple_testing_package():
407426

408427

409428
def test_export_closed_poly():
410-
export_multiple_data(
411-
epc_path="D:/Geosiris/OSDU/manifestTranslation/#Data/"
412-
"Volve_Fault_Depth_originEQN_v201_poly_closed.epc",
413-
uuid_list=[
414-
"4e23ee3e-54a7-427a-83f9-1473de6c56a4", # polyline
415-
"38bf3283-9514-43ab-81e3-17080dc5826f", # polyline
416-
],
417-
output_folder_path="../example/result/export-energyml-utils",
418-
# output_folder_path="D:/Geosiris/OSDU/manifestTranslation/#Data/export-energyml-utils",
419-
output_file_path_suffix="_poly_closed",
420-
file_format=MeshFileFormat.OBJ,
421-
)
429+
# export_multiple_data(
430+
# epc_path="D:/Geosiris/OSDU/manifestTranslation/#Data/"
431+
# "Volve_Fault_Depth_originEQN_v201_poly_closed.epc",
432+
# uuid_list=[
433+
# "4e23ee3e-54a7-427a-83f9-1473de6c56a4", # polyline
434+
# "38bf3283-9514-43ab-81e3-17080dc5826f", # polyline
435+
# ],
436+
# output_folder_path="../example/result/export-energyml-utils",
437+
# # output_folder_path="D:/Geosiris/OSDU/manifestTranslation/#Data/export-energyml-utils",
438+
# output_file_path_suffix="_poly_closed",
439+
# file_format=MeshFileFormat.OBJ,
440+
# )
441+
# export_multiple_data(
442+
# epc_path="D:/Geosiris/OSDU/manifestTranslation/#Data/"
443+
# "Volve_Fault_Depth_originEQN_v201.epc",
444+
# uuid_list=[
445+
# "4e23ee3e-54a7-427a-83f9-1473de6c56a4", # polyline
446+
# "38bf3283-9514-43ab-81e3-17080dc5826f", # polyline
447+
# ],
448+
# output_folder_path="../example/result/export-energyml-utils",
449+
# # output_folder_path="D:/Geosiris/OSDU/manifestTranslation/#Data/export-energyml-utils",
450+
# output_file_path_suffix="closed",
451+
# file_format=MeshFileFormat.OBJ,
452+
# )
422453
export_multiple_data(
423454
epc_path="D:/Geosiris/OSDU/manifestTranslation/#Data/"
424455
"Volve_Fault_Depth_originEQN_v201.epc",
425456
uuid_list=[
426457
"4e23ee3e-54a7-427a-83f9-1473de6c56a4", # polyline
427458
"38bf3283-9514-43ab-81e3-17080dc5826f", # polyline
459+
"5db39032-4998-4b75-9156-ea104a8649d2", # TrSet
428460
],
429-
output_folder_path="../example/result/export-energyml-utils",
461+
output_folder_path="../example/result/export-energyml-utils/geojson",
430462
# output_folder_path="D:/Geosiris/OSDU/manifestTranslation/#Data/export-energyml-utils",
431-
output_file_path_suffix="closed",
432-
file_format=MeshFileFormat.OBJ,
463+
output_file_path_suffix="new",
464+
file_format=MeshFileFormat.GEOJSON,
433465
)
434466

435467

@@ -642,6 +674,37 @@ def test_simple_geojson_io():
642674
print(f"\n+++++++++++++++++++++++++\n")
643675

644676

677+
def test_wellbore_reading():
678+
# WIP
679+
path = "../rc/obj_EpcExternalPartReference_61fa2fdf-46ab-4c02-ab72-7895cce58e37.xml"
680+
681+
with open(path, "rb") as f:
682+
xml_content = f.read()
683+
# print(xml_content)
684+
685+
print(read_energyml_xml_bytes(xml_content))
686+
687+
688+
def read_sub_representation():
689+
epc_path = "D:/Geosiris/Cloud/Resqml_Tools/2023-DATA/03_VOLVE/V2.0.1/ASPEN_TECH_RDDMS_IMPORT/Volve_Demo_Horizons_Depth.epc"
690+
# epc_path = "D:/Geosiris/Cloud/Resqml_Tools/OSDU/OSDU_RESERVOIR_DDMS/F2F_Demo.epc"
691+
# epc = Epc.read_file(epc_path)
692+
693+
uuid_list = [
694+
"e2e7f8a9-c602-4c02-99cb-cff3ef79ce84", # Grid Subrep
695+
"5bc4bfd9-44fa-433a-a362-59c5b35cd9e8", # Grid Subrep
696+
"218283a7-44eb-44fa-9074-7cb1cff125f2", # Grid Subrep
697+
"1450e49e-830a-4430-a482-aa06fcd013f5", # Grid Subrep
698+
]
699+
700+
export_multiple_data(
701+
epc_path=epc_path,
702+
uuid_list=uuid_list,
703+
output_folder_path="../example/result/subrep/",
704+
file_format=MeshFileFormat.OBJ,
705+
)
706+
707+
645708
if __name__ == "__main__":
646709

647710
logging.basicConfig(
@@ -678,6 +741,9 @@ def test_simple_geojson_io():
678741
# test_export_multiple_geojson()
679742
# test_export_multiple_geojson_volve()
680743
# test_simple_geojson()
681-
test_simple_geojson_io()
744+
# test_simple_geojson_io()
745+
# test_export_multiple_geojson_volve_struct()
746+
read_sub_representation()
682747

683748
# test_etree()
749+
# test_wellbore_reading()

energyml-utils/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ branch = true
7777
source = ["src/energyml"]
7878

7979
[tool.black]
80-
line-length = 79
80+
line-length = 120
8181
target-version = ["py39"]
8282
include = '\.pyi?$'
8383
exclude = '''
@@ -97,7 +97,7 @@ exclude = '''
9797
'''
9898

9999
[tool.pylint.format]
100-
max-line-length = "88"
100+
max-line-length = "120"
101101

102102
[tool.poetry-dynamic-versioning]
103103
enable = true
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
2+
<Trajectory xmlns="http://www.energistics.org/energyml/data/witsmlv2" xmlns:ns2="http://www.energistics.org/energyml/data/commonv2" uuid="4e76e1de-eff1-4458-805e-a6a877fa333b" schemaVersion="2.1">
3+
<ns2:Citation>
4+
<ns2:Title>My trajectory</ns2:Title>
5+
<ns2:Originator>philippe</ns2:Originator>
6+
<ns2:Creation>2023-04-05T14:30:41Z</ns2:Creation>
7+
<ns2:Format>F2I-CONSULTING:FESAPI Example:2.7.0.0</ns2:Format>
8+
<ns2:LastUpdate>2023-12-22T01:50:06.318Z</ns2:LastUpdate>
9+
</ns2:Citation>
10+
<ns2:ActiveStatus>inactive</ns2:ActiveStatus>
11+
<ns2:Index>
12+
<ns2:IndexKind>measured depth</ns2:IndexKind>
13+
<ns2:Uom>Euc</ns2:Uom>
14+
<ns2:Direction>increasing</ns2:Direction>
15+
</ns2:Index>
16+
<Definitive>true</Definitive>
17+
<FinalTraj>true</FinalTraj>
18+
<TrajectoryStation uid="d3ac5401-d3e7-4474-b846-070673b210ae">
19+
<ns2:Creation>1970-01-01T00:00:00Z</ns2:Creation>
20+
<ns2:LastUpdate>1970-01-01T00:00:00Z</ns2:LastUpdate>
21+
<ns2:Md>
22+
<ns2:MeasuredDepth uom="m">0.0</ns2:MeasuredDepth>
23+
</ns2:Md>
24+
<ManuallyEntered>true</ManuallyEntered>
25+
<TypeTrajStation>N E and TVD</TypeTrajStation>
26+
<Tvd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:DatumVerticalDepth">
27+
<ns2:VerticalDepth uom="m">0.0</ns2:VerticalDepth>
28+
</Tvd>
29+
<DispNs uom="m">0.0</DispNs>
30+
<DispEw uom="m">0.0</DispEw>
31+
<Location xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:ProjectedCompoundPosition">
32+
<ns2:Coordinate1>0.0</ns2:Coordinate1>
33+
<ns2:Coordinate2>0.0</ns2:Coordinate2>
34+
<ns2:VerticalCoordinate>0.0</ns2:VerticalCoordinate>
35+
<ns2:ProjectedCompoundCrs uuid="51150e56-e9f2-03b1-6d90-c2452be58f7d" schemaVersion="2.3">
36+
<ns2:Citation>
37+
<ns2:Title>ProjectedCompountSample</ns2:Title>
38+
<ns2:Originator>Geosiris</ns2:Originator>
39+
<ns2:Creation>2023-12-22T01:49:14.357Z</ns2:Creation>
40+
<ns2:Format>Geosiris Webstudio</ns2:Format>
41+
<ns2:LastUpdate>2023-12-22T01:49:15.165Z</ns2:LastUpdate>
42+
</ns2:Citation>
43+
<ns2:ProjectedCrs>
44+
<ns2:Uuid>158be8be-8f12-4e85-a7d9-a667a8f19992</ns2:Uuid>
45+
<ns2:QualifiedType>resqml20.obj_LocalDepth3dCrs</ns2:QualifiedType>
46+
<ns2:Title>Default local CRS</ns2:Title>
47+
</ns2:ProjectedCrs>
48+
</ns2:ProjectedCompoundCrs>
49+
</Location>
50+
</TrajectoryStation>
51+
<TrajectoryStation uid="d3ac5401-d3e7-4474-b846-070673b210ae">
52+
<ns2:Creation>1970-01-01T00:00:00Z</ns2:Creation>
53+
<ns2:LastUpdate>1970-01-01T00:00:00Z</ns2:LastUpdate>
54+
<ns2:Md>
55+
<ns2:MeasuredDepth uom="m">325.0</ns2:MeasuredDepth>
56+
</ns2:Md>
57+
<ManuallyEntered>true</ManuallyEntered>
58+
<TypeTrajStation>N E and TVD</TypeTrajStation>
59+
<Tvd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:DatumVerticalDepth">
60+
<ns2:VerticalDepth uom="m">325.0</ns2:VerticalDepth>
61+
</Tvd>
62+
<DispNs uom="m">325.0</DispNs>
63+
<DispEw uom="m">325.0</DispEw>
64+
</TrajectoryStation>
65+
<TrajectoryStation uid="d3ac5401-d3e7-4474-b846-070673b210ae">
66+
<ns2:Creation>1970-01-01T00:00:00Z</ns2:Creation>
67+
<ns2:LastUpdate>1970-01-01T00:00:00Z</ns2:LastUpdate>
68+
<ns2:Md>
69+
<ns2:MeasuredDepth uom="m">500.0</ns2:MeasuredDepth>
70+
</ns2:Md>
71+
<ManuallyEntered>true</ManuallyEntered>
72+
<TypeTrajStation>N E and TVD</TypeTrajStation>
73+
<Tvd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:DatumVerticalDepth">
74+
<ns2:VerticalDepth uom="m">500.0</ns2:VerticalDepth>
75+
</Tvd>
76+
<DispNs uom="m">500.0</DispNs>
77+
<DispEw uom="m">500.0</DispEw>
78+
</TrajectoryStation>
79+
<TrajectoryStation uid="d3ac5401-d3e7-4474-b846-070673b210ae">
80+
<ns2:Creation>1970-01-01T00:00:00Z</ns2:Creation>
81+
<ns2:LastUpdate>1970-01-01T00:00:00Z</ns2:LastUpdate>
82+
<ns2:Md>
83+
<ns2:MeasuredDepth uom="m">1000.0</ns2:MeasuredDepth>
84+
</ns2:Md>
85+
<ManuallyEntered>true</ManuallyEntered>
86+
<TypeTrajStation>N E and TVD</TypeTrajStation>
87+
<Tvd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:DatumVerticalDepth">
88+
<ns2:VerticalDepth uom="m">1000.0</ns2:VerticalDepth>
89+
</Tvd>
90+
<DispNs uom="m">1000.0</DispNs>
91+
<DispEw uom="m">1000.0</DispEw>
92+
</TrajectoryStation>
93+
<Wellbore>
94+
<ns2:Uuid>3c321e10-d04a-4b6d-8bcd-5eae01cab52d</ns2:Uuid>
95+
<ns2:QualifiedType>witsml21.Wellbore</ns2:QualifiedType>
96+
<ns2:Title>Drilling_Demo1</ns2:Title>
97+
</Wellbore>
98+
</Trajectory>

0 commit comments

Comments
 (0)