flopy.discretization.structuredgrid module¶
-
class
StructuredGrid
(delc=None, delr=None, top=None, botm=None, idomain=None, lenuni=None, epsg=None, proj4=None, prj=None, xoff=0.0, yoff=0.0, angrot=0.0, nlay=None, nrow=None, ncol=None, laycbd=None)[source]¶ Bases:
flopy.discretization.grid.Grid
class for a structured model grid
Parameters: - delc – delc array
- delr – delr array
- Properties –
- ---------- –
- nlay – returns the number of model layers
- nrow – returns the number of model rows
- ncol – returns the number of model columns
- delc – returns the delc array
- delr – returns the delr array
- xyedges – returns x-location points for the edges of the model grid and y-location points for the edges of the model grid
-
array_at_faces
(a, direction, withnan=True)[source]¶ Computes values at the center of cell faces using linear interpolation.
Parameters: - a (ndarray) – Values at cell centers, shape (nlay, row, ncol).
- direction (str, possible values are 'x', 'y' and 'z') – Direction in which values will be interpolated at cell faces.
- withnan (bool) – If True (default), the result value will be set to NaN where the cell face sits between inactive cells. If False, not.
Returns: afaces – Array values interpolated at cell vertices, shape as input extended by 1 along the specified direction.
Return type: ndarray
-
array_at_verts
(a)[source]¶ Interpolate array values at cell vertices.
Parameters: a (ndarray) – Array values. Allowed shapes are: (nlay, nrow, ncol), (nlay, nrow, ncol+1), (nlay, nrow+1, ncol) and (nlay+1, nrow, ncol). * When the shape is (nlay, nrow, ncol), input values are considered at cell centers, and output values are computed by trilinear interpolation. * When the shape is extended in one direction, input values are considered at the center of cell faces in this direction, and output values are computed by bilinear interpolation in planes defined by these cell faces. Returns: averts – Array values interpolated at cell vertices, shape (nlay+1, nrow+1, ncol+1). Return type: ndarray Notes
- Output values are smooth (continuous) even if top elevations or
bottom elevations are not constant across layers (i.e., in this case, vertices of neighboring cells are implicitly merged). * NaN values are assigned in accordance with inactive cells defined by idomain.
-
array_at_verts_basic
(a)[source]¶ Computes values at cell vertices using neighbor averaging.
Parameters: a (ndarray) – Array values at cell centers. Returns: averts – Array values at cell vertices, shape (a.shape[0]+1, a.shape[1]+1, a.shape[2]+1). NaN values are assigned in accordance with inactive cells defined by idomain. Return type: ndarray
-
delc
¶
-
delr
¶
-
delz
¶
-
extent
¶
-
get_cell_vertices
(i, j)[source] - Method to get a set of cell vertices for a single cell
- used in the Shapefile export utilities
Parameters: - i – (int) cell row number
- j – (int) cell column number
Returns ——- list of x,y cell vertices
-
grid_lines
¶ Get the grid lines as a list
-
intersect
(x, y, local=False, forgive=False)[source]¶ Get the row and column of a point with coordinates x and y
When the point is on the edge of two cells, the cell with the lowest row or column is returned.
Parameters: - x (float) – The x-coordinate of the requested point
- y (float) – The y-coordinate of the requested point
- local (bool (optional)) – If True, x and y are in local coordinates (defaults to False)
- forgive (bool (optional)) – Forgive x,y arguments that fall outside the model grid and return NaNs instead (defaults to False - will throw exception)
Returns: - row (int) – The row number
- col (int) – The column number
-
is_complete
¶
-
is_rectilinear
¶ Test whether the grid is rectilinear (it is always so in the x and y directions, but not necessarily in the z direction).
-
is_regular
¶ Test if the grid spacing is regular and equal in x, y and z directions.
-
is_regular_x
¶ Test whether the grid spacing is regular in the x direction.
-
is_regular_xy
¶ Test if the grid spacing is regular and equal in x and y directions.
-
is_regular_xz
¶ Test if the grid spacing is regular and equal in x and z directions.
-
is_regular_y
¶ Test whether the grid spacing is regular in the y direction.
-
is_regular_yz
¶ Test if the grid spacing is regular and equal in y and z directions.
-
is_regular_z
¶ Test if the grid spacing is regular in z direction.
-
is_valid
¶
-
ncol
¶
-
nlay
¶
-
nnodes
¶
-
nrow
¶
-
plot
(**kwargs)[source]¶ Plot the grid lines.
Parameters: kwargs (ax, colors. The remaining kwargs are passed into the) – the LineCollection constructor. Returns: lc Return type: matplotlib.collections.LineCollection
-
shape
¶
-
top_botm_withnan
¶ Same as top_botm array but with NaN where idomain==0 both above and below a cell.
-
write_shapefile
(filename='grid.shp', epsg=None, prj=None)[source]¶ Write a shapefile of the grid with just the row and column attributes.
-
xycenters
¶ Return a list of two numpy one-dimensional float arrays for center x and y coordinates in model space - not offset or rotated.
-
xyedges
¶ one with the cell edge x coordinate (size = ncol+1) and the other with the cell edge y coordinate (size = nrow+1) in model space - not offset or rotated.
Type: Return a list of two 1D numpy arrays
-
xyzcellcenters
¶ two two-dimensional arrays for center x and y coordinates, and one three-dimensional array for center z coordinates. Coordinates are given in real-world coordinates.
Type: Return a list of three numpy float arrays
-
xyzvertices
¶ Method to get all grid vertices in a layer
Returns: [] 2D array
-
zedges
¶ Return zedges for (column, row)==(0, 0).
-
zverts_smooth
¶ Get a unique z of cell vertices using bilinear interpolation of top and bottom elevation layers.
Returns: zverts – z of cell vertices. NaN values are assigned in accordance with inactive cells defined by idomain. Return type: ndarray, shape (nlay+1, nrow+1, ncol+1)
-
array_at_faces_1d
(a, delta)[source]¶ Interpolate array at cell faces of a 1d grid using linear interpolation.
Parameters: - a (1d ndarray) – Values at cell centers.
- delta (1d ndarray) – Grid steps.
Returns: afaces – Array values interpolated at cell faces, shape as input extended by 1.
Return type: 1d ndarray
-
array_at_verts_basic2d
(a)[source]¶ Computes values at cell vertices on 2d array using neighbor averaging.
Parameters: a (ndarray) – Array values at cell centers, could be a slice in any orientation. Returns: averts – Array values at cell vertices, shape (a.shape[0]+1, a.shape[1]+1). Return type: ndarray