gwmod / nlmod

Python package to build, run and visualize MODFLOW 6 groundwater models in the Netherlands.
https://nlmod.readthedocs.io
MIT License
35 stars 3 forks source link

Improvements gdf to da #290

Closed bdestombe closed 11 months ago

bdestombe commented 11 months ago

Improvements to intersecting shapes to grid functions.

The buffer argument I would like to use for identifying transition zones between two layer_models.

Introduced a new function that counts in how many shapes a cell is present. Basically all the code was already there

bdestombe commented 11 months ago

Is there a flopy function to leave out parts of a vertex modelgrid? I would like to try it to see if it would speed up gdf_to_da

dbrakenhoff commented 11 months ago

Is there a flopy function to leave out parts of a vertex modelgrid? I would like to try it to see if it would speed up gdf_to_da

I'm not aware of any such functionality, though it should be fairly easy to use gridintersect to create a subset of geometries based on an intersection result. Recreating a model grid from that object would be a bit difficult though. But since you need to build the intersection geometries for that step anyway, I doubt it will speed things up much leaving them out of the next intersection calculations? The shapely intersection routines should be able to query the relevant parts of the grid relatively quickly, I think?

bdestombe commented 11 months ago

The PR currently contains all the improvents I was looking for. According to codacy there is a space too many. However, the tests stopped passing after PR #803, so passing that that seems out of the scope for this PR.

In a future PR it would be interesting to also vectorize the "aggregate values based on nearest to cell node"-function, and other aggregation functions.

rubencalje commented 11 months ago

Nice! I have fixed the failing test in pull request #289, so I think this is ok to merge. We should add some test for gdf_to_da, gdf_to_bool_da and the other methods in grid.py...

bdestombe commented 11 months ago

Is there a flopy function to leave out parts of a vertex modelgrid? I would like to try it to see if it would speed up gdf_to_da

I'm not aware of any such functionality, though it should be fairly easy to use gridintersect to create a subset of geometries based on an intersection result. Recreating a model grid from that object would be a bit difficult though. But since you need to build the intersection geometries for that step anyway, I doubt it will speed things up much leaving them out of the next intersection calculations? The shapely intersection routines should be able to query the relevant parts of the grid relatively quickly, I think?

Perfect, thank you so much for your response. I'll leave it at that then.