MIR: regridding numpy arraysΒΆ
This example shows how to interpolate numpy arrays using the mir 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)
Next, 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]})
res.shape, res_grid
[3]:
((181, 360), {'grid': [1, 1]})
regrid() returns a tuple with the regridded array and the resulting gridspec. This latter might be different than the one specified in out_grid because MIR can perform normalisation and other adjustments on it.
[ ]: