flopy.discretization.grid module
- class Grid(grid_type=None, top=None, botm=None, idomain=None, lenuni=None, crs=None, epsg=None, proj4=None, prj=None, prjfile=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 (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, 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 
 
 - grid_type
- type of model grid (‘structured’, ‘vertex’, ‘unstructured’) - Type:
- enumeration 
 
 - crs
- Coordinate reference system (CRS) for the model grid - Type:
- pyproj.CRS 
 
 - 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 - 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 
 
 - cross_section_adjust_indicies(k, cbcnt)[source]
- Method to get adjusted indicies 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 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 
 
 
 - property cross_section_vertices
 - property crs
 - property epsg
 - property 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_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
 - property 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 
 - 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]
- DEPRECATED method. saturated_thick will be removed in version 3.3.9 - 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. 
 - 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, epsg=None, proj4=None, merge_coord_info=True)[source]
 - property shape
 - property size
 - property thick
- DEPRECATED method. thick will be removed in version 3.3.9 - Get the cell thickness for a structured, vertex, or unstructured grid. - Returns:
- thick 
- Return type:
- calculated thickness 
 
 - property top
 - property top_botm
 - property units
 - property verts
 - write_shapefile(filename='grid.shp', epsg=None, prj=None)[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