gsflow.builder.fishnet Module

class gsflow.builder.fishnet.GenerateFishnet(bbox, xcellsize, ycellsize, buffer=None)[source]

Class to build a fishnet model grid

The GenerateFishnet class creates a flopy.discretization.StructuredGrid object from basic geospatial information

Parameters
bboxshapefile, raster, [xmin, xmax, ymin, ymax]

bounding box for modelgrid. The bounding box can be a the extent read from a shapfile, the extent read in from a raster, or a list of [xmin, xmax, ymin, ymax]

xcellsizefloat

cell size in the x direction for fishnet

ycellsizefloat

cell size in the y direction for fishnet

bufferint

number of cells to buffer around the input geometry

Attributes
angrot
angrot_radians
botm
cross_section_vertices

Get a set of xvertices and yvertices ordered by node

delc
delr
delz
epsg
extent
grid_lines

Get the grid lines as a list

grid_type
idomain
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
iverts
laycbd
lenuni
map_polygons

Get a list of matplotlib Polygon patches for plotting

ncol
ncpl
nlay
nnodes
nrow
nvert
prj
proj4
shape
thick

Get the cell thickness for a structured, vertex, or unstructured grid.

top
top_botm
top_botm_withnan

Same as top_botm array but with NaN where idomain==0 both above and below a cell.

units
verts
xcellcenters
xoffset
xvertices
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

Return a list of two 1D numpy arrays: 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.

xyzcellcenters

Return a list of three numpy float arrays: two two-dimensional arrays for center x and y coordinates, and one three-dimensional array for center z coordinates.

xyzextent
xyzvertices

Method to get all grid vertices in a layer

ycellcenters
yoffset
yvertices
zcellcenters
zedges

Return zedges for (column, row)==(0, 0).

zvertices
zverts_smooth

Get a unique z of cell vertices using bilinear interpolation of top and bottom elevation layers.

Methods

array_at_faces(self, a, direction[, withnan])

Computes values at the center of cell faces using linear interpolation.

array_at_verts(self, a)

Interpolate array values at cell vertices.

array_at_verts_basic(self, a)

Computes values at cell vertices using neighbor averaging.

cross_section_adjust_indicies(self, k, cbcnt)

Method to get adjusted indicies by layer and confining bed for PlotCrossSection plotting

cross_section_lay_ncpl_ncb(self, ncb)

Get PlotCrossSection compatible layers, ncpl, and ncb variables

cross_section_nodeskip(self, nlay, xypts)

Get a nodeskip list for PlotCrossSection.

cross_section_set_contour_arrays(self, …)

Method to set countour array centers for rare instances where matplotlib contouring is prefered over trimesh plotting

from_binary_grid_file(file_path[, verbose])

Instantiate a StructuredGrid model grid from a MODFLOW 6 binary grid (*.grb) file.

from_gridspec(gridspec_file[, lenuni])

get_cell_vertices(self, \*args, \*\*kwargs)

Method to get a set of cell vertices for a single cell

get_coords(self, x, y)

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(self, x, y)

Given x and y array-like values, apply rotation, scale and offset, to convert them from real-world coordinates to model coordinates.

get_lrc(self, nodes)

Get layer, row, column from a list of zero based MODFLOW node numbers.

get_node(self, lrc_list)

Get node number from a list of zero based MODFLOW layer, row, column tuples.

get_number_plottable_layers(self, a)

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

get_plottable_layer_shape(self[, layer])

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

intersect(self, x, y[, z, local, forgive])

Get the row and column of a point with coordinates x and y

load_coord_info(self[, namefile, reffile])

Attempts to load spatial reference information from the following files (in order): 1) usgs.model.reference 2) NAM file (header comment) 3) defaults

load_from_file(f)

Method to load a binary modelgrid file

plot(self, \*\*kwargs)

Plot the grid lines.

read_usgs_model_reference_file(self[, reffile])

read spatial reference info from the usgs.model.reference file https://water.usgs.gov/ogw/policy/gw-model/modelers-setup.html

remove_confining_beds(self, array)

Method to remove confining bed layers from an array

saturated_thick(self, array[, mask])

Get the saturated thickness for a structured, vertex, or unstructured grid.

write(self, f)

Method to save a binary copy of the modelgrid for later use

write_shapefile(self[, filename, epsg, prj])

Write a shapefile of the grid with just the row and column attributes.

attribs_from_namfile_header

get_plottable_layer_array

get_xcellcenters_for_layer

get_xvertices_for_layer

get_ycellcenters_for_layer

get_yvertices_for_layer

set_coord_info

array_at_faces(self, a, direction, withnan=True)

Computes values at the center of cell faces using linear interpolation.

Parameters
andarray

Values at cell centers, shape (nlay, row, ncol).

directionstr, possible values are ‘x’, ‘y’ and ‘z’

Direction in which values will be interpolated at cell faces.

withnanbool

If True (default), the result value will be set to NaN where the cell face sits between inactive cells. If False, not.

Returns
afacesndarray

Array values interpolated at cell vertices, shape as input extended by 1 along the specified direction.

array_at_verts(self, a)

Interpolate array values at cell vertices.

Parameters
andarray

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
avertsndarray

Array values interpolated at cell vertices, shape (nlay+1, nrow+1, ncol+1).

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(self, a)

Computes values at cell vertices using neighbor averaging.

Parameters
andarray

Array values at cell centers.

Returns
avertsndarray

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.

cross_section_adjust_indicies(self, k, cbcnt)

Method to get adjusted indicies by layer and confining bed for PlotCrossSection plotting

Parameters
kint

zero based layer number

cbcntint

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(self, ncb)

Get PlotCrossSection compatible layers, ncpl, and ncb variables

Parameters
ncbint

number of confining beds

Returns
tuple(int, int, int) layers, ncpl, ncb
cross_section_nodeskip(self, nlay, xypts)

Get a nodeskip list for PlotCrossSection. This is a correction for UnstructuredGridPlotting

Parameters
nlayint

nlay is nlay + ncb

xyptsdict

dictionary of node number and xyvertices of a cross-section

Returns
listn-dimensional list of nodes to not plot for each layer
cross_section_set_contour_arrays(self, plotarray, xcenters, head, elev, projpts)

Method to set countour array centers for rare instances where matplotlib contouring is prefered over trimesh plotting

Parameters
plotarraynp.ndarray

array of data for contouring

xcentersnp.ndarray

xcenters array

zcentersnp.ndarray

zcenters array

headnp.ndarray

head array to adjust cell centers location

elevnp.ndarray

cell elevation array

projptsdict

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

Get a set of xvertices and yvertices ordered by node for plotting cross sections

Returns
xverts, yverts: (np.ndarray, np.ndarray)
classmethod from_binary_grid_file(file_path, verbose=False)

Instantiate a StructuredGrid model grid from a MODFLOW 6 binary grid (*.grb) file.

Parameters
file_pathstr

file path for the MODFLOW 6 binary grid file

verbosebool

Write information to standard output. Default is False.

Returns
returnStructuredGrid
get_cell_vertices(self, *args, **kwargs)
Method to get a set of cell vertices for a single cell

used in the Shapefile export utilities and plotting code

Parameters
  • node – (int) node number

  • i – (int) cell row number

  • j – (int) cell column number

Returns ——- list of x,y cell vertices

get_coords(self, x, y)

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(self, x, y)

Given x and y array-like values, apply rotation, scale and offset, to convert them from real-world coordinates to model coordinates.

get_lrc(self, nodes)

Get layer, row, column from a list of zero based MODFLOW node numbers.

Returns
vlist of tuples containing the layer (k), row (i),

and column (j) for each node in the input list

get_node(self, lrc_list)

Get node number from a list of zero based MODFLOW layer, row, column tuples.

Returns
vlist of MODFLOW nodes for each layer (k), row (i),

and column (j) tuple in the input list

get_number_plottable_layers(self, a)

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

Parameters
andarray

array to check for plottable layers

Returns
nplottableint

number of plottable layers

get_plottable_layer_shape(self, layer=None)

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
layerint

Has no effect unless grid changes by layer

Returns
shapetuple

required shape of array to plot for a layer

property grid_lines

Get the grid lines as a list

intersect(self, x, y, z=None, local=False, forgive=False)

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
xfloat

The x-coordinate of the requested point

yfloat

The y-coordinate of the requested point

zfloat

Optional z-coordinate of the requested point (will return layer, row, column) if supplied

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
rowint

The row number

colint

The column number

property 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).

property is_regular

Test if the grid spacing is regular and equal in x, y and z directions.

property is_regular_x

Test whether the grid spacing is regular in the x direction.

property is_regular_xy

Test if the grid spacing is regular and equal in x and y directions.

property is_regular_xz

Test if the grid spacing is regular and equal in x and z directions.

property is_regular_y

Test whether the grid spacing is regular in the y direction.

property is_regular_yz

Test if the grid spacing is regular and equal in y and z directions.

property is_regular_z

Test if the grid spacing is regular in z direction.

load_coord_info(self, namefile=None, reffile='usgs.model.reference')

Attempts to load spatial reference information from the following files (in order): 1) usgs.model.reference 2) NAM file (header comment) 3) defaults

static load_from_file(f)[source]

Method to load a binary modelgrid file

Parameters
fstr

binary modelgrid file name

Returns
GenerateFishnet object
property map_polygons

Get a list of matplotlib Polygon patches for plotting

Returns
list of Polygon objects
plot(self, **kwargs)

Plot the grid lines.

Parameters
kwargsax, colors. The remaining kwargs are passed into the

the LineCollection constructor.

Returns
lcmatplotlib.collections.LineCollection
read_usgs_model_reference_file(self, reffile='usgs.model.reference')

read spatial reference info from the usgs.model.reference file https://water.usgs.gov/ogw/policy/gw-model/modelers-setup.html

remove_confining_beds(self, array)

Method to remove confining bed layers from an array

Parameters
arraynp.ndarray

array to remove quasi3d confining bed data from. Shape of axis 0 should be (self.lay + ncb) to remove beds

Returns
——-

np.ndarray

saturated_thick(self, array, mask=None)

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
arrayndarray

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
thickcalculated saturated thickness
property thick

Get the cell thickness for a structured, vertex, or unstructured grid.

Returns
thickcalculated thickness
property top_botm_withnan

Same as top_botm array but with NaN where idomain==0 both above and below a cell.

write(self, f)[source]

Method to save a binary copy of the modelgrid for later use

Parameters
fstr

filename

Returns
None
write_shapefile(self, filename='grid.shp', epsg=None, prj=None)

Write a shapefile of the grid with just the row and column attributes.

property xycenters

Return a list of two numpy one-dimensional float arrays for center x and y coordinates in model space - not offset or rotated.

property xyedges

Return a list of two 1D numpy arrays: 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.

property xyzcellcenters

Return a list of three numpy float arrays: 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.

property xyzvertices

Method to get all grid vertices in a layer

Returns:

[] 2D array

property zedges

Return zedges for (column, row)==(0, 0).

property zverts_smooth

Get a unique z of cell vertices using bilinear interpolation of top and bottom elevation layers.

Returns
zvertsndarray, shape (nlay+1, nrow+1, ncol+1)

z of cell vertices. NaN values are assigned in accordance with inactive cells defined by idomain.