regrid (array-level) with MIR

New in version 0.5.0.

regrid(values, in_grid=None, out_grid=None, *, interpolation='linear', backend='mir', nearest_method='automatic', distance=1, distance_tolerance=1, nclosest=4)

Regrid array values 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:
  • values (ndarray) – array representing a single field defined on the in_grid.

  • in_grid (dict) – the gridspec describing the grid that values are defined on. Ignored when values is not an ndarray.

  • out_grid (dict) – the gridspec describing the target grid that values 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:

Return a tuple with the interpolated values and the gridspec of the output grid.

Return type:

tuple of ndarray and dict

Examples