flopy.export.vtk module
The vtk module provides functionality for exporting model inputs and outputs to VTK.
- class Pvd[source]
Bases:
object
Simple class to build a Paraview Data File (PVD)
- add_timevalue(file, timevalue)[source]
Method to add a Dataset record to the pvd file
- Parameters:
file (os.PathLike or str) – vtu file name
timevalue (float) – time step value in model time
- write(f)[source]
Method to write a pvd file from the PVD object.
- Parameters:
f (os.PathLike or str) – PVD file name
- class Vtk(model=None, modelgrid=None, vertical_exageration=1, binary=True, xml=False, pvd=False, shared_points=False, smooth=False, point_scalars=False)[source]
Bases:
object
Class that builds VTK objects and exports models to VTK files
- Parameters:
model (flopy.ModelInterface object) – any flopy model object, example flopy.modflow.Modflow() object
modelgrid (flopy.discretization.Grid object) – any flopy modelgrid object, example. VertexGrid
vertical_exageration (float) – floating point value to scale vertical exaggeration of the vtk points default is 1.
binary (bool) – flag that indicates if Vtk will write a binary or text file. Binary is preferred as paraview has a bug (8/4/2021) where is cannot represent NaN values from ASCII (non xml) files. In this case no-data values are set to 1e+30.
xml (bool) – flag to write xml based VTK files
pvd (bool) – boolean flag to write a paraview pvd file for transient data. This file maps vtk files to a model time.
shared_points (bool) – boolean flag to share points in grid polyhedron construction. Default is False, as paraview has a bug (8/4/2021) where some polyhedrons will not properly close when using shared points. If shared_points is True file size will be slightly smaller.
smooth (bool) – boolean flag to interpolate vertex elevations based on shared cell elevations. Default is False.
point_scalars (bool) – boolean flag to write interpolated data at each point based “shared vertices”.
- add_array(array, name, masked_values=None, dtype=None)[source]
Method to set an array to the vtk grid
- add_cell_budget(cbc, text=None, kstpkper=None, masked_values=None)[source]
Method to add cell budget data to vtk
- Parameters:
cbc (flopy.utils.CellBudget object) – flopy binary CellBudget object
text (str or None) – The text identifier for the record. Examples include ‘RIVER LEAKAGE’, ‘STORAGE’, ‘FLOW RIGHT FACE’, etc. If text=None all compatible records are exported
kstpkper (tuple, list of tuples, None) – tuple or list of tuples of kstpkper, if kstpkper=None all records are selected
masked_values (list, None) – list of values to set equal to nan
- add_model(model, selpaklist=None, masked_values=None)[source]
Method to add all array and transient list data from a modflow model to a timeseries of vtk files
- add_package(pkg, masked_values=None)[source]
Method to set all arrays within a package to VTK arrays
- Parameters:
pkg (flopy.pakbase.Package object) – flopy package object, example ModflowWel
masked_values (list, None) – list of values to set equal to nan
- add_pathline_points(pathlines, timeseries=False)[source]
Method to add particle pathlines to the grid, with points colored by travel-time. Supports MODPATH or MODFLOW6 PRT pathline format, or MODPATH timeseries format.
- Parameters:
pathlines (pd.dataframe, np.recarray or list) – Particle pathlines, either as a single dataframe or recarray or a list of such, separated by particle ID. If pathlines are not provided separately, the dataframe or recarray must have columns: ‘time’, ‘k’ & ‘particleid’ for MODPATH 3, 5, 6 or 7, and ‘irpt’, ‘iprp’, ‘imdl’, and ‘trelease’ for MODFLOW 6 PRT, so particle pathlines can be distinguished.
timeseries (bool, optional) – Whether to plot data as a series of vtk timeseries files for animation or as a single static vtk file. Default is false.
- add_transient_array(d, name=None, masked_values=None)[source]
Method to add transient array data to the vtk object
- add_transient_list(mflist, masked_values=None)[source]
Method to add transient list data to a vtk object
- Parameters:
mflist (flopy.utils.MfList object) –
masked_values (list, None) – list of values to set equal to nan
- add_transient_vector(d, name, masked_values=None)[source]
Method to add transient vector data to vtk
- to_pyvista()[source]
Convert VTK object to PyVista meshes. If the VTK object contains 0 or multiple meshes a list of meshes is returned. Otherwise the one mesh is returned alone. PyVista must be installed for this method.
- Returns:
PyVista mesh or list of meshes
- Return type:
pyvista.DataSet or list of pyvista.DataSet