flopy.utils.lgrutil module
- class Lgr(nlayp, nrowp, ncolp, delrp, delcp, topp, botmp, refine_mask=None, ncpp=3, ncppl=1, xllp=0.0, yllp=0.0, *, idomainp=None)[source]
Bases:
object- property child
Return a SimpleRegularGrid object for the child model
- Returns:
simple_regular_grid – simple grid object containing grid information for the child
- Return type:
- classmethod from_parent_grid(parent_grid, refine_mask, ncpp=3, ncppl=1)[source]
Create an Lgr instance from a parent StructuredGrid.
- Parameters:
parent_grid (StructuredGrid) – The parent grid
refine_mask (ndarray) –
Array indicating which parent cells to refine (shape: nlay, nrow, ncol). Cells with value 0 will be refined, with value 1 remain as parent cells.
When a parent cell is marked to be refined, it will be deactivated in the parent model using idomain functionality. Refined parent cells will correspond to active cells in the child model.
The child grid spans a rectangular bounding box around the cells marked for refinement in the parent. If the refinement region is not regularly shaped (non-rectangular), some child cells will be marked inactive such that no region is active in both the parent and child grid. In general, child cells are active (1) in refined parent cells (refine_mask=0) and inactive (0) where coinciding with active parent cells (refine_mask=1).
ncpp (int) – Number of child cells per parent cell face (default 3)
ncppl (int or list of ints) – Number of child layers per parent layer (default 1)
- Returns:
Local grid refinement instance
- Return type:
Examples
>>> # Create refinement mask - refine center 3x3 cells >>> refine_mask = np.ones((nlay, nrow, ncol)) >>> refine_mask[:, 2:5, 2:5] = 0 >>> lgr = Lgr.from_parent_grid(parent_grid, refine_mask, ncpp=3)
- get_exchange_data(angldegx=False, cdist=False)[source]
Get the list of parent/child connections
<cellidm1> <cellidm2> <ihc> <cl1> <cl2> <hwva> <angledegx>
- Returns:
exglist – list of connections between parent and child
- Return type:
- get_idomain()[source]
Return the idomain array for the child model.
The child grid spans a rectangular bounding box around the cells marked for refinement in the parent. If the refinement region is not regularly shaped (non-rectangular), some child cells will be marked inactive such that no region is active in both the parent and child grid. In general, child cells are active (1) in refined parent cells (refine_mask=0) and inactive (0) where coinciding with active parent cells (refine_mask=1).
- Returns:
idomain – Child idomain array (shape: nlay, nrow, ncol)
- Return type:
ndarray
- get_lower_left()[source]
Return the lower left corner of the child grid
- Returns:
(xll, yll) – location of lower left corner of the child grid
- Return type:
- get_parent_connections(kc, ic, jc)[source]
Return a list of parent cell indices that are connected to child cell kc, ic, jc.
- get_parent_indices(kc, ic, jc)[source]
Method returns the parent cell indices for this child. The returned indices are in zero-based indexing.
- get_replicated_parent_array(parent_array)[source]
Get a two-dimensional array the size of the child grid that has values replicated from the provided parent array.
- Parameters:
parent_array (ndarray) – A two-dimensional array that is the size of the parent model rows and columns.
- Returns:
child_array – A two-dimensional array that is the size of the child model rows and columns
- Return type:
ndarray
- get_shape()[source]
Return the shape of the child grid
- Returns:
(nlay, nrow, ncol) – shape of the child grid
- Return type:
- property idomain
Deprecated since version 3.9.
The idomain attribute is deprecated. Use refine_mask instead. Will be removed in version 3.10.
- property parent
Return a SimpleRegularGrid object for the parent model
- Returns:
simple_regular_grid – simple grid object containing grid information for the parent
- Return type:
- to_disv_gridprops()[source]
Create and return a gridprops dictionary that can be used to create a disv grid (instead of a separate parent and child representation). The gridprops dictionary can be unpacked into the flopy.mf6.Modflowdisv() constructor and flopy.discretization.VertexGrid() constructor.
Note that export capability will only work if the parent and child models have corresponding layers.
- Returns:
gridprops – Dictionary containing ncpl, nvert, vertices, cell2d, nlay, top, and botm
- Return type:
- class LgrToDisv(lgr)[source]
Bases:
object- build_verts_iverts()[source]
Build the verts and iverts members. self.verts is a 2d numpy array of size (nvert, 2). Column 1 is x and column 2 is y. self.iverts is a list of size ncpl (number of cells per layer) with each entry being the list of vertex indices that define the cell.
- find_hanging_vertices()[source]
Hanging vertices are vertices that must be included along the edge of parent cells. These hanging vertices mark the locations of corners of adjacent child cells. Hanging vertices are not strictly necessary to define the shape of a parent cell, but they are required by modflow to describe connections between parent and child cells.
This routine finds hanging vertices parent cells along a parent-child boundary. These hanging vertices are stored in 4 member dictionaries, called right_face_hanging, left_face_hanging, front_face_hanging, and back_face_hanging. These dictionaries are used subsequently to insert hanging vertices into the iverts array.
- get_botm()[source]
Construct a 2d array of size (nlay, ncpl) that contains the cell bottoms.
- Returns:
botm – 2d array of bottom elevations
- Return type:
ndarray
- get_disv_gridprops()[source]
Create and return a gridprops dictionary that can be used to create a disv grid (instead of a separate parent and child representation). The gridprops dictionary can be unpacked into the flopy.mf6.Modflowdisv() constructor and flopy.discretization.VertexGrid() constructor.
Note that export capability will only work if the parent and child models have corresponding layers.
- Returns:
gridprops – Dictionary containing ncpl, nvert, vertices, cell2d, nlay, top, and botm
- Return type:
- get_top()[source]
Construct a 1d array of size (ncpl) that contains the cell tops.
- Returns:
top – 1d array of top elevations
- Return type:
ndarray
- get_xcyc()[source]
Construct a 2d array of size (nvert, 2) that contains the cell centers.
- Returns:
xcyc – 2d array of x, y positions for cell centers
- Return type:
ndarray
- merge_hanging_vertices(ip, jp, ivlist)[source]
Given a list of vertices (ivlist) for parent row and column (ip, jp) merge hanging vertices from adjacent child cells into ivlist.
- Parameters:
- Returns:
ivlist – modified list of vertices that now also contains any hanging vertices needed to properly define a parent cell adjacent to child cells
- Return type:
list of ints
- class SimpleRegularGrid(nlay, nrow, ncol, delr, delc, top, botm, idomain, xorigin, yorigin)[source]
Bases:
StructuredGridDeprecated: Use StructuredGrid instead.
Deprecated since version 3.9: SimpleRegularGrid is deprecated and will be removed in version 3.10. Use
flopy.discretization.StructuredGridinstead.Simple object for representing regular MODFLOW grid information.
- Parameters:
nlay (int) – number of layers
nrow (int) – number of rows
ncol (int) – number of columns
delr (ndarray) – delr array
delc (ndarray) – delc array
top (ndarray) – top array (nrow, ncol)
botm (ndarray) – botm array (nlay, nrow, ncol)
idomain (ndarray) – idomain array (nlay, nrow, ncol)
xorigin (float) – x location of grid lower left corner
yorigin (float) – y location of grid lower left corner
- get_gridprops_dis6()[source]
Get grid properties for MODFLOW 6 DIS package.
Deprecated since version 3.9: get_gridprops_dis6 is deprecated and will be removed in version 3.10.
- Returns:
Dictionary of grid properties
- Return type:
- property modelgrid
SimpleRegularGrid now inherits from StructuredGrid.
Deprecated since version 3.9: The modelgrid property is deprecated. SimpleRegularGrid now inherits from StructuredGrid, so you can use the instance directly.
- Returns:
Returns self (which is a StructuredGrid instance)
- Return type:
- Type:
Deprecated