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

feat(vtk): add to_pyvista() method #1771

Merged
merged 2 commits into from
Apr 30, 2023

Conversation

wpbonelli
Copy link
Member

@wpbonelli wpbonelli commented Apr 22, 2023

Add to_pyvista() method to the Vtk class as suggested here. Returns up to 3 PyVista meshes:

  • underlying modelgrid
  • polygons (e.g. for HFB)
  • particle tracking pathlines

Only meshes which have been populated with add_model(), add_pathline_points(), etc are returned. If only one mesh has been configured, it is returned alone. If zero or >1 meshes have been configured, the return value is a list. This allows similar usage for 1+ meshes via tuple dereferencing

from flopy.export.vtk import Vtk

vtk = Vtk(model=gwf, binary=False, smooth=False)

# given model 'gwf'
vtk.add_model(gwf)
grid = vtk.to_pyvista()

# given recarray or list of recarrays 'pl'
vtk.add_pathline_points(pl)
grid, pathlines = vtk.to_pyvista()

Not sure this is the right approach — other options could be

  • independent methods for each mesh, e.g. grid_to_pyvista(), polygons_to_pyvista()
  • a parameter to select the mesh with default value "grid", e.g. to_pyvista(), to_pyvista(mesh="pathlines")

A similar to_pyvista() method may also be convenient on Grid types

@codecov
Copy link

codecov bot commented Apr 22, 2023

Codecov Report

Merging #1771 (608aae3) into develop (7db9263) will increase coverage by 0.0%.
The diff coverage is 100.0%.

@@           Coverage Diff           @@
##           develop   #1771   +/-   ##
=======================================
  Coverage     72.1%   72.1%           
=======================================
  Files          254     254           
  Lines        55914   55919    +5     
=======================================
+ Hits         40364   40369    +5     
  Misses       15550   15550           
Impacted Files Coverage Δ
flopy/export/vtk.py 70.2% <100.0%> (+0.1%) ⬆️

@wpbonelli wpbonelli marked this pull request as ready for review April 24, 2023 15:06
@wpbonelli wpbonelli requested a review from mwtoews April 25, 2023 12:13
Copy link
Contributor

@mwtoews mwtoews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

autotest/test_export.py Outdated Show resolved Hide resolved
@wpbonelli wpbonelli merged commit 5352425 into modflowpy:develop Apr 30, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants