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 (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

fstr

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

modelflopy.ModelInterface object

any flopy model object, example flopy.modflow.Modflow() object

modelgridflopy.discretization.Grid object

any flopy modelgrid object, example. VertexGrid

vertical_exagerationfloat

floating point value to scale vertical exageration of the vtk points default is 1.

binarybool

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.

xmlbool

flag to write xml based VTK files

pvdbool

boolean flag to write a paraview pvd file for transient data. This file maps vtk files to a model time.

shared_pointsbool

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.

smoothbool

boolean flag to interpolate vertex elevations based on shared cell elevations. Default is False.

point_scalarsbool

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

Parameters
  • array (np.ndarray, list) – list of array values to set to the vtk_array

  • name (str) – array name for vtk

  • masked_values (list, None) – list of values to set equal to nan

  • dtype (vtk datatype object) – method to supply and force a vtk datatype

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_heads(hds, kstpkper=None, masked_values=None)[source]

Method to add head data to a vtk file

Parameters
  • hds (flopy.utils.LayerFile object) – Binary or Formatted HeadFile type object

  • 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

Parameters
  • model (fp.modflow.ModelInterface) – any flopy model object

  • selpaklist (list, None) – optional parameter where the user can supply a list of packages to export.

  • masked_values (list, None) – list of values to set equal to nan

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.

pathlinesnp.recarray or list

pathlines accepts a numpy recarray of a particle pathline or a list of numpy reccarrays associated with pathlines

timeseriesbool

method 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

Parameters
  • d (dict) – dictionary of array2d, arry3d data or numpy array data

  • name (str, None) – parameter name, required when user provides a dictionary of numpy arrays

  • masked_values (list, None) – list of values to set equal to nan

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

ddict

dictionary of vectors

namestr

name of vector to be displayed in vtk

masked_valueslist, None

list of values to set equal to nan

add_vector(vector, name, masked_values=None)[source]

Method to add vector data to vtk

Parameters
  • vector (array) – array of dimension (3, nnodes)

  • name (str) – name of the vector to be displayed in vtk

  • masked_values (list, None) – list of values to set equal to nan

write(f, kper=None)[source]

Method to write a vtk file from the VTK object

Parameters
  • f (str) – vtk file name

  • kpers (int, list, tuple) – stress period or list of stress periods to write to vtk. This parameter only applies to transient package data.

export_array(model, array, output_folder, name, nanval=- 1e+20, array2d=False, smooth=False, point_scalars=False, vtk_grid_type='auto', true2d=False, binary=True)[source]

DEPRECATED method to export array to vtk

Parameters
  • model (flopy model instance) – the flopy model instance

  • array (flopy array) – flopy 2d or 3d array

  • output_folder (str) – 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]

DEPRECATED method

Exports cell by cell file to vtk

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]

DEPRECATED method

Exports binary head file to vtk

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, package_names=None, nanval=- 1e+20, smooth=False, point_scalars=False, vtk_grid_type='auto', true2d=False, binary=True, kpers=None)[source]

DEPRECATED method to export model to vtk

Parameters
  • model (flopy model instance) – flopy model

  • otfolder (str) – 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, vtkobj=None, nanval=- 1e+20, smooth=False, point_scalars=False, vtk_grid_type='auto', true2d=False, binary=True, kpers=None)[source]

DEPRECATED method to export package to vtk

Parameters
  • pak_model (flopy model instance) – the model of the package

  • pak_name (str) – the name of the package

  • otfolder (str) – 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, name, nanval=- 1e+20, array2d=False, smooth=False, point_scalars=False, vtk_grid_type='auto', true2d=False, binary=True, kpers=None)[source]

DEPRECATED method to export transient arrays and lists to vtk

Parameters
  • model (MFModel) – the flopy model instance

  • array (Transient instance) – flopy transient array

  • output_folder (str) – 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.