Precomputed: regridding numpy arraysΒΆ

This example shows how to interpolate numpy arrays using the precomputed backend.

[1]:
import numpy as np

from earthkit.geo.grids.array import regrid

First, we generate random data matching the size of an O32 octahedral reduced Gaussian grid.

[2]:
values = np.random.random(5248)

Interpolate the array onto a 1x1 degree global regular latitude-longitude grid using regrid(). The input and output grids are defined by a gridspec. Both the input and the output values are numpy arrays.

[3]:
res, res_grid = regrid(values, in_grid={"grid": "O32"}, out_grid={"grid": [1, 1]}, backend="precomputed")
res.shape, res_grid
[3]:
((181, 360), {'grid': [1, 1]})

regrid() returns a tuple with the regridded array and the resulting gridspec.

[ ]: