flopy.discretization.unstructuredgrid module

class UnstructuredGrid(vertices=None, iverts=None, xcenters=None, ycenters=None, top=None, botm=None, idomain=None, lenuni=None, ncpl=None, epsg=None, proj4=None, prj=None, xoff=0.0, yoff=0.0, angrot=0.0)[source]

Bases: flopy.discretization.grid.Grid

Class for an unstructured model grid

Parameters:
  • vertices (list) – list of vertices that make up the grid. Each vertex consists of three entries [iv, xv, yv] which are the vertex number, which should be zero-based, and the x and y vertex coordinates.
  • iverts (list) – list of vertex numbers that comprise each cell. This list must be of size nodes, if the grid_varies_by_nodes argument is true, or it must be of size ncpl[0] if the same 2d spatial grid is used for each layer.
  • xcenters (list or ndarray) – list of x center coordinates for all cells in the grid if the grid varies by layer or for all cells in a layer if the same grid is used for all layers
  • ycenters (list or ndarray) – list of y center coordinates for all cells in the grid if the grid varies by layer or for all cells in a layer if the same grid is used for all layers
  • ncpl (ndarray) – one dimensional array of size nlay with the number of cells in each layer. This can also be passed in as a tuple or list as long as it can be set using ncpl = np.array(ncpl, dtype=int). The sum of ncpl must be equal to the number of cells in the grid. ncpl is optional and if it is not passed in, then it is is set using ncpl = np.array([len(iverts)], dtype=int), which means that all cells in the grid are contained in a single plottable layer. If the model grid defined in verts and iverts applies for all model layers, then the length of iverts can be equal to ncpl[0] and there is no need to repeat all of the vertex information for cells in layers beneath the top layer.
  • top (list or ndarray) – top elevations for all cells in the grid.
  • botm (list or ndarray) – bottom elevations for all cells in the grid.
  • Properties
  • ----------
  • vertices – returns list of vertices that make up the grid
  • cell2d – returns list of cells and their vertices
get_cell_vertices(cellid)[source]

returns vertices for a single cell at cellid.

Notes

This class handles spatial representation of unstructured grids. It is based on the concept of being able to support multiple model layers that may have a different number of cells in each layer. The array ncpl is of size nlay and and its sum must equal nodes. If the length of iverts is equal to ncpl[0] and the number of cells per layer is the same for each layer, then it is assumed that the grid does not vary by layer. In this case, the xcenters and ycenters arrays must also be of size ncpl[0]. This makes it possible to efficiently store spatial grid information for multiple layers.

If the spatial grid is different for each model layer, then the grid_varies_by_layer flag will automatically be set to false, and iverts must be of size nodes. The arrays for xcenters and ycenters must also be of size nodes.

extent
classmethod from_argus_export(fname, nlay=1)[source]

Create a new SpatialReferenceUnstructured grid from an Argus One Trimesh file

Parameters:
  • fname (string) – File name
  • nlay (int) – Number of layers to create
Returns:

sru

Return type:

flopy.utils.reference.SpatialReferenceUnstructured

get_cell_vertices(cellid)[source]
Method to get a set of cell vertices for a single cell
used in the Shapefile export utilities
Parameters:cellid – (int) cellid number

Returns ——- list of x,y cell vertices

get_layer_node_range(layer)[source]
get_number_plottable_layers(a)[source]

Calculate and return the number of 2d plottable arrays that can be obtained from the array passed (a)

Parameters:a (ndarray) – array to check for plottable layers
Returns:nplottable – number of plottable layers
Return type:int
get_plottable_layer_array(a, layer)[source]
get_plottable_layer_shape(layer=None)[source]

Determine the shape that is required in order to plot in 2d for this grid.

Parameters:layer (int) – Has no effect unless grid changes by layer
Returns:shape – required shape of array to plot for a layer
Return type:tuple
get_xcellcenters_for_layer(layer)[source]
get_xvertices_for_layer(layer)[source]
get_ycellcenters_for_layer(layer)[source]
get_yvertices_for_layer(layer)[source]
grid_lines

Creates a series of grid line vertices for drawing a model grid line collection. If the grid varies by layer, then return a dictionary with keys equal to layers and values equal to grid lines. Otherwise, just return the grid lines

Returns:grid lines or dictionary of lines by layer
Return type:dict
grid_varies_by_layer
intersect(x, y, local=False, forgive=False)[source]
is_complete
is_valid
ncpl
static ncpl_from_ihc(ihc, iac)[source]

Use the ihc and iac arrays to calculate the number of cells per layer array (ncpl) assuming that the plottable layer number is stored in the diagonal position of the ihc array.

Parameters:
  • ihc (ndarray) – horizontal indicator array. If the plottable layer number is stored in the diagonal position, then this will be used to create the returned ncpl array. plottable layer numbers must increase monotonically and be consecutive with node number
  • iac (ndarray) – array of size nodes that has the number of connections for a cell, plus one for the cell itself
Returns:

ncpl – number of cells per plottable layer

Return type:

ndarray

nlay
nnodes
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
set_ncpl(ncpl)[source]
shape
xyzcellcenters

Method to get cell centers and set to grid

xyzvertices

Method to get model grid verticies

Returns:list of dimension ncpl by nvertices