flopy.utils.postprocessing module

get_extended_budget(cbcfile, precision='single', idx=None, kstpkper=None, totim=None, boundary_ifaces=None, hdsfile=None, model=None)[source]

Get the flow rate across cell faces including potential stresses applied along boundaries at a given time. Only implemented for “classical” MODFLOW versions where the budget is recorded as FLOW RIGHT FACE, FLOW FRONT FACE and FLOW LOWER FACE arrays.

Parameters:
  • cbcfile (str) – Cell by cell file produced by Modflow.
  • precision (str) – Binary file precision, default is ‘single’.
  • idx (int or list) – The zero-based record number.
  • kstpkper (tuple of ints) – A tuple containing the time step and stress period (kstp, kper). The kstp and kper values are zero based.
  • totim (float) – The simulation time.
  • boundary_ifaces (dictionary {str: int or list}) – A dictionary defining how to treat stress flows at boundary cells. The keys are budget terms corresponding to stress packages (same term as in the overall volumetric budget printed in the listing file). The values are either a single iface number to be applied to all cells for the stress package, or a list of lists describing individual boundary cells in the same way as in the package input plus the iface number appended. The iface number indicates the face to which the stress flow is assigned, following the MODPATH convention (see MODPATH user guide). Example: boundary_ifaces = { ‘RECHARGE’: 6, ‘RIVER LEAKAGE’: 6, ‘CONSTANT HEAD’: [[lay, row, col, iface], …], ‘WELLS’: [[lay, row, col, flux, iface], …], ‘HEAD DEP BOUNDS’: [[lay, row, col, head, cond, iface], …]}. Note: stresses that are not informed in boundary_ifaces are implicitly treated as internally-distributed sinks/sources.
  • hdsfile (str) – Head file produced by MODFLOW (only required if boundary_ifaces is used).
  • model (flopy.modflow.Modflow object) – Modflow model instance (only required if boundary_ifaces is used).
Returns:

(Qx_ext, Qy_ext, Qz_ext) – Flow rates across cell faces. Qx_ext is a ndarray of size (nlay, nrow, ncol + 1). Qy_ext is a ndarray of size (nlay, nrow + 1, ncol). The sign is such that the y axis is considered to increase in the north direction. Qz_ext is a ndarray of size (nlay + 1, nrow, ncol). The sign is such that the z axis is considered to increase in the upward direction.

Return type:

tuple

get_gradients(heads, m, nodata, per_idx=None)[source]

Calculates the hydraulic gradients from the heads array for each stress period.

Parameters:
  • heads (3 or 4-D np.ndarray) – Heads array.
  • m (flopy.modflow.Modflow object) – Must have a flopy.modflow.ModflowDis object attached.
  • nodata (real) – HDRY value indicating dry cells.
  • per_idx (int or sequence of ints) – stress periods to return. If None, returns all stress periods (default).
Returns:

grad – Array of hydraulic gradients

Return type:

3 or 4-D np.ndarray

get_saturated_thickness(heads, m, nodata, per_idx=None)[source]

Calculates the saturated thickness for each cell from the heads array for each stress period.

Parameters:
  • heads (3 or 4-D np.ndarray) – Heads array.
  • m (flopy.modflow.Modflow object) – Must have a flopy.modflow.ModflowDis object attached.
  • nodata (real) – HDRY value indicating dry cells.
  • per_idx (int or sequence of ints) – stress periods to return. If None, returns all stress periods (default).
Returns:

sat_thickness – Array of saturated thickness

Return type:

3 or 4-D np.ndarray

get_specific_discharge(model, cbcfile, precision='single', idx=None, kstpkper=None, totim=None, boundary_ifaces=None, hdsfile=None, position='centers')[source]

Get the discharge vector at cell centers at a given time. For “classical” MODFLOW versions, we calculate it from the flow rate across cell faces. For MODFLOW 6, we directly take it from MODFLOW output (this requires setting the option “save_specific_discharge” in the NPF package).

Parameters:
  • model (flopy.modflow.Modflow object) – Modflow model instance.
  • cbcfile (str) – Cell by cell file produced by Modflow.
  • precision (str) – Binary file precision, default is ‘single’.
  • idx (int or list) – The zero-based record number.
  • kstpkper (tuple of ints) – A tuple containing the time step and stress period (kstp, kper). The kstp and kper values are zero based.
  • totim (float) – The simulation time.
  • boundary_ifaces (dictionary {str: int or list}) – A dictionary defining how to treat stress flows at boundary cells. Only implemented for “classical” MODFLOW versions where the budget is recorded as FLOW RIGHT FACE, FLOW FRONT FACE and FLOW LOWER FACE arrays. The keys are budget terms corresponding to stress packages (same term as in the overall volumetric budget printed in the listing file). The values are either a single iface number to be applied to all cells for the stress package, or a list of lists describing individual boundary cells in the same way as in the package input plus the iface number appended. The iface number indicates the face to which the stress flow is assigned, following the MODPATH convention (see MODPATH user guide). Example: boundary_ifaces = { ‘RECHARGE’: 6, ‘RIVER LEAKAGE’: 6, ‘WELLS’: [[lay, row, col, flux, iface], …], ‘HEAD DEP BOUNDS’: [[lay, row, col, head, cond, iface], …]}. Note: stresses that are not informed in boundary_ifaces are implicitly treated as internally-distributed sinks/sources.
  • hdsfile (str) – Head file produced by MODFLOW. Head is used to calculate saturated thickness and to determine if a cell is inactive or dry. If not provided, all cells are considered fully saturated. hdsfile is also required if the budget term ‘HEAD DEP BOUNDS’, ‘RIVER LEAKAGE’ or ‘DRAINS’ is present in boundary_ifaces and that the corresponding value is a list.
  • position (str) – Position at which the specific discharge will be calculated. Possible values are “centers” (default), “faces” and “vertices”.
Returns:

(qx, qy, qz) – Discharge vector. qx, qy, qz are ndarrays of size (nlay, nrow, ncol) for a structured grid or size (nlay, ncpl) for an unstructured grid. The sign of qy is such that the y axis is considered to increase in the north direction. The sign of qz is such that the z axis is considered to increase in the upward direction. Note: if hdsfile is provided, inactive and dry cells are set to NaN.

Return type:

tuple

get_transmissivities(heads, m, r=None, c=None, x=None, y=None, sctop=None, scbot=None, nodata=-999)[source]

Computes transmissivity in each model layer at specified locations and open intervals. A saturated thickness is determined for each row, column or x, y location supplied, based on the open interval (sctop, scbot), if supplied, otherwise the layer tops and bottoms and the water table are used.

Parameters:
  • heads (2D array OR 3D array) – numpy array of shape nlay by n locations (2D) OR complete heads array of the model for one time (3D)
  • m (flopy.modflow.Modflow object) – Must have dis, sr, and lpf or upw packages.
  • r (1D array-like of ints, of length n locations) – row indices (optional; alternately specify x, y)
  • c (1D array-like of ints, of length n locations) – column indices (optional; alternately specify x, y)
  • x (1D array-like of floats, of length n locations) – x locations in real world coordinates (optional)
  • y (1D array-like of floats, of length n locations) – y locations in real world coordinates (optional)
  • sctop (1D array-like of floats, of length n locations) – open interval tops (optional; default is model top)
  • scbot (1D array-like of floats, of length n locations) – open interval bottoms (optional; default is model bottom)
  • nodata (numeric) – optional; locations where heads=nodata will be assigned T=0
Returns:

T – Transmissivities in each layer at each location

Return type:

2D array of same shape as heads (nlay x n locations)

get_water_table(heads, nodata, per_idx=None)[source]

Get a 2D array representing the water table elevation for each stress period in heads array.

Parameters:
  • heads (3 or 4-D np.ndarray) – Heads array.
  • nodata (real) – HDRY value indicating dry cells.
  • per_idx (int or sequence of ints) – stress periods to return. If None, returns all stress periods (default is None).
Returns:

wt – for each stress period.

Return type:

2 or 3-D np.ndarray of water table elevations