interpolate

  • Interpolators for spatial data

Source code

IceAdvect.interpolate.inpaint(xs: ndarray, ys: ndarray, zs: ndarray, N: int = 0, s0: int = 3, power: int = 2, epsilon: float = 2.0, **kwargs)[source]

Inpaint over missing data in a two-dimensional array using a penalized least-squares method based on discrete cosine transforms [1, 6]

Parameters:
xs: np.ndarray

x-coordinates

ys: np.ndarray

y-coordinates

zs: np.ndarray

Data with masked values

N: int, default 0

Number of iterations (0 for nearest neighbors)

s0: int, default 3

Smoothing factor

power: int, default 2

Power for lambda function

epsilon: float, default 2.0

Relaxation factor

Returns:
z0: np.ndarray

Data with inpainted (filled) values

IceAdvect.interpolate.barycentric(xv: ndarray, yv: ndarray, ze: ndarray, x: ndarray, y: ndarray, order: int = 1, **kwargs)[source]

Interpolation of unstructured model data using a barycentric method

Parameters:
xv: np.ndarray

x-coordinates of triangle vertices

yv: np.ndarray

y-coordinates of triangle vertices

ze: np.ndarray

Unstructured model data at elements

x: np.ndarray

Output x-coordinates

y: np.ndarray

Output y-coordinates

order: int, default 1

Polynomial order of the triangular elements

  • 1: linear

  • 2: quadratic

Returns:
data: xr.DataArray

Interpolated data

IceAdvect.interpolate._to_barycentric(xv: ndarray, yv: ndarray, x: ndarray, y: ndarray)[source]

Convert coordinates to barycentric space

Parameters:
xv: np.ndarray

x-coordinates of triangle vertices

yv: np.ndarray

y-coordinates of triangle vertices

x: np.ndarray

Output x-coordinates

y: np.ndarray

Output y-coordinates

Returns:
xi: np.ndarray

Normalized barycentric (areal) xi-coordinates

eta: np.ndarray

Normalized barycentric (areal) eta-coordinates

IceAdvect.interpolate._inside_triangle(xi: ndarray, eta: ndarray, atol: float = 1e-08)[source]

Check if point is within the triangular area

Parameters:
xi: np.ndarray

Normalized barycentric (areal) xi-coordinates

eta: np.ndarray

Normalized barycentric (areal) eta-coordinates

atol: float = 1e-8

Absolute tolerance parameter

Returns:
valid: np.ndarray

Mask for coordinates

IceAdvect.interpolate._shape_functions(xi: ndarray, eta: ndarray, order: int)[source]

Get the interpolating shape functions for a polynomial order

Parameters:
xi: np.ndarray

Normalized barycentric (areal) xi-coordinates

eta: np.ndarray

Normalized barycentric (areal) eta-coordinates

order: int

Polynomial order of the triangular elements

  • 1: linear

  • 2: quadratic

Returns:
N: list

Shape functions in barycentric space

IceAdvect.interpolate._winding_number(xv: ndarray, yv: ndarray)[source]

Calculate the winding number of a triangle by taking the cross-product of the vertex vectors

Parameters:
xv: np.ndarray

x-coordinates of triangle vertices

yv: np.ndarray

y-coordinates of triangle vertices

Returns:
wind: np.ndarray

Winding number of the triangle