NEDAS.utils.spatial_operation module

NEDAS.utils.spatial_operation.gradx(fld, dx, cyclic_dim=None)

Gradient of input field in x direction

Parameters:
  • fld (np.ndarray) – input field, last two dimensions (ny, nx)

  • dx (int) – grid spacing in x, fld.shape

  • cyclic_dim (str, optional) – string ‘x’, ‘y’, ‘xy’, indicating the dimension(s) that are cyclic.

Returns:

gradx of fld with same shape

Return type:

np.ndarray

NEDAS.utils.spatial_operation.grady(fld, dy, cyclic_dim=None)

gradient of input fld in y direction, similar to gradx

NEDAS.utils.spatial_operation.gradx2(fld, dx, cyclic_dim=None)
NEDAS.utils.spatial_operation.grady2(fld, dy, cyclic_dim=None)
NEDAS.utils.spatial_operation.gradxy(fld, dx, dy, cyclic_dim=None)
NEDAS.utils.spatial_operation.laplacian(fld, dx, dy, cyclic_dim=None)
NEDAS.utils.spatial_operation.coarsen(grid, fld, nlevel)[source]

Coarsen the image by downsampling the grid points by factors of 1/2,

Parameters:
  • grid (Grid) – the original grid

  • fld (np.ndarray) – field with last two dimensions ny,nx

  • nlevel (int) – number of resolution levels to go down

Returns:

new grid with lower resolution np.ndarray: new field defined on the new grid

Return type:

Grid

NEDAS.utils.spatial_operation.refine(grid, mask, fld, nlevel)[source]

Refine the image by upsampling the grid points by factors of 2,

Parameters:
  • grid (Grid) – the original grid

  • fld (np.ndarray) – field with last two dimensions ny,nx

  • nlevel (int) – number of resolution levels to go up

Returns:

new grid with higher resolution np.ndarray: new field on new grid

Return type:

Grid

NEDAS.utils.spatial_operation.coarsen_mask(mask, lev1, lev2)[source]
NEDAS.utils.spatial_operation.coarsen_field(fld, lev1, lev2)[source]
NEDAS.utils.spatial_operation.sharpen_field(fld, lev1, lev2)[source]
NEDAS.utils.spatial_operation.warp(grid, fld, u, v)[source]

Warp the image with input vector field

Parameters:
  • grid (Grid) – the grid on which the image is defined

  • fld (np.ndarray) – input image

  • u (np.ndarray) – displacement vector x component, in grid.x units

  • v (np.ndarray) – displacement vector y component, in grid.y units

Returns:

the warped image

Return type:

np.ndarray