flopy.discretization.grid module¶
-
class
Grid
(grid_type=None, top=None, botm=None, idomain=None, lenuni=None, epsg=None, proj4=None, prj=None, xoff=0.0, yoff=0.0, angrot=0.0)[source]¶ Bases:
object
Base class for a structured or unstructured model grid
Parameters: - grid_type (enumeration) – type of model grid (‘structured’, ‘vertex’, ‘unstructured’)
- top (ndarray(float)) – top elevations of cells in topmost layer
- botm (ndarray(float)) – bottom elevations of all cells
- idomain (ndarray(int)) – ibound/idomain value for each cell
- lenuni (ndarray(int)) – model length units
- espg (str, int) – optional espg projection code
- proj4 (str) – optional proj4 projection string code
- prj (str) – optional projection file name path
- xoff (float) – x coordinate of the origin point (lower left corner of model grid) in the spatial reference coordinate system
- yoff (float) – y coordinate of the origin point (lower left corner of model grid) in the spatial reference coordinate system
- angrot (float) – rotation angle of model grid, as it is rotated around the origin point
-
grid_type
¶ type of model grid (‘structured’, ‘vertex’, ‘unstructured’)
Type: enumeration
-
top
¶ top elevations of cells in topmost layer
Type: ndarray(float)
-
botm
¶ bottom elevations of all cells
Type: ndarray(float)
-
idomain
¶ ibound/idomain value for each cell
Type: ndarray(int)
-
proj4
¶ spatial reference locates the grid in a coordinate system
Type: proj4 SpatialReference
-
epsg
¶ spatial reference locates the grid in a coordinate system
Type: epsg SpatialReference
-
lenuni
¶ modflow lenuni parameter
Type: int
-
xoffset
¶ x coordinate of the origin point in the spatial reference coordinate system
Type: float
-
yoffset
¶ y coordinate of the origin point in the spatial reference coordinate system
Type: float
-
angrot
¶ rotation angle of model grid, as it is rotated around the origin point
Type: float
-
angrot_radians
¶ rotation angle of model grid, in radians
Type: float
-
xgrid
¶ returns numpy meshgrid of x edges in reference frame defined by point_type
Type: ndarray
-
ygrid
¶ returns numpy meshgrid of y edges in reference frame defined by point_type
Type: ndarray
-
zgrid
¶ returns numpy meshgrid of z edges in reference frame defined by point_type
Type: ndarray
-
xcenters
¶ returns x coordinate of cell centers
Type: ndarray
-
ycenters
¶ returns y coordinate of cell centers
Type: ndarray
-
ycenters
returns z coordinate of cell centers
Type: ndarray
-
xyzgrid
¶ returns the location of grid edges of all model cells. if the model grid contains spatial reference information, the grid edges are in the coordinate system provided by the spatial reference information. returns a list of three ndarrays for the x, y, and z coordinates
Type: [ndarray, ndarray, ndarray]
-
xyzcellcenters
¶ returns the cell centers of all model cells in the model grid. if the model grid contains spatial reference information, the cell centers are in the coordinate system provided by the spatial reference information. otherwise the cell centers are based on a 0,0 location for the upper left corner of the model grid. returns a list of three ndarrays for the x, y, and z coordinates
Type: [ndarray, ndarray, ndarray]
-
get_coords
(x, y)[source]¶ transform point or array of points x, y from model coordinates to spatial coordinates
-
grid_lines : (point_type=PointType.spatialxyz) : list
returns the model grid lines in a list. each line is returned as a list containing two tuples in the format [(x1,y1), (x2,y2)] where x1,y1 and x2,y2 are the endpoints of the line.
-
xyvertices : (point_type) : ndarray
1D array of x and y coordinates of cell vertices for whole grid (single layer) in C-style (row-major) order (same as np.ravel())
Notes
Examples
-
angrot
-
angrot_radians
-
botm
-
cross_section_adjust_indicies
(k, cbcnt)[source]¶ Method to get adjusted indicies by layer and confining bed for PlotCrossSection plotting
Parameters: - k (int) – zero based layer number
- cbcnt (int) – confining bed counter
Returns: - tuple ((int, int, int) (adjusted layer, nodeskip layer, node)
- adjustment value based on number of confining beds and the layer)
-
cross_section_lay_ncpl_ncb
(ncb)[source]¶ Get PlotCrossSection compatible layers, ncpl, and ncb variables
Parameters: ncb (int) – number of confining beds Returns: tuple Return type: (int, int, int) layers, ncpl, ncb
-
cross_section_nodeskip
(nlay, xypts)[source]¶ Get a nodeskip list for PlotCrossSection. This is a correction for UnstructuredGridPlotting
Parameters: - nlay (int) – nlay is nlay + ncb
- xypts (dict) – dictionary of node number and xyvertices of a cross-section
Returns: list
Return type: n-dimensional list of nodes to not plot for each layer
-
cross_section_set_contour_arrays
(plotarray, xcenters, head, elev, projpts)[source]¶ Method to set countour array centers for rare instances where matplotlib contouring is prefered over trimesh plotting
Parameters: - plotarray (np.ndarray) – array of data for contouring
- xcenters (np.ndarray) – xcenters array
- zcenters (np.ndarray) – zcenters array
- head (np.ndarray) – head array to adjust cell centers location
- elev (np.ndarray) – cell elevation array
- projpts (dict) – dictionary of projected cross sectional vertices
Returns: - tuple ((np.ndarray, np.ndarray, np.ndarray, bool))
- plotarray, xcenter array, ycenter array, and a boolean flag
- for contouring
-
cross_section_vertices
¶
-
epsg
-
extent
¶
-
get_coords
(x, y)[source] Given x and y array-like values, apply rotation, scale and offset, to convert them from model coordinates to real-world coordinates.
-
get_local_coords
(x, y)[source]¶ Given x and y array-like values, apply rotation, scale and offset, to convert them from real-world coordinates to model coordinates.
-
get_plottable_layer_shape
(layer=None)[source]¶ Determine the shape that is required in order to plot a 2d array for this grid. For a regular MODFLOW grid, this is (nrow, ncol). For a vertex grid, this is (ncpl,) and for an unstructured grid this is (ncpl[layer],).
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
-
grid_lines
¶
-
grid_type
-
idomain
-
intersect
(x, y, local=False, forgive=False)[source]
-
is_complete
¶
-
is_valid
¶
-
iverts
¶
-
lenuni
-
load_coord_info
(namefile=None, reffile='usgs.model.reference')[source]¶ Attempts to load spatial reference information from the following files (in order): 1) usgs.model.reference 2) NAM file (header comment) 3) defaults
-
map_polygons
¶
-
ncpl
¶
-
nnodes
¶
-
nvert
¶
-
prj
¶
-
proj4
-
read_usgs_model_reference_file
(reffile='usgs.model.reference')[source]¶ read spatial reference info from the usgs.model.reference file https://water.usgs.gov/ogw/policy/gw-model/modelers-setup.html
-
saturated_thick
(array, mask=None)[source]¶ Get the saturated thickness for a structured, vertex, or unstructured grid. If the optional array is passed then thickness is returned relative to array values (saturated thickness). Returned values ranges from zero to cell thickness if optional array is passed.
Parameters: - array (ndarray) – array of elevations that will be used to adjust the cell thickness
- mask (float, list, tuple, ndarray) – array values to replace with a nan value.
Returns: thick
Return type: calculated saturated thickness
-
set_coord_info
(xoff=None, yoff=None, angrot=None, epsg=None, proj4=None, merge_coord_info=True)[source]¶
-
shape
¶
-
thick
¶ Get the cell thickness for a structured, vertex, or unstructured grid.
Returns: thick Return type: calculated thickness
-
top
-
top_botm
¶
-
units
¶
-
verts
¶
-
write_shapefile
(filename='grid.shp', epsg=None, prj=None)[source]¶ Write a shapefile of the grid with just the row and column attributes.
-
xcellcenters
¶
-
xoffset
-
xvertices
¶
-
xyzcellcenters
-
xyzextent
¶
-
xyzvertices
¶
-
ycellcenters
¶
-
yoffset
-
yvertices
¶
-
zcellcenters
¶
-
zvertices
¶