Skip to content

bug: Cannot open VTK file after creating it #2052

Closed Answered by sebmeng
sebmeng asked this question in Q&A
Discussion options

You must be logged in to vote

I found the full workaraound to export only the active cells with pyvista and vtk:

# Load the model
modelname = 'Gondebeek_SS' 
sim = flopy.modflow.Modflow.load(modelname, model_ws='.', exe_name='MODFLOW-NWT.exe')

# Get the modelgrid from the model
modelgrid = sim.modelgrid

# Create a vtk object
vtkobj = flopy.export.vtk.Vtk(sim, modelgrid=modelgrid, vertical_exageration=10,binary=False)

# Flatten the entire 3D array of bottom elevations
botm_flattened = sim.dis.botm.array.flatten()

# Add the flattened array to the VTK object
vtkobj.add_array(botm_flattened, "botm")

# Calculate the top elevations
botm = sim.dis.botm.array
top = np.empty_like(botm)
top[0] = sim.dis.top.array
top[1:] =…

Replies: 5 comments 11 replies

Comment options

You must be logged in to vote
6 replies
@wpbonelli
Comment options

@sebmeng
Comment options

@sebmeng
Comment options

@sebmeng
Comment options

@vcantarella
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@wpbonelli
Comment options

@sebmeng
Comment options

Comment options

You must be logged in to vote
3 replies
@wpbonelli
Comment options

@wpbonelli
Comment options

@sebmeng
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by wpbonelli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #2048 on December 27, 2023 15:23.