MIR: using different interpolations

This example compares different interpolation methods using the mir backend.

To make this notebook work earthkit-data and earthkit-plots have to be installed. The data will be represented as a :ref:~earthkit.data.core.fieldlist.FieldList`.

Regridding

We perform the regridding with the regrid() method.

[1]:
import earthkit.data as ekd

import earthkit.geo as ekg

# Get octahedral reduced Gaussian GRIB data containing two fields.
ds = ekd.from_source("sample", "O32_t2.grib2").to_fieldlist()

# the target grid is a global 1x1 degree regular latitude-longitude grid
out_grid = {"out_grid": [1, 1]}

# Regrid the fieldlist using various interpolations and
# gather results in a dict
res = {}
for i_type in ["linear", "nearest-neighbour", "grid-box-average"]:
    res[i_type] = ekg.regrid(ds, out_grid=out_grid, interpolation=i_type)

Plotting the results

We use earthkit-plots to visualise the results together with the locations of the original (O32) gridpoints.

[2]:
import earthkit.plots as ekp

for i_type, ds_res in res.items():
    chart = ekp.Map(domain=["Europe"])
    # we only plot the first field from the result
    chart.grid_cells(ds_res[0], units="celsius", style="auto")
    # plot the original grid points
    chart.grid_points(ds[0])
    chart.title(f"interpolation={i_type}")
    chart.coastlines()
    chart.gridlines()
    chart.show()
../../_images/how-tos_mir_mir_interpolation_types_7_0.png
../../_images/how-tos_mir_mir_interpolation_types_7_1.png
../../_images/how-tos_mir_mir_interpolation_types_7_2.png
[ ]: