Deltares / xugrid

Xarray and unstructured grids
https://deltares.github.io/xugrid/
MIT License
61 stars 8 forks source link

laplace_interpolate and interpolate_na should broadcast over dimensions using apply_ufunc #292

Closed Huite closed 3 weeks ago

Huite commented 3 weeks ago

Currently, both interpolation methods only work on UgridDataArray with a single UGRID dimension.

It should work over additional dimensions, such as time and layer. xarray apply_ufunc takes care of this nicely.

A straightforward implementation would just process them one slice at a time. This is a bit inefficient if the NoData values are persistent over e.g. time. In that case, we could setup and query a KDTree only once, and assign values across dimensions with a single .isel. This has the obvious downside of needing to load and check all values immediately.