gempy-project / gempy

GemPy is an open-source, Python-based 3-D structural geological modeling software, which allows the implicit (i.e. automatic) creation of complex geological models from interface and orientation data. It also offers support for stochastic modeling to address parameter and model uncertainties.
https://gempy.org
European Union Public License 1.2
941 stars 232 forks source link

Coordinates missing #906

Closed qing-1998 closed 1 month ago

qing-1998 commented 1 month ago

hi, It seems i lost the Coordinates of surface points when i use "=gg.visualization.create_depth_maps_from_gempy(geo_model=geo_model, surfaces='sand1')", and also can not find it in "= geo_model.solutions.raw_arrays", i want to extract the model to pyvista , then make it to be a solid model , i use gempy-2024.1.4 , pls tell me how could i do , thanks. Have a nice day.

AlexanderJuestel commented 1 month ago

Dear @qing-1998,

GemGIS currently works with GemPy Versions < 3. I am currently testing GemPy 3 and work solutions to make GemGIS compatible with GemPy 3.

Stay tuned

qing-1998 commented 1 month ago

Is there any other way to get vertices and faces from geo_model or i need to use GemPy versions <3?

glory21 commented 1 month ago

Hi @qing-1998, I also am trying get vertices and faces from geo_model. I ran the following code, but there was an error.

vertices, faces = gp.get_surfaces(geo_model)

enter values to shift model

x0, y0, z0 = 0, 0, -700

save model

for i in range(len(vertices)): np.save('vertices/' + 'vert%02d.npy' %i, vertices[i]-[x0, y0, z0]) np.save('faces/' + 'faces%02d.npy' %i, faces[i]) print(len(vertices[i]))

AttributeError: module 'gempy' has no attribute 'get_surfaces'

qing-1998 commented 1 month ago

@glory21 As i know there has no attribute 'get surfaces' in GenPy3 @AlexanderJuestel But when i import gempy_legacy , there has an error 'ModuleNotFoundError: No module named 'numpy.distutils' , if i do not import gempy_legacy , the code can run normally.

javoha commented 1 month ago

Hi, @glory21: Again I think you should switch to gempy_v3 and use the method suggested in your issue (or here).

@qing-1998: So you can get the meshes either from geo_model.solutions.dc_meshes or geo_model.solutions.raw_arrays.vertices and geo_model.solutions.raw_arrays.edges . You are correct though that the coordinates are not in the orginal form, as we use a coordinate transformation in gempy. You can easily back transform them appplying the inverse as follows

data.transform.apply_inverse(data.solutions.raw_arrays.vertices[2])

The index here is refering to a specific mesh for a structural element.

Please let me know if this is the solution you are looking for.

Cheers Jan

qing-1998 commented 1 month ago

@javoha Thanks , the problem has been solved. Have a nice day

Jo

AlexanderJuestel commented 1 month ago

Just for completion:

Mesh extracted with GemGIS using mesh = gg.visualization.create_depth_maps_from_gempy(geo_model, `surface1') with incorrect coordinates.

image

Mesh extracted using geo_model.solutions.dc_meshes with incorrect coordinates and the following code:

meshes_gempy = geo_model.solutions.dc_meshes
faces = np.hstack(np.pad(meshes_gempy[0].edges, ((0, 0), (1, 0)), 'constant', constant_values=3))
mesh = pv.PolyData(meshes_gempy[0].vertices, faces)

image

Mesh extracted with correct coordinates using the proposed transform.

vertices = geo_model.transform.apply_inverse(geo_model.solutions.raw_arrays.vertices[0])
faces = np.hstack(np.pad(geo_model.solutions.raw_arrays.edges, ((0, 0), (1, 0)), 'constant', constant_values=3))
mesh = pv.PolyData(vertices, faces)
# Assigning Depth values to mesh
mesh['Depth [m]'] = mesh.points[:, 2]

image