regrid (high-level) with MIR

New in version 0.5.0.

regrid(data, grid=None, *, interpolation='linear', backend='mir', nearest_method='automatic', distance=1, distance_tolerance=1, nclosest=4, **kwargs)

Regrid the high-level data object (with geography information) using MIR (Meteorological Interpolation and Regridding).

The backend parameter is set to “mir” by default so it is not necessary to specify it explicitly.

Parameters:
  • data (fieldlist, field, bytes, or io.BytesIO) –

    the following input data types are supported:

    • an earthkit-data GRIB fieldlist (requires earthkit-data >= 0.6.0).

    • an earthkit-data GRIB field (requires earthkit-data >= 0.6.0).

    • a GRIB message as a bytes or io.BytesIO object

    • an xarray.DataArray or xarray.Dataset

  • grid (dict) – the gridspec describing the target grid that data will be interpolated onto

  • interpolation (str) –

    the interpolation method. There is a high degree of customisation available to parametrise the available interpolation methods. Please note ot all the interpolation methods support all possible grid types. The possible values are as follows:

    • ”linear”: Finite Element based interpolation with linear base functions with supporting triangular mesh

    • ”grid-box-average”: input/output grid box (see [model_grid_box]) intersections interpolation preserving input value integrals (conservative interpolation).

    • ”nearest-neighbour”: choose a nearest neighbouring input point to define output point value

  • nearest_method (str) –

    Available for any of the “nearest-” interpolation methods. The possible values are:

    • ”distance”: input points with radius (option distance) of output point

    • ”nclosest”: n-closest input points (option nclosest) to output point (default 4)

    • ”distance_and_nclosest”: input points respecting distance \(\cap\) nclosest.

    • ”distance_or_nclosest”: input points respecting distance \(\cup\) nclosest

    • ”nclosest_or_nearest”: n-closest input points (option nclosest), if all are at the same distance (within option distance_tolerance) return all points within that distance (robust interpolation of pole values)

    • ”nearest_neighbour_with_lowest_index”: nearest input point, if at the same distance to other points (option nclosest) chosen by lowest index

    • ”sample”: sample of n-closest points (option nclosest) out of input points with radius (option distance) of output point, not sorted by distance

    • ”sorted_sample”: as “sample”, sorted by distance

    • ”automatic”

  • distance (number, default: 1) – choice of closest points by distance to input point (metres)

  • distance_tolerance (number, default: 1) – tolerance in metres checking the farthest from nearest points (when nearest_method is “nclosest” or “nearest”).

  • nclosest (number, default: 4) – choice of n-closest input points to input point

  • **kwargs

    additional keyword arguments that can be passed to MIR. Since earthkit-regrid only supports the MIR options that are documented above, please use these extra options with care.

Returns:

see the output parameter for details

Examples