flopy.mf6.utils.binarygrid_util module
Module to read MODFLOW 6 binary grid files (*.grb) that define the model grid binary output files. The module contains the MfGrdFile class that can be accessed by the user.
- class MfGrdFile(filename, precision='double', verbose=False)[source]
Bases:
FlopyBinaryDataThe MfGrdFile class.
- Parameters:
Notes
The MfGrdFile class provides simple ways to retrieve data from binary MODFLOW 6 binary grid files (.grb). The binary grid file contains data that can be used for post processing MODFLOW 6 model results. For example, the ia and ja arrays for a model grid.
Examples
>>> import flopy >>> gobj = flopy.utils.MfGrdFile('test.dis.grb')
- property angrot
Model grid rotation angle. None if not defined in the MODFLOW 6 grid file.
- Returns:
angrot
- Return type:
- property bot
Bottom of the model cells.
- Returns:
bot
- Return type:
ndarray of floats
- property cell2d
cell2d data for a DISV grid. None for DIS and DISU grids.
- Returns:
cell2d
- Return type:
list of lists
- property cellcenters
Cell centers (x,y).
- Returns:
cellcenters
- Return type:
ndarray of floats
- property crs
CRS user input string (version 2 GRB file only).
- Returns:
crs
- Return type:
str or None
- property delc
Cell size in the column direction (x-direction). None if not defined in the MODFLOW 6 grid file.
- Returns:
delc
- Return type:
ndarray of floats
- property delr
Cell size in the row direction (y-direction). None if not defined in the MODFLOW 6 grid file.
- Returns:
delr
- Return type:
ndarray of floats
- export(filename, *, precision=None, version=None, crs=None, verbose=False)[source]
Export the binary grid file to a new file.
- Parameters:
filename (str or PathLike) – Path to output .grb file
precision (str, optional) – ‘single’ or ‘double’. If None, uses the precision from the original file (default None)
version (int, optional) – Grid file version to write. If None (default), version 2 is written when a CRS string is available, otherwise version 1. Pass
version=1to force version 1 even when a CRS is set.crs (str, optional) – CRS user input string to write (e.g.
"EPSG:26916"or OGC WKT). If None, uses the CRS from the source file if present. Providing this argument with a version 1 source file upgrades the output to version 2.verbose (bool, optional) – Print progress messages (default False)
keyword-only (All parameters except filename are) –
a (so adding) –
and (new parameter here in the future (e.g. a dedicated parameter) –
field (property for a new GRB) –
can (mirroring crs/.crs)) –
call. (never silently change the meaning of an existing positional) –
Examples
>>> from flopy.mf6.utils import MfGrdFile >>> grb = MfGrdFile('model.dis.grb') >>> grb.export('model_copy.dis.grb') >>> # Round-trip a v2 file preserving CRS >>> grb2 = MfGrdFile('model_v2.dis.grb') >>> grb2.export('model_v2_copy.dis.grb') >>> # Upgrade a v1 file to v2 with an explicit CRS >>> grb.export('model_v2.dis.grb', crs='EPSG:26916')
- property grid_type
Grid type defined in the MODFLOW 6 grid file.
- Returns:
grid_type
- Return type:
- property ia
index array that defines indexes for .ja. Each ia value is the starting position of data for a cell. [ia[n]:ia[n+1]] would give you all data for a cell. ia[n] is also the location of data for the diagonal position. See .ja property documentation for an example of getting a cell’s number and connected cells
- Returns:
ia
- Return type:
ndarray of ints
- property iavert
index array that defines indexes for .javart. Each ia value is the starting position of data for a cell. [iavert[n]:iavert[n+1]] would give you all data for a cell. See .javert property documentation for an example of getting cell number and it’s vertex numbers. Alternatively, the .iverts property can be used to get this information
- Returns:
iavert
- Return type:
ndarray of ints or None for structured grids
- property idomain
IDOMAIN for the model grid. None if not defined in the MODFLOW 6 grid file.
- Returns:
idomain
- Return type:
ndarray of ints
- property iverts
Vertex numbers comprising each cell for every cell in model grid.
- Returns:
iverts
- Return type:
list of lists of ints
- property ja
Flat jagged connection array for a model. .ja for a cell includes the cell number and the cell number for all connected cells. Indexes for cells are stored in the .ia variable.
- Returns:
ja
- Return type:
ndarray of ints
Examples
>>> from flopy.mf6.utils import MfGrdFile >>> grb = MfGrdFile("my_model.dis.grb") >>> ia = grb.ia >>> ja = grb.ja >>> # get connections for node 0 >>> ja_node0 = ja[ia[0]:ia[1]] >>> node = ja_node0[0] >>> connections = ja_node0[1:]
- property javert
Flat jagged array of vertex numbers that comprise all of the cells
- Returns:
javerts
- Return type:
ndarray of ints or None for structured grids
Examples
>>> from flopy.mf6.utils import MfGrdFile >>> grb = MfGrdFile("my_model.dis.grb") >>> iavert = self.iavert >>> javert = self.javert >>> # get vertex numbers for node 0 >>> vertnums = javert[iavert[0]:iavert[1]]
- property modelgrid
Model grid object.
- Returns:
modelgrid
- Return type:
- property top
Top of the model cells in the upper model layer for DIS and DISV grids. Top of the model cells for DISU grids.
- Returns:
top
- Return type:
ndarray of floats
- property verts
x,y location of each vertex that defines the model grid.
- Returns:
verts
- Return type:
ndarray of floats
- property xorigin
x-origin of the model grid. None if not defined in the MODFLOW 6 grid file.
- Returns:
xorigin
- Return type: