Closed Lian-Po-s-Study-Diary closed 8 months ago
You could try out our gemgis package which allows extracting the surfaces as pyvista meshes. You can then save them using pyvista to a vtk file
Thank you for your reply. I have reviewed the documentation for gemgis and cannot find a function that can convert gempy's geomodel object to a pyvista mesh
Perhaps due to software version updates, I did not find a suitable instance on the website to help me solve this problem.
I tried to write a test code based on the example on the Gemgis website.This is my test code. import gempy as gp
import os import sys import gemgis as gg import pyvista as pv
script_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
path1 = os.path.join(script_dir, "data/oo0.csv") path2 = os.path.join(script_dir, "data/oo.csv")
geo_model = gp.create_geomodel( project_name="Sand1", extent=[0, 400, 0, 400, 0, 200], resolution=[1, 1, 1], refinement=5, importer_helper=gp.data.ImporterHelper( path_to_orientations=path1, path_to_surface_points=path2 ) )
gp.compute_model(geo_model)
dict_sand1 = gg.visualization.create_depth_maps_from_gempy(geo_model=geo_model, surfaces='Sand1')
p = pv.Plotter(notebook=True)
p.add_mesh(dict_sand1['Sand1'][0], scalars='Depth [m]')
p.set_background('white') p.show_grid(color='black') p.show()
When I execute this script, it prompts“ File "E:\anaconda3\envs\py310\lib\site-packages\gemgis\visualization.py", line 1656, in create_depth_maps_from_gempy if not isinstance(geo_model, gp.core.model.Project): AttributeError: module 'gempy.core' has no attribute 'model'”
Have you found this here? Here you can extract the surfaces as pyvista meshes and can save them using pyvista as vtk file
I have reviewed this example.
I'm really sorry, I think I made a mistake with the version of gempy. I found that when I installed "gempy_viewer", the version of gempy was also updated to 2023.2.0b1.
When I am using this version, it seems that I cannot use "gg. visualization. create.depth_maps'from_gempy" for grid conversion, and the program prompts "module 'gempy. core' has no attribute 'model'".
Then, I tried using gempy2.3.1 and 2.2.12 in the new Python environment, but it seemed that many dependencies were incompatible and gempy never ran properly, so I couldn't perform grid conversion either.
Then, I compared the files in the "core" folder between version 2.3.1 and version 2023.2.0b1, and found that many files were missing in the new version.
Is it because of this reason that Gemgis cannot be used to convert grids, which can only be applied to versions below 2.3.1
@Lian-Po-s-Study-Diary,
the API has undergone a massive overhaul in the latest version. We will work on a fix for that!
Thank you for your reply. I have reinstalled gempy2.3.1 and successfully exported the grid as a vtk file. But I want to export the entire solid model, not just the surface model. I tried to convert 'basement' and 'topography' to gemgis grids, but failed. The code is as follows, 'dict_sand1['basement'][0].save('output_basement.vtk') ', prompt:'KeyError: 'basement'. What should I do?
The basement cannot be represented as surface as far as I know. The topography should be provided as raster file and can also be converted to a PyVista mesh
@Lian-Po-s-Study-Diary,
I have updated GemGIS, the function create_depth_maps
is now compatible with GemPy>=3. Please update using pip install gemgis==1.1.8
. A conda installation will follow during the day.
Okay, I'll give it a try. Thank you very much.
hello,I am a geologist and I am using gempy to try making underground coal seam models. I noticed that previous versions of gempy had a function to export models to vtk files, but it was cancelled in version 2.3.1. I tried using the previous version, but found that it is not compatible with Python and other inventory, and it has not been successful. I really need this feature to load the model into other software for processing. Is there any other way.