PlotTransient#
- class timflow.transient.plots.PlotTransient(ml)#
Bases:
timflow.plots.plots.PlotBasePlotting functionality for timflow.transient models.
Provides methods for visualizing model layouts, contours, and other transient model results.
- head_along_line(x1=0, x2=1, y1=0, y2=0, npoints=100, t=1.0, layers=None, sstart=0, color=None, lw=1, figsize=None, ax=None, legend=True, grid=True, **kwargs)#
Plot head along line.
- Parameters:
x1 (float) – start and end coordinates of line
x2 (float) – start and end coordinates of line
y1 (float) – start and end coordinates of line
y2 (float) – start and end coordinates of line
npoints (int) – number of points along line
t (scalar or array) – times at which to plot heads
layers (int, list of ints, optional) – layers for which to plot heads, default is None, which plots all layers
sstart (float) – starting distance for cross-section
color (str) – color of line
lw (float) – line width
figsize (tuple of 2 values) – size of figure
ax (matplotlib.Axes) – axes to plot on, default is None which creates a new figure
legend (bool) – add legend to plot
grid (bool) – add grid to plot
- Returns:
ax – axes with plot
- Return type:
matplotlib.Axes
- discharge_along_line(x1=0, x2=1, y1=0, y2=0, npoints=100, t=1.0, layers=0, sstart=0, color=None, lw=1, figsize=None, ax=None, legend=True, grid=True)#
Plot discharge along line.
- Parameters:
x1 (float) – start and end coordinates of line
x2 (float) – start and end coordinates of line
y1 (float) – start and end coordinates of line
y2 (float) – start and end coordinates of line
npoints (int) – number of points along line
t (scalar or array) – times at which to plot discharge
layers – layers for which to plot discharge
sstart (float) – starting distance for cross-section
color (str) – color of line
lw (float) – line width
figsize (tuple of 2 values) – size of figure
ax (matplotlib.Axes) – axes to plot on, default is None which creates a new figure
legend (bool) – add legend to plot
grid (bool) – add grid to plot
- Returns:
ax – axes with plot
- Return type:
matplotlib.Axes
- contour(win, ngr=20, t=1, layers=0, levels=20, layout=True, labels=True, decimals=1, color=None, cmap=None, ax=None, figsize=None, legend=True, return_contours=False, parallel=False, show_progress=False, **kwargs)#
Head contour plot.
- Parameters:
win (list or tuple) – [x1, x2, y1, y2]
ngr (scalar, tuple or list) – if scalar: number of grid points in x and y directions if tuple or list: nx, ny, number of grid points in x and y direction
t (scalar) – time
layers (integer, list or array) – layers for which grid is returned
levels (integer or array (default 20)) – levels that are contoured
layout (boolean (default True_)) – plot layout of elements
labels (boolean (default True)) – print labels along contours
decimals (integer (default 1)) – number of decimals of labels along contours
color (str or list of strings) – color of contour lines
cmap (str or matplotlib colormap) – colormap for contour lines, only used if color is None
ax (matplotlib.Axes) – axes to plot on, default is None which creates a new figure
figsize (tuple of 2 values (default is mpl default)) – size of figure
legend (list or boolean (default True)) – add legend to figure if list of strings: use strings as names in legend
return_contours (bool, optional) – if True, return list of contour sets for each contoured layer
parallel (bool or int, optional) – if True, compute headgrid in parallel using multiprocessing, default is False. If int is provided, it is interpreted as the number of processes to use.
show_progress (bool, optional) – if True, show progress bar when computing headgrid in parallel, default is False.
**kwargs – additional keyword arguments passed to ax.contour()
- Returns:
ax – axes with plot
- Return type:
matplotlib.Axes
- vcontour(win, n, t, levels=20, labels=True, decimals=0, color=None, cmap=None, vinterp=True, nudge=1e-06, ax=None, figsize=None, layout=True, horizontal_axis: Literal['x', 'y', 's'] = 's', return_contours=False, **kwargs)#
Head contour plot in vertical cross-section.
- Parameters:
win (list or tuple) – [xmin, xmax, ymin, ymax]
n (integer) – number of grid points along cross-section
t (scalar) – time
levels (integer or array (default 20)) – levels that are contoured
labels (boolean (default True)) – print labels along contours
decimals (integer (default 0)) – number of decimals of labels along contours
color (str or list of strings) – color of contour lines
cmap (str or matplotlib colormap) – colormap for contour lines, only used if color is None
vinterp (boolean) – when True, interpolate between centers of layers when False, constant value vertically in each layer
nudge (float) – small value to nudge grid points away from boundaries
ax (matplotlib.Axes) – axes to plot on, default is None which creates a new figure
figsize (tuple of 2 values (default is mpl default)) – size of figure
layout (boolean) – plot layout if True
horizontal_axis (str, optional) – ‘s’ for distance along cross-section on x-axis (default) ‘x’ for using x-coordinates on x-axis ‘y’ for using y-coordinates on x-axis
return_contours (bool) – if True, return contour set, default is False
**kwargs – additional keyword arguments passed to ax.contour()
- Returns:
cs
- Return type:
contour set
- quiver_xy(x, y, z, t, normalize=False, ax=None, figsize=None, parallel=False, **kwargs)#
Quiver plot of velocity field in xy-plane.
- Parameters:
x (1D arrays) – coordinates of grid points in x and y directions
y (1D arrays) – coordinates of grid points in x and y directions
z (scalar) – z-coordinate of plane in which to plot velocity field
t (scalar) – time at which to plot velocity field
normalize (bool) – if True, normalize velocity vectors to have length 1
ax (matplotlib.Axes) – axes to plot on, default is None which creates a new figure
figsize (tuple of 2 values) – size of figure
parallel (bool) – if True, compute velocity grid in parallel using multiprocessing, default is False
**kwargs – additional keyword arguments passed to ax.quiver()
- Returns:
ax – axes with plot
- Return type:
matplotlib.Axes
- quiver_z(x, y, z, t, normalize=False, ax=None, figsize=None, parallel=False, **kwargs)#
Quiver plot of velocity field in xz- or yz-plane.
- Parameters:
x (1D arrays) – coordinates of grid points in x and y directions
y (1D arrays) – coordinates of grid points in x and y directions
z (scalar) – z-coordinate of plane in which to plot velocity field
t (scalar) – time at which to plot velocity field
normalize (bool) – if True, normalize velocity vectors to have length 1
ax (matplotlib.Axes) – axes to plot on, default is None which creates a new figure
figsize (tuple of 2 values) – size of figure
parallel (bool) – if True, compute velocity grid in parallel using multiprocessing, default is False
**kwargs – additional keyword arguments passed to ax.quiver()
- Returns:
ax – axes with plot
- Return type:
matplotlib.Axes
- topview(win=None, ax=None, figsize=None, layers=None)#
Plot top-view.
This method plots all elements (in specified layers).
- Parameters:
win (list or tuple) – [x1, x2, y1, y2]
ax (matplotlib.Axes, optional) – axes to plot on, default is None which creates a new figure
figsize (tuple of 2 values) – size of figure
layers (int or list of ints, optional) – layers to plot, default is None which plots elements in all layers
- Returns:
ax – axes with plot
- Return type:
matplotlib.Axes
- xsection(xy: list[tuple[float]] | None = None, labels: bool = True, params: bool = False, names: bool = False, ax=None, fmt: str | None = None, units: dict | None = None, layer_names: tuple | dict = ('aquifer', 'leaky layer'), hstar: float | None = None, boundaries: bool = True, horizontal_axis: Literal['x', 'y', 's'] = 's', sep: Literal[', ', '\n'] = ', ', ha: str = 'center', **kwargs)#
Plot cross-section of model.
This is a shared method that handles cross-section plotting for both steady and transient models. The method automatically adapts the parameter labels based on the model type.
- Parameters:
xy (list of tuples, optional) – list of tuples with coordinates of the form [(x0, y0), (x1, y1)]. If not provided, a cross section with length 1 is plotted for 3D models. For cross-section models the left and right are derived from the elements.
labels (bool, optional) – add layer numbering labels to plot
params (bool, optional) – add parameter values to plot
names (bool, optional) – add inhomogeneity names to plot, only supported for cross-section models.
ax (matplotlib.Axes, optional) – axes to plot on, default is None which creates a new figure
fmt (str, optional) – format string for parameter values, e.g. ‘.2f’ for 2 decimals
units (dict, optional) – dictionary with units keyed by timflow parameter names, e.g. {‘kaq’: ‘m/d’, ‘c’: ‘d’, ‘Saq’: ‘m$^{-1}$’, ‘Sll’: ‘m$^{-1}$’}
layer_names (2-tuple or dict) – words to use for aquifers and leaky layers, default is (‘aquifer’, ‘leaky layer’). If a dict is provided, it maps layer type and number to a name, e.g. {‘aquifer 0’: ‘top aquifer’, ‘leaky layer 1’: ‘clay layer’}
horizontal_axis (str) – ‘s’ for distance along cross-section on x-axis (default) ‘x’ for using x-coordinates on x-axis ‘y’ for using y-coordinates on x-axis
hstar (float, optional) – override hstar value for plotting water level in transient 1D inhomogeneities that use hstar, useful for plotting pretty cross-sections when reference level is not equal to 0.
boundaries (bool, optional) – whether to plot aquifer boundaries for cross-section models, default is True
sep (str) – Separator between parameters, either “, “ or “n”
ha (str, optional) – Horizontal alignment for parameter labels. Defaults to “center”.
**kwargs – passed on to all ax.plot calls
- Returns:
ax – axes with plot
- Return type:
matplotlib.Axes
- topview_and_xsection(win=None, axes=None, figsize=None, topfigfrac=0.8, layers=None, horizontal_axis: Literal['x', 'y'] = 'x', **xsection_kwargs)#
Plot top-view above and cross-section below.
This method plots the top-view and cross-section side by side in a single figure.
- Parameters:
win (list or tuple) – [x1, x2, y1, y2]
axes (list of matplotlib.Axes, optional) – axes to plot on, default is None which creates a new figure
figsize (tuple of 2 values) – size of figure
topfigfrac (float) – fraction of figure width for top-view plot
layers (int or list of ints, optional) – layers to plot, default is None which plots elements in all layers
horizontal_axis (str) – ‘x’ for using x-coordinates on x-axis ‘y’ for using y-coordinates on x-axis
**xsection_kwargs (dict) – additional keyword arguments passed to xsection()
- Returns:
axes – axes with plots [topview_ax, xsection_ax]
- Return type:
list of matplotlib.Axes
- vcontour_array(x, y, arr, levels=20, labels=True, decimals=0, color=None, cmap=None, vinterp=True, ax=None, figsize=None, layout=True, horizontal_axis: Literal['x', 'y', 's'] = 's', return_contours=False, **kwargs)#
Contour array in vertical cross-section.
This method derives the vertical coordinates based on the model layers. It assumes that the input array has shape (layers, len(x)). Use vinterp to control whether to interpolate between layer centers or use constant values within each layer.
- Parameters:
x (1D array) – horizontal coordinates of grid points
y (1D array) – horizontal coordinates of grid points
arr (2D array) – array to contour, shape (naq, len(x))
levels (integer or array (default 20)) – levels that are contoured
labels (boolean (default True)) – print labels along contours
decimals (integer (default 0)) – number of decimals of labels along contours
color (str or list of strings) – color of contour lines
cmap (str or matplotlib colormap) – colormap for contour lines, only used if color is None
vinterp (boolean) – when True, interpolate between centers of layers when False, constant value vertically in each layer
ax (matplotlib.Axes) – axes to plot on, default is None which creates a new figure
figsize (tuple of 2 values (default is mpl default)) – size of figure
layout (boolean) – plot layout if True
horizontal_axis (str, optional) – ‘s’ for distance along cross-section on x-axis (default) ‘x’ for using x-coordinates on x-axis ‘y’ for using y-coordinates on x-axis
return_contours (bool) – if True, return contour set, default is False
**kwargs – additional keyword arguments passed to ax.contour()
- Returns:
cs
- Return type:
contour set
- abstractmethod headalongline(*args, **kwargs)#
Plot head along a line.
This method should be implemented by subclasses to provide model-specific head plotting functionality.
- Raises:
NotImplementedError – If not implemented in subclass