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
dataobject 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:
an earthkit-data
FieldListan earthkit-data
Fielda GRIB message as a
bytesorio.BytesIOobject
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 informationin_gridneeds to be provided. Whenin_gridis provided, it takes precedence over the metadata of the input data. The supported grids depends on the regriddingbackend.out_grid (
dict|str|Grid|None) – The grid spec describing the target grid thatdatawill be interpolated onto. The supported grids depends on the regriddingbackend.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:
- ”mir”: Use the MIR regridding library. This is the default backend. See details in the
documentation at regrid (high-level) with MIR.
- ”precomputed”: Use pre-computed interpolation weights for some supported grid pairs and interpolation
methods. See details in the documentation at regrid (high-level) with precomputed weights.
**kwargs – Additional keyword arguments depending on data type, interpolation or backend.
- Returns:
The regridded data with the same type as
databut with the grid changed to the output grid.- Return type:
"FieldList|Field|xarray.DataArray|xarray.Dataset|bytes|io.BytesIO"
Examples
Using the “mir” backend:
/tutorials/mir/mir_regrid_xarray.ipynb
Using the “precomputed” backend: