flopy.mf6.utils.reference module
Module spatial referencing for flopy model objects
- class SpatialReference(delr=1.0, delc=1.0, xvdict=None, yvdict=None, lenuni=1, nlay=1, xul=None, yul=None, xadj=0.0, yadj=0.0, rotation=0.0, proj4_str=None, distype='structured')[source]
Bases:
object
A dynamic inheritance class that locates a gridded model in space
- delrnumpy ndarray
the model discretization delr vector
- delcnumpy ndarray
the model discretization delc vector
- lenuniint
the length units flag from the discretization package
- xulfloat
the x coordinate of the upper left corner of the grid
- yulfloat
the y coordinate of the upper left corner of the grid
- rotationfloat
the counter-clockwise rotation (in degrees) of the grid
- proj4_str: str
a PROJ4 string that identifies the grid in space. warning: case sensitive!
- xadjfloat
vertex grid: x vertex adjustment factor
- yadjfloat
vertex grid: y vertex adjustment factor
- xvdict: dict
dictionary of x-vertices by cellnum ex. {0: (0,1,1,0)}
- yvdict: dict
dictionary of y-vertices by cellnum ex. {0: (1,1,0,0)}
- distype: str
model grid discretization type
- class StructuredSpatialReference(delr=1.0, delc=1.0, lenuni=1, nlay=1, xul=None, yul=None, rotation=0.0, proj4_str=None, **kwargs)[source]
Bases:
object
a simple class to locate the model grid in x-y space
- Parameters:
delr (numpy ndarray) – the model discretization delr vector
delc (numpy ndarray) – the model discretization delc vector
lenuni (int) – the length units flag from the discretization package
xul (float) – the x coordinate of the upper left corner of the grid
yul (float) – the y coordinate of the upper left corner of the grid
rotation (float) – the counter-clockwise rotation (in degrees) of the grid
proj4_str (str) – a PROJ4 string that identifies the grid in space. warning: case sensitive!
- xedge
array of column edges
- Type:
ndarray
- yedge
array of row edges
- Type:
ndarray
- xgrid
numpy meshgrid of xedges
- Type:
ndarray
- ygrid
numpy meshgrid of yedges
- Type:
ndarray
- xcenter
array of column centers
- Type:
ndarray
- ycenter
array of row centers
- Type:
ndarray
- xcentergrid
numpy meshgrid of column centers
- Type:
ndarray
- ycentergrid
numpy meshgrid of row centers
- Type:
ndarray
Notes
xul and yul can be explicitly (re)set after SpatialReference instantiation, but only before any of the other attributes and methods are accessed
- property attribute_dict
- get_xcenter_array()[source]
Return a numpy one-dimensional float array that has the cell center x coordinate for every column in the grid in model space - not offset or rotated.
- get_xedge_array()[source]
Return a numpy one-dimensional float array that has the cell edge x coordinates for every column in the grid in model space - not offset or rotated. Array is of size (ncol + 1)
- get_ycenter_array()[source]
Return a numpy one-dimensional float array that has the cell center x coordinate for every row in the grid in model space - not offset of rotated.
- get_yedge_array()[source]
Return a numpy one-dimensional float array that has the cell edge y coordinates for every row in the grid in model space - not offset or rotated. Array is of size (nrow + 1)
- interpolate(a, xi, method='nearest')[source]
Use the griddata method to interpolate values from an array onto the points defined in xi. For any values outside of the grid, use ‘nearest’ to find a value for them.
- Parameters:
a (numpy.ndarray) – array to interpolate from. It must be of size nrow, ncol
xi (numpy.ndarray) – array containing x and y point coordinates of size (npts, 2). xi also works with broadcasting so that if a is a 2d array, then xi can be passed in as (xgrid, ygrid).
method ({'linear', 'nearest', 'cubic'}) – method to use for interpolation (default is ‘nearest’)
- Returns:
b – array of size (npts)
- Return type:
- property ncol
- property nrow
- static rotate(x, y, theta, xorigin=0.0, yorigin=0.0)[source]
Given x and y array-like values calculate the rotation about an arbitrary origin and then return the rotated coordinates. theta is in degrees.
- set_spatialreference(xul=None, yul=None, rotation=0.0)[source]
set spatial reference - can be called from model instance
- property xcenter
- property xcentergrid
- property xedge
- property xgrid
- property ycenter
- property ycentergrid
- property yedge
- property ygrid
- class VertexSpatialReference(xvdict=None, yvdict=None, nlay=1, xadj=0, yadj=0, rotation=0.0, lenuni=1.0, proj4_str=None, **kwargs)[source]
Bases:
object
a simple class to locate the model grid in x-y space
- Parameters:
xvdict (dictionary) – dictionary of x-vertices {1: (0,1,1,0)}
yvdict (dictionary) – dictionary of y-vertices {1: (1,0,1,0)}
lenuni (int) – the length units flag from the discretization package
xadj (float) – the x coordinate of the upper left corner of the grid
yadj (float) – the y coordinate of the upper left corner of the grid
rotation (float) – the counter-clockwise rotation (in degrees) of the grid
proj4_str (str) – a PROJ4 string that identifies the grid in space. warning: case sensitive!
- xedge
array of column edges
- Type:
ndarray
- yedge
array of row edges
- Type:
ndarray
- xgrid
numpy meshgrid of xedges
- Type:
ndarray
- ygrid
numpy meshgrid of yedges
- Type:
ndarray
- xcenter
array of column centers
- Type:
ndarray
- ycenter
array of row centers
- Type:
ndarray
- xcentergrid
numpy meshgrid of column centers
- Type:
ndarray
- ycentergrid
numpy meshgrid of row centers
- Type:
ndarray
Notes
xadj and yuadj can be explicitly (re)set after SpatialReference instantiation, but only before any of the other attributes and methods are accessed
- property ncpl
- static rotate(x, y, theta, xorigin=0.0, yorigin=0.0)[source]
Given x and y array-like values calculate the rotation about an arbitrary origin and then return the rotated coordinates. theta is in degrees.
- set_spatialreference(xadj=0.0, yadj=0.0, rotation=0.0)[source]
set spatial reference - can be called from model instance xadj, yadj should be named xadj, yadj since they represent an adjustment factor
- property xarr
- property xcenter_array
- property xdict
- property xydict
- property yarr
- property ycenter_array
- property ydict