earthkit.geo.grids._regrid.regrid.regrid

earthkit.geo.grids._regrid.regrid.regrid(data, in_grid=None, out_grid=None, in_dims=None, out_dims=None, interpolation='linear', backend='mir', **kwargs)
earthkit.geo.grids._regrid.regrid.regrid(data: FieldList | Field, in_grid: dict | str | Grid | None = None, out_grid: dict | str | Grid | None = None, interpolation: str = 'linear', backend: Literal['mir', 'precomputed'] = 'mir', **kwargs) FieldList | Field
earthkit.geo.grids._regrid.regrid.regrid(data: bytes | io.BytesIO, in_grid: dict | str | Grid | None = None, out_grid: dict | str | Grid | None = None, interpolation: str = 'linear', backend: Literal['mir', 'precomputed'] = 'mir', **kwargs) bytes | io.BytesIO

Regrid the high-level data object with the given backend.

Parameters:
  • data (FieldList|Field|xarray.DataArray|xarray.Dataset|io.BytesIO) –

    The input data to be regridded. The supported data types are as follows:

  • in_grid (dict|str|Grid|None, optional) – The grid spec describing the input grid. It is only needed when the input grid cannot be automatically inferred from the input data. This can be the case for Xarray, where at present the grid information can only be accessed via the “earthkit.grid_spec” attribute, and if it is missing or does not contain the necessary information in_grid needs to be provided. When in_grid is provided, it takes precedence over the metadata of the input data. The supported grids depends on the regridding backend.

  • out_grid (dict|str|Grid|None) – The grid spec describing the target grid that data will be interpolated onto. The supported grids depends on the regridding backend.

  • interpolation (str) –

    The interpolation method. Please note not 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 intersections interpolation preserving input value integrals (conservative interpolation).

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

  • backend ({"mir", "precomputed"}, default "mir") –

    The regridding backend to use. The possible values are as follows:

  • **kwargs – Additional keyword arguments depending on data type, interpolation or backend.

Returns:

The regridded data with the same type as data but with the grid changed to the output grid.

Return type:

"FieldList|Field|xarray.DataArray|xarray.Dataset|bytes|io.BytesIO"

Examples

Using the “mir” backend:

Using the “precomputed” backend: