flopy.plot.plotutil module
Module containing helper functions for plotting model data using ModelMap and ModelCrossSection. Functions for plotting shapefiles are also included.
- class PlotUtilities[source]
Bases:
object
Class which groups a collection of plotting utilities which Flopy and Flopy6 can use to generate map based plots
- static saturated_thickness(head, top, botm, laytyp, mask_values=None)[source]
Calculate the saturated thickness.
- Parameters:
head (numpy.ndarray) – head array
top (numpy.ndarray) – top array of shape (nrow, ncol)
botm (numpy.ndarray) – botm array of shape (nlay, nrow, ncol)
laytyp (numpy.ndarray) – confined (0) or convertible (1) of shape (nlay)
mask_values (list of floats) – If head is one of these values, then set sat to top - bot
- Returns:
sat_thk – Saturated thickness of shape (nlay, nrow, ncol).
- Return type:
- class SwiConcentration(model=None, botm=None, istrat=1, nu=None)[source]
Bases:
object
The binary_header class is a class to create headers for MODFLOW binary files
- calc_conc(zeta, layer=None)[source]
Calculate concentrations for a given time step using passed zeta.
- Parameters:
zeta (dictionary of numpy arrays) – Dictionary of zeta results. zeta keys are zero-based zeta surfaces.
layer (int) – Concentration will be calculated for the specified layer. If layer is None, then the concentration will be calculated for all layers. (default is None).
- Returns:
conc – Calculated concentration.
- Return type:
numpy array
Examples
>>> import flopy >>> m = flopy.modflow.Modflow.load('test') >>> c = flopy.plot.SwiConcentration(model=m) >>> conc = c.calc_conc(z, layer=0)
- class UnstructuredPlotUtilities[source]
Bases:
object
Collection of unstructured grid and vertex grid compatible plotting helper functions
- static arctan2(verts, reverse=False)[source]
Reads 2 dimensional set of verts and orders them using the arctan 2 method
- Parameters:
verts (np.array of floats) – Nx2 array of verts
- Returns:
verts – Nx2 array of verts
- Return type:
np.array of float
- static irregular_shape_patch(xverts, yverts=None)[source]
Patch for vertex cross-section plotting when we have an irregular shape type throughout the model grid or multiple shape types. This method is also used by the model splitter as a helper function for remapping the cell2d array.
- advanced_package_bc_helper(pkg, modelgrid, kper)[source]
Helper function for plotting boundary conditions from “advanced” packages
- Parameters:
pkg (flopy Package objects) –
modelgrid (flopy.discretization.Grid object) –
- filter_modpath_by_travel_time(recarray, travel_time)[source]
Helper method for filtering particles by travel time. Used in modpath plotting routines
- intersect_modpath_with_crosssection(recarrays, projpts, xvertices, yvertices, projection, ncpl, method='cell', starting=False)[source]
Method to intersect modpath output with a cross-section
- Parameters:
recarrays (list) – list of numpy recarrays
projpts (dict) – dict of crossectional cell vertices
xvertices (np.array) – array of modelgrid xvertices
yvertices (np.array) – array of modelgrid yvertices
projection (str) – projection direction (x or y)
ncpl (int) – number of cells per layer (cross sectional version)
method (str) – intersection method (‘cell’ or ‘all’)
starting (bool) – modpath starting location flag
- Returns:
dict
- Return type:
dictionary of intersecting recarrays
- plot_shapefile(shp, ax=None, radius=500.0, cmap='Dark2', edgecolor='scaled', facecolor='scaled', a=None, masked_values=None, idx=None, **kwargs)[source]
Generic function for plotting a shapefile.
- Parameters:
shp (string or os.PathLike) – Path of the shapefile to plot.
ax (matplolib.pyplot.axes object) –
radius (float) – Radius of circle for points. (Default is 500.)
cmap (string) – Name of colormap to use for polygon shading (default is ‘Dark2’)
edgecolor (string) – Color name. (Default is ‘scaled’ to scale the edge colors.)
facecolor (string) – Color name. (Default is ‘scaled’ to scale the face colors.)
a (numpy.ndarray) – Array to plot.
masked_values (iterable of floats, ints) – Values to mask.
idx (iterable int) – A list or array that contains shape numbers to include in the patch collection. Return all shapes if not specified.
kwargs (dictionary) – Keyword arguments that are passed to PatchCollection.set(
**kwargs
). Some common kwargs would be ‘linewidths’, ‘linestyles’, ‘alpha’, etc.
- Returns:
pc
- Return type:
Examples
- reproject_modpath_to_crosssection(idict, projpts, xypts, projection, modelgrid, ncpl, geographic_coords, starting=False)[source]
Method to reproject modpath points onto cross sectional line
- Parameters:
idict (dict) – dictionary of intersecting points
projpts (dict) – dictionary of cross sectional cells
xypts (dict) – dictionary of cross sectional line
projection (str) – projection direction (x or y)
modelgrid (Grid object) – flopy modelgrid object
ncpl (int) – number of cells per layer (cross sectional version)
geographic_coords (bool) – flag for plotting in geographic coordinates
starting (bool) – flag for modpath position
- Return type:
dictionary of projected modpath lines or points
- shapefile_extents(shp)[source]
Determine the extents of a shapefile
- Parameters:
shp (string) – Name of the shapefile to convert to a PatchCollection.
- Returns:
extents – tuple with xmin, xmax, ymin, ymax from shapefile.
- Return type:
Examples
>>> import flopy >>> fshp = 'myshapefile' >>> extent = flopy.plot.plotutil.shapefile_extents(fshp)
- shapefile_get_vertices(shp)[source]
Get vertices for the features in a shapefile
- Parameters:
shp (string) – Name of the shapefile to extract shapefile feature vertices.
- Returns:
vertices – Vertices is a list with vertices for each feature in the shapefile. Individual feature vertices are x, y tuples and contained in a list. A list with a single x, y tuple is returned for point shapefiles. A list with multiple x, y tuples is returned for polyline and polygon shapefiles.
- Return type:
Examples
>>> import flopy >>> fshp = 'myshapefile' >>> lines = flopy.plot.plotutil.shapefile_get_vertices(fshp)
- shapefile_to_patch_collection(shp: str | PathLike, radius=500.0, idx=None)[source]
Create a patch collection from the shapes in a shapefile
- Parameters:
- Returns:
pc – Patch collection of shapes in the shapefile
- Return type:
- to_mp7_endpoints(data: recarray | DataFrame) recarray | DataFrame [source]
Convert MODFLOW 6 PRT pathline data to MODPATH 7 endpoint format.
- Parameters:
data (np.recarray or pd.DataFrame) – MODFLOW 6 PRT pathline data
- Return type:
np.recarray or pd.DataFrame (consistent with input type)
- to_mp7_pathlines(data: recarray | DataFrame) recarray | DataFrame [source]
Convert MODFLOW 6 PRT pathline data to MODPATH 7 pathline format.
- Parameters:
data (np.recarray or pd.DataFrame) – MODFLOW 6 PRT pathline data
- Return type:
np.recarray or pd.DataFrame (consistent with input type)
- to_prt_pathlines(data: recarray | DataFrame) recarray | DataFrame [source]
Convert MODPATH 7 pathline or endpoint data to MODFLOW 6 PRT pathline format.
- Parameters:
data (np.recarray or pd.DataFrame) – MODPATH 7 pathline or endpoint data
- Return type:
np.recarray or pd.DataFrame (consistent with input type)