-
Notifications
You must be signed in to change notification settings - Fork 41
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
[ENH] Return lith_block cropped to topography using pvgeo #259
Comments
Update: currently I'm able to do this and export the result to VTK with the following code, but it requires that the model xy resolution be the same as in the DEM file with the topography, and I think there must be a more efficient way. But, in case it's useful:
|
Came across this whilst trying to figure out the same thing. I ended up with a workaround using
|
Hello and welcome! Thanks for posting your first issue in the GemGIS project! Someone from our developers will get back to you. If your question is support related, we may transfer it to the Discussions. |
I transfered your issue to our GemGIS repository as I thought that it could be a nice addition to the repo and as it is not entirely within the scope of GemPy |
def crop_block_to_topography(geo_model) -> pv.core.pointset.UnstructuredGrid:
"""Cropping GemPy solutions block to topography
Parameters:
___________
geo_model: gp.core.model.Project
Returns:
________
grid: pv.core.pointset.UnstructuredGrid
"""
# Trying to import GemPy
try:
import gempy as gp
except ModuleNotFoundError:
raise ModuleNotFoundError(
'GemPy package is not installed. Use pip install gempy to install the latest version')
# Trying to import PVGeo
try:
from PVGeo.grids import ExtractTopography
except ModuleNotFoundError:
raise ModuleNotFoundError('PVGeo package is not installed. Use pip install pvgeo to install the lastest version')
# Creating StructuredGrid
grid = pv.UniformGrid()
# Setting Grid Dimensions
grid.dimensions= np.array(geo_model.solutions.lith_block.reshape(geo_model.grid.regular_grid.resolution).shape)+1
# Setting Grid Origin
grid.origin = (geo_model.grid.regular_grid.extent[0],geo_model.grid.regular_grid.extent[2], geo_model.grid.regular_grid.extent[4]) # The bottom left corner of the data set
# Setting Grid Spacing
grid.spacing = ((geo_model.grid.regular_grid.extent[1]-geo_model.grid.regular_grid.extent[0])/geo_model.grid.regular_grid.resolution[0],
(geo_model.grid.regular_grid.extent[3]-geo_model.grid.regular_grid.extent[2])/geo_model.grid.regular_grid.resolution[1],
(geo_model.grid.regular_grid.extent[5]-geo_model.grid.regular_grid.extent[4])/geo_model.grid.regular_grid.resolution[2])
# Setting Cell Data
grid.cell_data['values']= geo_model.solutions.lith_block.reshape(geo_model.grid.regular_grid.resolution).flatten(order='F')
# Creating Polydata Dataset
topo = pv.PolyData(geo_model._grid.topography.values)
# Interpolating topography
topo.delaunay_2d(inplace=True)
extracted = ExtractTopography(tolerance=5, remove=True).apply(grid, topo)
return extracted |
Closing as this was added in #255 |
Putting this in a separate issue since it's just a small question. :)
Is it possible to return a lithology array where all cells above the land surface have been filled with NaNs or zeros?
It looks like you have something set up for it with
sol.mask_topo()
, but there's not quite enough documentation for me to figure out how to do it.sol.mask_topo(sol.mask_matrix)
gives me a dimension error because one is 1D and one is 3D.The text was updated successfully, but these errors were encountered: