Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After the model is exported to pyvista, the coordinates are incorrect #898

Closed
Lian-Po-s-Study-Diary opened this issue May 18, 2024 · 3 comments

Comments

@Lian-Po-s-Study-Diary
Copy link

After I built the model using gempy3.0, I used the create_depth_maps_from_gempy method of gemgis to output the model to pyvista and found that the coordinates were wrong. It may be because gempy uses the method of normalizing coordinates. How should I restore the model to the actual size and actual position? Or, is there a way to directly output model files in gempy3.0?

@javoha
Copy link
Member

javoha commented May 21, 2024

Hi,
so if understand you correctly the coordinates within gempy are correct, but using the gemgis function does not work? As far as I know gemgis has not been updated to work with gempy v3, so it might take a while until this functionality is available.
I would suggest creating an issue in gemgis to ask about the current state.
Gempy v3 as of now does not have the functionality to save a full model. You can however export all the raw arrays of the result using .solutions.
Just some examples: geo_model.solutions.dc_meshes to retrieve the meshes plotted in vista, or data.grid.regular_grid.values and data.solutions.raw_arrays.lith_block for getting the vertices and lithologies of the grid.
Does this help?

@Lian-Po-s-Study-Diary
Copy link
Author

Thank you for your help. I successfully restored the model using geo_model. transforme

@javoha javoha closed this as completed May 22, 2024
@AlexanderJuestel
Copy link
Contributor

Here the code to export the meshes with their true XYZ coordinates


# List of Surfaces
surfaces = ['Layer1', 'Layer2']

# Getting a list of all surfaces
list_surfaces = list(geo_model.structural_frame.element_name_id_map.keys())

# Getting indices of provided surfaces
list_indices = [list_surfaces.index(surface) for surface in surfaces]

# Creating empty dict to store data
surfaces_poly = {}

for index in list_indices:

    # Extracting vertices
    vertices = geo_model.input_transform.apply_inverse(geo_model.solutions.raw_arrays.vertices[index])

    # Extracting faces
    faces = np.insert(geo_model.solutions.raw_arrays.edges[index], 0, 3, axis=1).ravel()

    # Creating PolyData from vertices and faces
    surf = pv.PolyData(vertices, faces)

    # Appending depth to PolyData
    surf['Depth [m]'] = geo_model.input_transform.apply_inverse(geo_model.solutions.raw_arrays.vertices[index])[:, 2]

    # Storing mesh, depth values and color values in dict
    surfaces_poly[list_surfaces[index]] = [surf, geo_model.structural_frame.elements_colors[index]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants