modflowpy / flopy

A Python package to create, run, and post-process MODFLOW-based models.
https://flopy.readthedocs.io
Other
517 stars 313 forks source link

bug: Cannot open VTK file after creating it #2048

Closed sebmeng closed 10 months ago

sebmeng commented 10 months ago

Describe the bug I have a modflow 2005 file that i created using some DEM files used for thefining the lguide layers. Oustide the active domain i have -1e9 values, that's why i can't visualize it when i create the vtk file. I've tried to extract only the active cells, but is not possible, since the latest version flopy.export.vti.Vtk doesn't have the "nanvalue" option anymore.

To Reproduce Steps to reproduce the behavior:

modelgrid = sim.modelgrid

vtkobj = flopy.export.vtk.Vtk(sim, modelgrid=modelgrid, vertical_exageration=10)

vtkobj.add_array(sim.dis.botm.array, "botm")

hk = sim.lpf.hk.array

ibound = sim.bas6.ibound.array

active_cells = ibound > 0

hk_active = np.full_like(hk, np.nan)
hk_active[active_cells] = hk[active_cells]

vtkobj.add_array(hk_active, "ActiveCells")

vtkobj.write("model.vtk")

Expected behavior VTK file with active cells only

Screenshots

Desktop (please complete the following information): OS: Windows 10 -Visual Studio Code v1.76.2 Thanks in advance for the help!

jlarsen-usgs commented 10 months ago

The .add_array() method has a masked_values= parameter that will set array values to nan. Example usage:

vtkobj.add_array(hk_active, "ActiveCells", masked_values=[1e-9, any, other, values])