flopy.plot.crosssection module
- class PlotCrossSection(model=None, modelgrid=None, ax=None, line=None, extent=None, geographic_coords=False)[source]
Bases:
object
Class to create a cross sectional plot of a model.
- Parameters:
ax (matplotlib.pyplot axis) – The plot axis. If not provided it, plt.gca() will be used.
model (flopy.modflow object) – flopy model object. (Default is None)
modelgrid (flopy.discretization.Grid object) – can be a StructuredGrid, VertexGrid, or UnstructuredGrid object
line (dict) – Dictionary with either “row”, “column”, or “line” key. If key is “row” or “column” key value should be the zero-based row or column index for cross-section. If key is “line” value should be an array of (x, y) tuples with vertices of cross-section. Vertices should be in map coordinates consistent with xul, yul, and rotation.
extent (tuple of floats) – (xmin, xmax, ymin, ymax) will be used to specify axes limits. If None then these will be calculated based on grid, coordinates, and rotation.
geographic_coords (bool) – boolean flag to allow the user to plot cross section lines in geographic coordinates. If False (default), cross section is plotted as the distance along the cross section line.
- contour_array(a, masked_values=None, head=None, **kwargs)[source]
Contour a two-dimensional array.
- Parameters:
a (numpy.ndarray) – Three-dimensional array to plot.
masked_values (iterable of floats, ints) – Values to mask.
head (numpy.ndarray) – Three-dimensional array to set top of patches to the minimum of the top of a layer or the head value. Used to create patches that conform to water-level elevations.
**kwargs (dictionary) – keyword arguments passed to matplotlib.pyplot.contour
- Returns:
contour_set
- Return type:
matplotlib.pyplot.contour
- get_extent()[source]
Get the extent of the rotated and offset grid
- Returns:
tuple
- Return type:
(xmin, xmax, ymin, ymax)
- get_grid_line_collection(**kwargs)[source]
Get a PatchCollection of the grid
- Parameters:
**kwargs (dictionary) – keyword arguments passed to matplotlib.collections.LineCollection
- Returns:
PatchCollection
- Return type:
- get_grid_patch_collection(plotarray, projpts=None, fill_between=False, **kwargs)[source]
Get a PatchCollection of plotarray in unmasked cells
- Parameters:
plotarray (numpy.ndarray) – One-dimensional array to attach to the Patch Collection.
projpts (dict) – dictionary defined by node number which contains model patch vertices.
fill_between (bool) – flag to create polygons that mimick the matplotlib fill between method. Only used by the plot_fill_between method.
**kwargs (dictionary) – keyword arguments passed to matplotlib.collections.PatchCollection
- Returns:
patches
- Return type:
- plot_array(a, masked_values=None, head=None, **kwargs)[source]
Plot a three-dimensional array as a patch collection.
- Parameters:
a (numpy.ndarray) – Three-dimensional array to plot.
masked_values (iterable of floats, ints) – Values to mask.
head (numpy.ndarray) – Three-dimensional array to set top of patches to the minimum of the top of a layer or the head value. Used to create patches that conform to water-level elevations.
**kwargs (dictionary) – keyword arguments passed to matplotlib.collections.PatchCollection
- Returns:
patches
- Return type:
- plot_bc(name=None, package=None, kper=0, color=None, head=None, **kwargs)[source]
Plot boundary conditions locations for a specific boundary type from a flopy model
- Parameters:
name (string) – Package name string (‘WEL’, ‘GHB’, etc.). (Default is None)
package (flopy.modflow.Modflow package class instance) – flopy package class instance. (Default is None)
kper (int) – Stress period to plot
color (string) – matplotlib color string. (Default is None)
head (numpy.ndarray) – Three-dimensional array (structured grid) or Two-dimensional array (vertex grid) to set top of patches to the minimum of the top of a layer or the head value. Used to create patches that conform to water-level elevations.
**kwargs (dictionary) – keyword arguments passed to matplotlib.collections.PatchCollection
- Returns:
patches
- Return type:
- plot_endpoint(ep, direction='ending', selection=None, selection_direction=None, method='cell', head=None, **kwargs)[source]
- plot_fill_between(a, colors=('blue', 'red'), masked_values=None, head=None, **kwargs)[source]
Plot a three-dimensional array as lines.
- Parameters:
a (numpy.ndarray) – Three-dimensional array to plot.
colors (list) – matplotlib fill colors, two required
masked_values (iterable of floats, ints) – Values to mask.
head (numpy.ndarray) – Three-dimensional array to set top of patches to the minimum of the top of a layer or the head value. Used to create patches that conform to water-level elevations.
**kwargs (dictionary) – keyword arguments passed to matplotlib.pyplot.plot
- Returns:
plot
- Return type:
list containing matplotlib.fillbetween objects
- plot_grid(**kwargs)[source]
Plot the grid lines.
- Parameters:
kwargs (ax, colors. The remaining kwargs are passed into the) – the LineCollection constructor.
- Returns:
lc
- Return type:
- plot_ibound(ibound=None, color_noflow='black', color_ch='blue', color_vpt='red', head=None, **kwargs)[source]
Make a plot of ibound. If not specified, then pull ibound from the self.model
- Parameters:
ibound (numpy.ndarray) – ibound array to plot. (Default is ibound in ‘BAS6’ package.)
color_noflow (string) – (Default is ‘black’)
color_ch (string) – Color for constant heads (Default is ‘blue’.)
head (numpy.ndarray) – Three-dimensional array to set top of patches to the minimum of the top of a layer or the head value. Used to create patches that conform to water-level elevations.
**kwargs (dictionary) – keyword arguments passed to matplotlib.collections.PatchCollection
- Returns:
patches
- Return type:
- plot_inactive(ibound=None, color_noflow='black', **kwargs)[source]
Make a plot of inactive cells. If not specified, then pull ibound from the self.ml
- Parameters:
ibound (numpy.ndarray) – ibound array to plot. (Default is ibound in ‘BAS6’ package.)
color_noflow (string) – (Default is ‘black’)
- Returns:
quadmesh
- Return type:
- plot_pathline(pl, travel_time=None, method='cell', head=None, **kwargs)[source]
Plot the MODPATH pathlines
- Parameters:
pl (list of rec arrays or a single rec array) – rec array or list of rec arrays is data returned from modpathfile PathlineFile get_data() or get_alldata() methods. Data in rec array is ‘x’, ‘y’, ‘z’, ‘time’, ‘k’, and ‘particleid’.
travel_time (float or str) – travel_time is a travel time selection for the displayed pathlines. If a float is passed then pathlines with times less than or equal to the passed time are plotted. If a string is passed a variety logical constraints can be added in front of a time value to select pathlines for a select period of time. Valid logical constraints are <=, <, ==, >=, and >. For example, to select all pathlines less than 10000 days travel_time=’< 10000’ would be passed to plot_pathline. (default is None)
method (str) –
- “cell” shows only pathlines that intersect with a cell
- ”all” projects all pathlines onto the cross section regardless
of whether they intersect with a given cell
head (np.ndarray) – optional adjustment to only show pathlines that are <= to the top of the water table given a user supplied head array
kwargs (layer, ax, colors. The remaining kwargs are passed) – into the LineCollection constructor.
- Returns:
lc
- Return type:
- plot_surface(a, masked_values=None, **kwargs)[source]
Plot a two- or three-dimensional array as line(s).
- Parameters:
a (numpy.ndarray) – Two- or three-dimensional array to plot.
masked_values (iterable of floats, ints) – Values to mask.
**kwargs (dictionary) – keyword arguments passed to matplotlib.pyplot.plot
- Returns:
plot
- Return type:
list containing matplotlib.plot objects
- plot_timeseries(ts, travel_time=None, method='cell', head=None, **kwargs)[source]
Plot the MODPATH timeseries.
- Parameters:
ts (list of rec arrays or a single rec array) – rec array or list of rec arrays is data returned from modpathfile TimeseriesFile get_data() or get_alldata() methods. Data in rec array is ‘x’, ‘y’, ‘z’, ‘time’, ‘k’, and ‘particleid’.
travel_time (float or str) – travel_time is a travel time selection for the displayed pathlines. If a float is passed then pathlines with times less than or equal to the passed time are plotted. If a string is passed a variety logical constraints can be added in front of a time value to select pathlines for a select period of time. Valid logical constraints are <=, <, ==, >=, and >. For example, to select all pathlines less than 10000 days travel_time=’< 10000’ would be passed to plot_pathline. (default is None)
kwargs (layer, ax, colors. The remaining kwargs are passed) – into the LineCollection constructor. If layer=’all’, pathlines are output for all layers
- Returns:
lo
- Return type:
list of Line2D objects
- plot_vector(vx, vy, vz, head=None, kstep=1, hstep=1, normalize=False, masked_values=None, **kwargs)[source]
Plot a vector.
- Parameters:
vx (np.ndarray) – x component of the vector to be plotted (non-rotated) array shape must be (nlay, nrow, ncol) for a structured grid array shape must be (nlay, ncpl) for a unstructured grid
vy (np.ndarray) – y component of the vector to be plotted (non-rotated) array shape must be (nlay, nrow, ncol) for a structured grid array shape must be (nlay, ncpl) for a unstructured grid
vz (np.ndarray) – y component of the vector to be plotted (non-rotated) array shape must be (nlay, nrow, ncol) for a structured grid array shape must be (nlay, ncpl) for a unstructured grid
head (numpy.ndarray) – MODFLOW’s head array. If not provided, then the quivers will be plotted in the cell center.
kstep (int) – layer frequency to plot (default is 1)
hstep (int) – horizontal frequency to plot (default is 1)
normalize (bool) – boolean flag used to determine if vectors should be normalized using the vector magnitude in each cell (default is False)
masked_values (iterable of floats) – values to mask
kwargs (matplotlib.pyplot keyword arguments for the) – plt.quiver method
- Returns:
quiver – result of the quiver function
- Return type:
matplotlib.pyplot.quiver
- property polygons
Method to return cached matplotlib polygons for a cross section
- Returns:
dict
- Return type:
- set_zcentergrid(vs, kstep=1)[source]
Get an array of z elevations at the center of a cell that is based on minimum of cell top elevation (self.elev) or passed vs numpy.ndarray
- Parameters:
vs (numpy.ndarray) – Three-dimensional array to plot.
kstep (int) – plotting layer interval
- Returns:
zcentergrid
- Return type:
- set_zpts(vs)[source]
Get an array of projected vertices corrected with corrected elevations based on minimum of cell elevation (self.elev) or passed vs numpy.ndarray
- Parameters:
vs (numpy.ndarray) – Two-dimensional array to plot.
- Returns:
zpts
- Return type: