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 exageration of the vtk points default is 1.
binary (bool) – flag that indicates if Vtk will write a binary or text file. Binary is prefered 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) – boolen 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 Modpath output from a pathline or timeseries file to the grid. Colors will be representative of totim.
- 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
- export_array(model, array, output_folder: str | PathLike, name, nanval=-1e+20, array2d=False, smooth=False, point_scalars=False, vtk_grid_type='auto', true2d=False, binary=True)[source]
Export array to vtk
Deprecated since version 3.3.5: Use
Vtk.add_array()
- Parameters:
model (flopy model instance) – the flopy model instance
array (flopy array) – flopy 2d or 3d array
output_folder (str or PathLike) – output folder to write the data
name (str) – name of array
nanval (scalar) – no data value, default value is -1e20
array2d (bool) – true if the array is 2d and represents the first layer, default is False
smooth (bool) – if True, will create smooth layer elevations, default is False
point_scalars (bool) – if True, will also output array values at cell vertices, default is False; note this automatically sets smooth to True
vtk_grid_type (str) –
Specific vtk_grid_type or ‘auto’ (default). Possible specific values are ‘ImageData’, ‘RectilinearGrid’, and ‘UnstructuredGrid’. If ‘auto’, the grid type is automatically determined. Namely:
A regular grid (in all three directions) will be saved as an ‘ImageData’.
A rectilinear (in all three directions), non-regular grid will be saved as a ‘RectilinearGrid’.
Other grids will be saved as ‘UnstructuredGrid’.
true2d (bool) – If True, the model is expected to be 2d (1 layer, 1 row or 1 column) and the data will be exported as true 2d data, default is False.
binary (bool) – if True the output file will be binary, default is False
- export_cbc(model, cbcfile, otfolder, precision='single', verbose=False, nanval=-1e+20, kstpkper=None, text=None, smooth=False, point_scalars=False, vtk_grid_type='auto', true2d=False, binary=True)[source]
Exports cell by cell file to vtk
Deprecated since version 3.3.5: Use
Vtk.add_cell_budget()
- Parameters:
model (flopy model instance) – the flopy model instance
cbcfile (str) – the cell by cell file
otfolder (str) – output folder to write the data
precision (str) – Precision of data in the cell by cell file: ‘single’ or ‘double’. Default is ‘single’.
verbose (bool) – If True, write information to the screen. Default is False.
nanval (scalar) – no data value
kstpkper (tuple of ints or list of tuple of ints) – A tuple containing the time step and stress period (kstp, kper). The kstp and kper values are zero based.
text (str or list of str) – The text identifier for the record. Examples include ‘RIVER LEAKAGE’, ‘STORAGE’, ‘FLOW RIGHT FACE’, etc.
smooth (bool) – if True, will create smooth layer elevations, default is False
point_scalars (bool) – if True, will also output array values at cell vertices, default is False; note this automatically sets smooth to True
vtk_grid_type (str) –
Specific vtk_grid_type or ‘auto’ (default). Possible specific values are ‘ImageData’, ‘RectilinearGrid’, and ‘UnstructuredGrid’. If ‘auto’, the grid type is automatically determined. Namely:
A regular grid (in all three directions) will be saved as an ‘ImageData’.
A rectilinear (in all three directions), non-regular grid will be saved as a ‘RectilinearGrid’.
Other grids will be saved as ‘UnstructuredGrid’.
true2d (bool) – If True, the model is expected to be 2d (1 layer, 1 row or 1 column) and the data will be exported as true 2d data, default is False.
binary (bool) – if True the output file will be binary, default is False
- export_heads(model, hdsfile, otfolder, text='head', precision='auto', verbose=False, nanval=-1e+20, kstpkper=None, smooth=False, point_scalars=False, vtk_grid_type='auto', true2d=False, binary=True)[source]
Exports binary head file to vtk
Deprecated since version 3.3.5: Use
Vtk.add_heads()
- Parameters:
model (MFModel) – the flopy model instance
hdsfile (str, HeadFile object) – binary head file path or object
otfolder (str) – output folder to write the data
text (string) – Name of the text string in the head file. Default is ‘head’.
precision (str) – Precision of data in the head file: ‘auto’, ‘single’ or ‘double’. Default is ‘auto’.
verbose (bool) – If True, write information to the screen. Default is False.
nanval (scalar) – no data value, default value is -1e20
kstpkper (tuple of ints or list of tuple of ints) – A tuple containing the time step and stress period (kstp, kper). The kstp and kper values are zero based.
smooth (bool) – if True, will create smooth layer elevations, default is False
point_scalars (bool) – if True, will also output array values at cell vertices, default is False; note this automatically sets smooth to True
vtk_grid_type (str) –
Specific vtk_grid_type or ‘auto’ (default). Possible specific values are ‘ImageData’, ‘RectilinearGrid’, and ‘UnstructuredGrid’. If ‘auto’, the grid type is automatically determined. Namely:
A regular grid (in all three directions) will be saved as an ‘ImageData’.
A rectilinear (in all three directions), non-regular grid will be saved as a ‘RectilinearGrid’.
Other grids will be saved as ‘UnstructuredGrid’.
true2d (bool) – If True, the model is expected to be 2d (1 layer, 1 row or 1 column) and the data will be exported as true 2d data, default is False.
binary (bool) – if True the output file will be binary, default is False
- export_model(model, otfolder: str | PathLike, package_names=None, nanval=-1e+20, smooth=False, point_scalars=False, vtk_grid_type='auto', true2d=False, binary=True, kpers=None)[source]
Export model to vtk
Deprecated since version 3.3.5: Use
Vtk.add_model()
- Parameters:
model (flopy model instance) – flopy model
otfolder (str or PathLike) – output folder
package_names (list) – list of package names to be exported
nanval (scalar) – no data value, default value is -1e20
array2d (bool) – True if array is 2d, default is False
smooth (bool) – if True, will create smooth layer elevations, default is False
point_scalars (bool) – if True, will also output array values at cell vertices, default is False; note this automatically sets smooth to True
vtk_grid_type (str) –
Specific vtk_grid_type or ‘auto’ (default). Possible specific values are ‘ImageData’, ‘RectilinearGrid’, and ‘UnstructuredGrid’. If ‘auto’, the grid type is automatically determined. Namely:
A regular grid (in all three directions) will be saved as an ‘ImageData’.
A rectilinear (in all three directions), non-regular grid will be saved as a ‘RectilinearGrid’.
Other grids will be saved as ‘UnstructuredGrid’.
true2d (bool) – If True, the model is expected to be 2d (1 layer, 1 row or 1 column) and the data will be exported as true 2d data, default is False.
binary (bool) – if True the output file will be binary, default is False
kpers (iterable of int) – Stress periods to export. If None (default), all stress periods will be exported.
- export_package(pak_model, pak_name, otfolder: str | PathLike, vtkobj=None, nanval=-1e+20, smooth=False, point_scalars=False, vtk_grid_type='auto', true2d=False, binary=True, kpers=None)[source]
Export package to vtk
Deprecated since version 3.3.5: Use
Vtk.add_package()
- Parameters:
pak_model (flopy model instance) – the model of the package
pak_name (str) – the name of the package
otfolder (str or PathLike) – output folder to write the data
vtkobj (VTK instance) – a vtk object (allows export_package to be called from export_model)
nanval (scalar) – no data value, default value is -1e20
smooth (bool) – if True, will create smooth layer elevations, default is False
point_scalars (bool) – if True, will also output array values at cell vertices, default is False; note this automatically sets smooth to True
vtk_grid_type (str) –
Specific vtk_grid_type or ‘auto’ (default). Possible specific values are ‘ImageData’, ‘RectilinearGrid’, and ‘UnstructuredGrid’. If ‘auto’, the grid type is automatically determined. Namely:
A regular grid (in all three directions) will be saved as an ‘ImageData’.
A rectilinear (in all three directions), non-regular grid will be saved as a ‘RectilinearGrid’.
Other grids will be saved as ‘UnstructuredGrid’.
true2d (bool) – If True, the model is expected to be 2d (1 layer, 1 row or 1 column) and the data will be exported as true 2d data, default is False.
binary (bool) – if True the output file will be binary, default is False
kpers (iterable of int) – Stress periods to export. If None (default), all stress periods will be exported.
- export_transient(model, array, output_folder: str | PathLike, name, nanval=-1e+20, array2d=False, smooth=False, point_scalars=False, vtk_grid_type='auto', true2d=False, binary=True, kpers=None)[source]
Export transient arrays and lists to vtk
Deprecated since version 3.3.5: Use
Vtk.add_transient_array()
orVtk.add_transient_list()
- Parameters:
model (MFModel) – the flopy model instance
array (Transient instance) – flopy transient array
output_folder (str or PathLike) – output folder to write the data
name (str) – name of array
nanval (scalar) – no data value, default value is -1e20
array2d (bool) – True if array is 2d, default is False
smooth (bool) – if True, will create smooth layer elevations, default is False
point_scalars (bool) – if True, will also output array values at cell vertices, default is False; note this automatically sets smooth to True
vtk_grid_type (str) –
Specific vtk_grid_type or ‘auto’ (default). Possible specific values are ‘ImageData’, ‘RectilinearGrid’, and ‘UnstructuredGrid’. If ‘auto’, the grid type is automatically determined. Namely:
A regular grid (in all three directions) will be saved as an ‘ImageData’.
A rectilinear (in all three directions), non-regular grid will be saved as a ‘RectilinearGrid’.
Other grids will be saved as ‘UnstructuredGrid’.
true2d (bool) – If True, the model is expected to be 2d (1 layer, 1 row or 1 column) and the data will be exported as true 2d data, default is False.
binary (bool) – if True the output file will be binary, default is False
kpers (iterable of int) – Stress periods to export. If None (default), all stress periods will be exported.