Regridding NumPy arrays

For plain NumPy array data — a single field of values with no attached geography metadata — use the dedicated array-level entry point, earthkit.geo.grids.array.regrid(), rather than the generic, high-level earthkit.geo.grids.regrid().

from earthkit.geo.grids import array

out_values, out_grid = array.regrid(values, in_grid={"grid": [1, 1]}, out_grid={"grid": "O320"})

Since a raw array carries no geography information of its own, both in_grid and out_grid must always be given explicitly as gridspecs. The function returns a tuple of the interpolated values and the output grid spec; the latter may differ from the requested out_grid since the backend can normalise or otherwise adjust it during regridding.

Note

Passing a raw NumPy array to the generic earthkit.geo.grids.regrid() function raises a ValueError pointing to this array-level entry point instead, since that function’s grid inference and dispatch mechanism only applies to data types with attached geography metadata (see Regridding FieldList and Field data, regrid-grib and Regridding xarray Dataset and DataArray).

Examples

Using the “mir” backend:

Using the “precomputed” backend:

See also