surface_grid¶
Functions to define 2D grids based on coordinates
coordinates_to_grid(x, y=None, z=None)
¶
Convert coordinates to grid coordinates
X, Y, Z = coordinates_to_grid(x, y, z)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array | tuple[list, list, list]
|
array of coordinates, either x=(n,) or x=(n,3). |
required |
y
|
Array | None
|
array of y coordinates, or None if x=(n,3) |
None
|
z
|
Array | None
|
array of z coordinates, or None if x=(n,3) |
None
|
Returns:
| Type | Description |
|---|---|
|
x,y,z grid coordinates, each with shape ~(a,b) where a+b ~ n |
Source code in mmg_toolbox/utils/surface_grid.py
interpolate_to_grid(x, y=None, z=None, grid_shape=None, method='linear')
¶
Convert coordinates to grid coordinates
X, Y, Z = interpolate_to_grid(x, y, z, (101, 101))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array | tuple[list, list, list]
|
array of coordinates, either x=(n,) or x=(n,3). |
required |
y
|
Array | None
|
array of y coordinates, or None if x=(n,3) |
None
|
z
|
Array | None
|
array of z coordinates, or None if x=(n,3) |
None
|
grid_shape
|
tuple[int, int] | None
|
grid shape, (x, y) |
None
|
method
|
Literal['nearest', 'linear', 'cubic']
|
interpolation method for scipy.interpolate.griddata. One of: "nearest", "linear", "cubic" |
'linear'
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray, ndarray]
|
x,y,z grid coordinates, each with shape ~(a,b) where a+b ~ n |