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
Parameters
x |
array_like |
x coordinates of cell centers |
None |
x0 |
float |
x coordinate of lower-left corner of first cell |
0.0 |
dx |
float |
x cell size |
None |
nx |
int |
number of cells in x direction |
None |
y |
array_like |
y coordinates of cell centers |
None |
y0 |
float |
y coordinate of lower-left corner of first cell |
0.0 |
dy |
float |
y cell size |
None |
ny |
int |
number of cells in y direction |
None |
bbox |
tuple |
(x0, y0, x1, y1) of bounding box |
None |
projection |
str |
projection string, by default “NON-UTM” |
'LONG/LAT' |
origin |
tuple |
user-defined origin, by default None |
None |
orientation |
float |
rotation angle in degrees, by default 0.0 |
0.0 |
axis_names |
tuple |
names of x and y axes, by default (“x”, “y”) |
('x', 'y') |
is_spectral |
bool |
if True, the grid is spectral, by default False |
False |
is_vertical |
bool |
if True, the grid is vertical, by default False |
False |
Examples
import mikeio
mikeio.Grid2D(x0=12.0, nx=2, dx=0.25, y0=55.0, ny=3, dy=0.25, projection="LONG/LAT")
<mikeio.Grid2D>
x: [12, 12.25] (nx=2, dx=0.25)
y: [55, 55.25, 55.5] (ny=3, dy=0.25)
projection: LONG/LAT
Attributes
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
contains
Test if a list of points are inside grid.
Parameters
coords |
array(float) |
xy-coordinate of points given as n-by-2 array |
required |
Returns
|
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
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
|
(array(int), array(int)) |
i- and j-index of nearest cell |
get_node_coordinates
Grid2D.get_node_coordinates()
Node coordinates for this grid.
Returns
|
array(float) |
2d array with x,y-coordinates, length=(nx+1)*(ny+1) |
isel
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
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
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 |