xoa.core.interp.XYInterpolator

xoa.core.interp.XYInterpolator#

class xoa.core.interp.XYInterpolator(src_grid, dst_lon, dst_lat, method='bilinear', bias=0.0, tension=0.0)[source]#

Numba-accelerated interpolator from a 2D source grid to arbitrary destination points.

Supports bilinear and bicubic methods. The destination can be any shape: a single point, a 1D transect, a 2D grid, etc.

The source must be a 2D curvilinear, rectangular, or regular grid. The destination is any array of (lon, lat) pairs — no grid structure required.

__init__(src_grid, dst_lon, dst_lat, method='bilinear', bias=0.0, tension=0.0)[source]#
Parameters:
  • src_grid (dict) – Keys: ‘lon’ (2D array), ‘lat’ (2D array), optional ‘mask’ (2D bool), ‘type’ (str).

  • dst_lon (array-like) – Destination coordinates, any shape. Scalars are treated as shape (1,). Output shape matches this shape.

  • dst_lat (array-like) – Destination coordinates, any shape. Scalars are treated as shape (1,). Output shape matches this shape.

  • method (str) – ‘bilinear’ or ‘bicubic’

  • bias (float) – Kochanek-Bartels parameters for bicubic interpolation (default 0).

  • tension (float) – Kochanek-Bartels parameters for bicubic interpolation (default 0).

Methods

compute_weights([skipna])

Compute fractional cell indices for each destination point.

get_weights()

Return the computed fractional-index weights as a dict.

interp(data[, skipna, na_thres])

Interpolate source data to destination points.

interp_with_time(data, src_times, dst_times)

Interpolate to scattered (x, y, t) locations.

load_weights(filename)

Load precomputed weights from a npz file

save_weights(filename)

Save computed weights to a npz file

set_weights(weights)

Restore fractional-index weights from a dict (as returned by get_weights()).

Attributes

dst_shape

Shape of the destination point array.

has_weights

True if compute_weights() has been called successfully.

valid_grid_types

valid_methods