Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathexample.py
More file actions
Latest commit
250 lines (219 loc) · 12.1 KB
/
Copy pathexample.py
File metadata and controls
250 lines (219 loc) · 12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
fromdatetimeimportdatetime
importfesapi
defserialize_grid(repo: fesapi.DataObjectRepository):
"""
This function creates a one cell grid + a property on a partial ijk grid in the repo to be serialized
"""
earth_model=repo.createEarthModel("f2060ce0-fa3d-11e5-8620-0002a5d5c51b", "Grid")
earth_model_interp=repo.createEarthModelInterpretation(
earth_model, "f5cd7520-fa3d-11e5-b65b-0002a5d5c51b", "Grid interp")
# ONE CELL GRID
single_cell_ijk_grid=repo.createIjkGridExplicitRepresentation(
earth_model_interp, "e69bfe00-fa3d-11e5-b5eb-0002a5d5c51b", "One unfaulted sugar cube",
1, 1, 1)
python_points= [0.0, 0.0, 300.0, 700.0, 0.0, 350.0, 0.0, 150.0, 300.0, 700.0, 150.0, 350.0,
0.0, 0.0, 500.0, 700.0, 0.0, 550.0, 0.0, 150.0, 500.0, 700.0, 150.0, 550.0]
resqml_points=fesapi.DoubleArray(24)
fori, valueinenumerate(python_points):
resqml_points.setitem(i, value)
single_cell_ijk_grid.setGeometryAsCoordinateLineNodes(
fesapi.resqml20__PillarShape_vertical, fesapi.resqml20__KDirection_down, False,
resqml_points.cast())
# ONE CONTINUOUS PROPERTY ON A PARTIAL 3 cells I=1 J=1 K=3 GRID
partial_ijk_grid=repo.createPartialIjkGridRepresentation("bc92a216-aa17-4a1f-9253-8b3ab094bf84", "partial grid")
continuous_prop=repo.createContinuousProperty(partial_ijk_grid, "827d1074-5b16-4c7d-80bb-a8f3e1413753", "My length property", 1, fesapi.eml23__IndexableElement_cells,
fesapi.resqml20__ResqmlUom_m, fesapi.resqml20__ResqmlPropertyKind_length)
prop_values= [1.1, 2.2, 3.3]
resqml_values=fesapi.FloatArray(3)
fori, valueinenumerate(prop_values):
resqml_values.setitem(i, value)
stats=fesapi.FloatArrayStatistics()
stats.setMaximum(3.3)
stats.setMinimum(1.1)
continuous_prop.pushBackFloatArray3dOfValuesPlusStatistics(resqml_values.cast(), 1, 1, 3, stats)
# A time series definition
time_series=repo.createTimeSeries("1187d8a0-fa3e-11e5-ac3a-0002a5d5c51b", "Testing time series 1")
time_series.pushBackTimestamp(1409753895)
time_series.pushBackTimestamp(1441289895)
# A continuous property with time series
continuous_prop_time0=repo.createContinuousProperty(partial_ijk_grid, "18027a00-fa3e-11e5-8255-0002a5d5c51b", "Time Series Property", 1,
fesapi.eml23__IndexableElement_cells, fesapi.resqml20__ResqmlUom_m, fesapi.resqml20__ResqmlPropertyKind_length)
continuous_prop_time0.setTimeSeries(time_series)
continuous_prop_time0.setSingleTimestamp(time_series.getTimestamp(0))
continuous_prop_time0.pushBackFloatArray3dOfValues(resqml_values.cast(), 1, 1, 3)
continuous_prop_time1=repo.createContinuousProperty(partial_ijk_grid, "1ba54340-fa3e-11e5-9534-0002a5d5c51b", "Time Series Property", 1,
fesapi.eml23__IndexableElement_cells, fesapi.resqml20__ResqmlUom_m, fesapi.resqml20__ResqmlPropertyKind_length)
continuous_prop_time1.setTimeSeries(time_series)
continuous_prop_time1.setSingleTimestamp(1441289895)
continuous_prop_time1.pushBackFloatArray3dOfValues(resqml_values.cast(), 1, 1, 3)
# unstructured grid example
unstructured_grid=repo.createUnstructuredGridRepresentation(
"9283cd33-5e52-4110-b7b1-616abde2b303",
"One tetrahedron + prism grid",
2
)
python_points= [0, 0, 300, 375, 0, 300, 0, 150, 300, # points for shared face between tetra and wedge
0, 0, 500, # point for tetra
0, 0, 0, 375, 0, 0, 0, 150, 0]
resqml_points=fesapi.DoubleArray(21)
fori, valueinenumerate(python_points):
resqml_points.setitem(i, value)
python_node_indices_per_face= [0, 1, 2, # shared face
1, 2, 3, 0, 1, 3, 0, 2, 3, # faces for tetra
0, 2, 6, 4, 2, 1, 5, 6, 0, 1, 5, 4, 4, 5, 6] # faces for wedge
resqml_node_indices_per_face=fesapi.UInt64Array(27)
fori, valueinenumerate(python_node_indices_per_face):
resqml_node_indices_per_face.setitem(i, value)
python_node_indices_cumulative_count_per_face= [3, # shared face
6, 9, 12, # faces for tetra
16, 20, 24, 27] # faces for wedge
resqml_node_indices_cumulative_count_per_face=fesapi.UInt64Array(8)
fori, valueinenumerate(python_node_indices_cumulative_count_per_face):
resqml_node_indices_cumulative_count_per_face.setitem(i, value)
python_face_indices_per_cell= [0, 1, 2, 3, # tetra
0, 4, 5, 6, 7] # wedge
resqml_face_indices_per_cell=fesapi.UInt64Array(9)
fori, valueinenumerate(python_face_indices_per_cell):
resqml_face_indices_per_cell.setitem(i, value)
python_face_indices_cumulative_count_per_cell= [ 4, 9 ];
resqml_face_indices_cumulative_count_per_cell=fesapi.UInt64Array(2)
fori, valueinenumerate(python_face_indices_cumulative_count_per_cell):
resqml_face_indices_cumulative_count_per_cell.setitem(i, value)
python_face_right_handness= [ 1, 0, 0, 1, 0, 0, 0, 1, 1 ];
resqml_face_right_handness=fesapi.UInt8Array(9)
fori, valueinenumerate(python_face_right_handness):
resqml_face_right_handness.setitem(i, value)
unstructured_grid.setGeometry(resqml_face_right_handness.cast(), resqml_points.cast(), 7, None, resqml_face_indices_per_cell.cast(), resqml_face_indices_cumulative_count_per_cell.cast(), 8,
resqml_node_indices_per_face.cast(), resqml_node_indices_cumulative_count_per_face.cast(), fesapi.resqml20__CellShape_prism);
defserialize(file_name: str):
"""
This function serializes an EPC document
"""
epc_file=fesapi.EpcDocument(file_name+".epc")
repo=fesapi.DataObjectRepository()
# CRS
print(type(fesapi.eml20__LengthUom_m))
local_3d_crs=repo.createLocalDepth3dCrs("798d47d8-0c7d-4f12-8c44-0f36b6d16c32", "Default CRS",
0.0, 0.0, 0.0, 0.0,
fesapi.eml20__LengthUom_m, 5215,
fesapi.eml20__LengthUom_m, "Unknown",
False)
repo.createLocalTime3dCrs("", "Default local time CRS",
1.0, 0.1, 15, .0,
fesapi.eml20__LengthUom_m, 23031,
fesapi.eml20__TimeUom_s, fesapi.eml20__LengthUom_m, "Unknown",
False)
repo.setDefaultCrs(local_3d_crs)
# HdfProxy
hdf_proxy=repo.createHdfProxy("798d47d8-0c7d-4f12-8c44-0f36b6d16c33", "Hdf Proxy",
".", file_name+".h5",
fesapi.DataObjectRepository.openingMode_OVERWRITE)
repo.setDefaultHdfProxy(hdf_proxy)
serialize_grid(repo)
epc_file.serializeFrom(repo)
defshow_all_metadata(data_object: fesapi.AbstractObject):
"""
Show all metadata of a dataobject
"""
print("Title is : "+data_object.getTitle())
print("Guid is : "+data_object.getUuid())
ifnotdata_object.isPartial():
print("Creation date is (unix timestamp) : ",
datetime.fromtimestamp(data_object.getCreation()))
else:
print("IS PARTIAL!")
defshow_ijk_grid(ijk_grid: fesapi.Resqml2_AbstractIjkGridRepresentation):
"""
This function shows some ijk grids which have been deserialized
"""
show_all_metadata(ijk_grid)
ifijk_grid.isPartial():
return
ifijk_grid.getGeometryKind() !=fesapi.Resqml2_AbstractIjkGridRepresentation.geometryKind_NO_GEOMETRY:
most_complex_pillar_geom=ijk_grid.getMostComplexPillarGeometry()
ifmost_complex_pillar_geom==fesapi.resqml20__PillarShape_vertical:
print("Most complex pillar geometry is vertical")
else:
ifmost_complex_pillar_geom==fesapi.resqml20__PillarShape_straight:
print("Most complex pillar geometry is straight")
else:
ifmost_complex_pillar_geom==fesapi.resqml20__PillarShape_curved:
print("Most complex pillar geometry is curved")
k_gap_count=ijk_grid.getKGapsCount()
print("K Gap Count = ", k_gap_count)
ifijk_grid.getGeometryKind() ==fesapi.Resqml2_AbstractIjkGridRepresentation.geometryKind_LATTICE:
print("This 3d grid has a lattice geometry.")
else:
ifijk_grid.getGeometryKind() == \
fesapi.Resqml2_AbstractIjkGridRepresentation.geometryKind_PARAMETRIC:
print("This 3d grid has a parametric geometry.")
else:
ifijk_grid.getGeometryKind() == \
fesapi.Resqml2_AbstractIjkGridRepresentation.geometryKind_EXPLICIT:
print("This 3d grid has an explicit geometry.")
else:
print("This 3d grid has an unknown geometry.")
patch_count=ijk_grid.getPatchCount()
print("Patch Count =", patch_count)
nb_xyz_points=ijk_grid.getXyzPointCountOfAllPatches()
print("XYZ points count :", nb_xyz_points)
forpatch_indexinrange(patch_count):
nb_xyz_points_in_patch=ijk_grid.getXyzPointCountOfPatch(patch_index)
xyz_points_in_patch=fesapi.DoubleArray(nb_xyz_points_in_patch*3)
ijk_grid.getXyzPointsOfPatch(patch_index, xyz_points_in_patch.cast())
forvertex_indexinrange(nb_xyz_points_in_patch):
x=xyz_points_in_patch.getitem(vertex_index*3)
y=xyz_points_in_patch.getitem(vertex_index*3+1)
z=xyz_points_in_patch.getitem(vertex_index*3+2)
print("Vertex ", vertex_index, " : ", x, " ", y, " ", z)
xyz_points=fesapi.DoubleArray(nb_xyz_points*3)
ijk_grid.getXyzPointsOfAllPatches(xyz_points.cast())
ijk_grid.loadSplitInformation()
forcell_cornerinrange(8):
pt_index=ijk_grid.getXyzPointIndexFromCellCorner(0, 0, 0, cell_corner)
print("Cell 0,0,0 corner ", cell_corner, " is at index ", pt_index)
print("Cell 0,0,0 corner ", cell_corner, " is ", xyz_points.getitem(pt_index*3), " ", xyz_points.getitem(pt_index*3+1), " ", xyz_points.getitem(pt_index*3+2))
ijk_grid.unloadSplitInformation();
else:
print("This 3d grid has no geometry.")
defdeserialize(file_name: str):
"""
This function deserializes an EPC document
"""
epc_file=fesapi.EpcDocument(file_name+".epc")
print("Start deserialization of "+epc_file.getName())
repo=fesapi.DataObjectRepository()
warnings=epc_file.deserializeInto(repo)
ifnotwarnings:
print(warnings)
repo.clearWarnings()
hdf_proxy_count=repo.getHdfProxyCount()
print("There is/are "+str(hdf_proxy_count) +" hdf file(s) associated to this epc document.")
forhdf_proxy_indexinrange(0, hdf_proxy_count):
print("Hdf file relative path : "+repo.getHdfProxy(hdf_proxy_index).getRelativePath())
forwarninginrepo.getWarnings():
print("Warning : "+warning)
enum_str_mapper=fesapi.EnumStringMapper()
print("MAPPING ENUM VS STRING")
print("rock permeability == "+enum_str_mapper.getEnergisticsPropertyKindName(
enum_str_mapper.getEnergisticsPropertyKind("rock permeability")))
print("m (meter) == "+enum_str_mapper.getEnergisticsUnitOfMeasureName(
enum_str_mapper.getEnergisticsUnitOfMeasure("m")))
print("CRS")
forcrs_indexinrange(repo.getLocal3dCrsCount()):
crs=repo.getLocal3dCrs(crs_index)
print("Title is : "+crs.getTitle())
ifcrs.isProjectedCrsDefinedWithEpsg():
print("Projected : EPSG "+str(crs.getProjectedCrsEpsgCode()))
else:
ifcrs.isProjectedCrsUnknown():
print("Projected : Unknown. Reason is:"+crs.getProjectedCrsUnknownReason())
ifcrs.isATimeCrs():
print("It is a time CRS")
else:
print("It is a depth CRS")
ijk_grid_count=repo.getIjkGridRepresentationCount()
forijk_grid_indexinrange(ijk_grid_count):
show_ijk_grid(repo.getIjkGridRepresentation(ijk_grid_index))
serialize("./TestingPackagePython")
deserialize("./TestingPackagePython")