Grid2D

Grid2D(
    self,
    *,
    x=None,
    x0=0.0,
    dx=None,
    nx=None,
    y=None,
    y0=0.0,
    dy=None,
    ny=None,
    bbox=None,
    projection='LONG/LAT',
    origin=None,
    orientation=0.0,
    axis_names=('x', 'y'),
    is_spectral=False,
    is_vertical=False,
)

2D grid.

Origin in the center of cell in lower-left corner x and y axes are increasing and equidistant

Attributes

Name Description
bbox Bounding box (left, bottom, right, top).
dx X grid spacing.
dy Y grid spacing.
is_geo Are coordinates geographical (LONG/LAT)?
is_local_coordinates Are coordinates relative (NON-UTM)?
nx Number of x grid points.
ny Number of y grid points.
orientation Grid orientation.
origin Coordinates of grid origo (in projection).
projection The projection.
projection_string The projection string.
x Array of x coordinates (element center).
xy N-by-2 array of x- and y-coordinates.
y Array of y coordinates (element center).

Methods

Name Description
contains Test if a list of points are inside grid.
find_index Find nearest index (i,j) of point(s).
get_node_coordinates Node coordinates for this grid.
isel Return a new geometry as a subset of Grid2D along the given axis.
to_geometryFM Convert Grid2D to GeometryFM2D.
to_mesh Export grid to mesh file.

contains

Grid2D.contains(coords)

Test if a list of points are inside grid.

Parameters

Name Type Description Default
coords array(float) xy-coordinate of points given as n-by-2 array required

Returns

Name Type Description
bool array True for points inside, False otherwise

find_index

Grid2D.find_index(x=None, y=None, coords=None, area=None)

Find nearest index (i,j) of point(s).

Parameters

Name Type Description Default
x float x-coordinate of point None
y float y-coordinate of point None
coords array(float) xy-coordinate of points given as n-by-2 array None
area array(float) xy-coordinates of bounding box None

Returns

Name Type Description
(array(int), array(int)) i- and j-index of nearest cell

get_node_coordinates

Grid2D.get_node_coordinates()

Node coordinates for this grid.

Returns

Name Type Description
array(float) 2d array with x,y-coordinates, length=(nx+1)*(ny+1)

isel

Grid2D.isel(idx, axis)

Return a new geometry as a subset of Grid2D along the given axis.

to_geometryFM

Grid2D.to_geometryFM(z=None, west=2, east=4, north=5, south=3)

Convert Grid2D to GeometryFM2D.

Parameters

Name Type Description Default
z float bathymetry values for each node, by default 0 None
west int code value for west boundary 2
east int code value for east boundary 4
north int code value for north boundary 5
south int code value for south boundary 3

to_mesh

Grid2D.to_mesh(outfilename, z=None)

Export grid to mesh file.

Parameters

Name Type Description Default
outfilename str path of new mesh file required
z float or array(float) bathymetry values for each node, by default 0 if array: must have length=(nx+1)*(ny+1) None