flopy.discretization.grid module
- class Grid(grid_type=None, top=None, botm=None, idomain=None, lenuni=None, crs=None, prjfile=None, xoff=0.0, yoff=0.0, angrot=0.0, **kwargs)[source]
Bases:
object
Base class for a structured or unstructured model grid
- Parameters:
grid_type (enumeration) – type of model grid (‘structured’, ‘vertex’, ‘unstructured’)
top (float or ndarray) – top elevations of cells in topmost layer
botm (float or ndarray) – bottom elevations of all cells
idomain (int or ndarray) – ibound/idomain value for each cell
lenuni (int or ndarray) – model length units
crs (pyproj.CRS, int, str, optional if prjfile is specified) – Coordinate reference system (CRS) for the model grid (must be projected; geographic CRS are not supported). The value can be anything accepted by
pyproj.CRS.from_user_input()
, such as an authority string (eg “EPSG:26916”) or a WKT string.prjfile (str or pathlike, optional if crs is specified) – ESRI-style projection file with well-known text defining the CRS for the model grid (must be projected; geographic CRS are not supported).
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
**kwargs (dict, optional) –
Support deprecated keyword options.
Deprecated since version 3.5: The following keyword options will be removed for FloPy 3.6:
prj
(str or pathlike): useprjfile
instead.epsg
(int): usecrs
instead.proj4
(str): usecrs
instead.
- grid_type
type of model grid (‘structured’, ‘vertex’, ‘unstructured’)
- Type:
enumeration
- 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
- 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.
Notes
Examples
- property angrot
- property angrot_radians
- property botm
- property cell_thickness
Get the cell thickness for a structured, vertex, or unstructured grid.
- Returns:
thick
- Return type:
calculated thickness
- convert_grid(factor)[source]
Method to scale the model grid based on user supplied scale factors
- Parameters:
factor –
- Return type:
Grid object
- cross_section_adjust_indicies(k, cbcnt)[source]
Method to get adjusted indices by layer and confining bed for PlotCrossSection plotting
- cross_section_lay_ncpl_ncb(ncb)[source]
Get PlotCrossSection compatible layers, ncpl, and ncb variables
- cross_section_nodeskip(nlay, xypts)[source]
Get a nodeskip list for PlotCrossSection. This is a correction for UnstructuredGridPlotting
- cross_section_set_contour_arrays(plotarray, xcenters, head, elev, projpts)[source]
Method to set contour array centers for rare instances where matplotlib contouring is preferred 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
- property cross_section_vertices
- property crs
Coordinate reference system (CRS) for the model grid.
If pyproj is not installed this property is always None; see
epsg
for an alternative CRS definition.
- property epsg
EPSG integer code registered to a coordinate reference system.
This property is derived from
crs
if pyproj is installed, otherwise it preserved from the constructor.
- property extent
- geo_dataframe(polys)[source]
Method returns a geopandas GeoDataFrame of the Grid
- Return type:
GeoDataFrame
- 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_lni(nodes)[source]
Get the layer index and within-layer node index (both 0-based) for the given nodes
- Parameters:
nodes (node numbers (array-like)) –
- Return type:
list of tuples (layer index, node index)
- 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],).
- property grid_lines
- property grid_type
- property idomain
- property is_complete
- property is_valid
- property iverts
- property laycbd
- property 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
- property map_polygons
- property ncpl
- property nlay
- property nnodes
- property nvert
- property prj
- property prjfile
Path to a .prj file containing WKT for a coordinate reference system.
- property proj4
PROJ string for a coordinate reference system.
This property is derived from
crs
if pyproj is installed, otherwise it preserved from the constructor.
- 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
- remove_confining_beds(array)[source]
Method to remove confining bed layers from an array
- Parameters:
array (np.ndarray) – array to remove quasi3d confining bed data from. Shape of axis 0 should be (self.lay + ncb) to remove beds
- Return type:
np.ndarray
- saturated_thick(array, mask=None)[source]
Raises AttributeError, use
saturated_thickness()
.
- saturated_thickness(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.
- set_coord_info(xoff=None, yoff=None, angrot=None, crs=None, prjfile=None, merge_coord_info=True, **kwargs)[source]
Set coordinate information for a grid.
- Parameters:
xoff (float, optional) – X and Y coordinate of the origin point in the spatial reference coordinate system.
yoff (float, optional) – X and Y coordinate of the origin point in the spatial reference coordinate system.
angrot (float, optional) – Rotation angle of model grid, as it is rotated around the origin point.
crs (pyproj.CRS, int, str, optional) – Coordinate reference system (CRS) for the model grid (must be projected; geographic CRS are not supported). The value can be anything accepted by
pyproj.CRS.from_user_input()
, such as an authority string (eg “EPSG:26916”) or a WKT string.prjfile (str or pathlike, optional) – ESRI-style projection file with well-known text defining the CRS for the model grid (must be projected; geographic CRS are not supported).
merge_coord_info (bool, default True) – If True, retaining previous properties. If False, overwrite properties with defaults, unless specified.
**kwargs (dict, optional) –
Support deprecated keyword options.
Deprecated since version 3.5: The following keyword options will be removed for FloPy 3.6:
epsg
(int): usecrs
instead.proj4
(str): usecrs
instead.
- property shape
- property size
- property thick
Raises AttributeError, use
cell_thickness()
.
- property top
- property top_botm
- property units
- property verts
- write_shapefile(filename='grid.shp', crs=None, prjfile=None, **kwargs)[source]
Write a shapefile of the grid with just the row and column attributes.
- property xcellcenters
- property xoffset
- property xvertices
- property xyzcellcenters
- property xyzextent
- property xyzvertices
- property ycellcenters
- property yoffset
- property yvertices
- property zcellcenters
- property zvertices