meteodatalab.operators.regrid

Regridding operator.

Functions

icon2geolatlon(field)

Remap ICON native grid data to the geolatlon grid.

icon2rotlatlon(field)

Remap ICON native grid data to the rotated latlon grid.

regrid(field, dst, resampling[, src])

Regrid a field.

Classes

RegularGrid(crs, nx, ny, xmin, xmax, ymin, ymax)

Class defining a regular grid.

class meteodatalab.operators.regrid.RegularGrid(crs: CRS, nx: int, ny: int, xmin: float, xmax: float, ymin: float, ymax: float)[source]

Class defining a regular grid.

crs

Coordinate reference system.

Type:

CRS

nx

Number of grid points in the x direction.

Type:

int

ny

Number of grid points in the y direction.

Type:

int

xmin

Coordinate of the first grid point in the x direction.

Type:

float

xmax

Coordinate of the last grid point in the x direction.

Type:

float

ymin

Coordinate of the first grid point in the y direction.

Type:

float

ymax

Coordinate of the last grid point in the y direction.

Type:

float

classmethod from_field(field: DataArray)[source]

Extract grid parameters from grib metadata.

Parameters:

field (xarray.DataArray) – field containing the relevant metadata.

classmethod parse_regrid_operator(op: str)[source]

Parse fieldextra out_regrid_target string.

Parameters:

op (str) – fieldextra out_regrid_target definition i.e. crs,xmin,ymin,xmay,ymax,dx,dy.

to_crs(crs: str, **kwargs)[source]

Return a new grid in the given coordinate reference system.

Parameters:

crs (str) – The coordinate reference system in which the output grid should be defined.

Returns:

Output grid in the given coordinate reference system.

Return type:

RegularGrid or subtype

meteodatalab.operators.regrid.icon2geolatlon(field: DataArray) DataArray[source]

Remap ICON native grid data to the geolatlon grid.

Parameters:

field (xarray.DataArray) – A field with data in the ICON native grid.

Returns:

Field with data remapped to the geolatlon grid.

Return type:

xarray.DataArray

meteodatalab.operators.regrid.icon2rotlatlon(field: DataArray) DataArray[source]

Remap ICON native grid data to the rotated latlon grid.

Parameters:

field (xarray.DataArray) – A field with data in the ICON native grid.

Returns:

Field with data remapped to the rotated latlon grid.

Return type:

xarray.DataArray

meteodatalab.operators.regrid.regrid(field: DataArray, dst: RegularGrid, resampling: Resampling, src: RegularGrid | None = None)[source]

Regrid a field.

Parameters:
  • field (xarray.DataArray) – Input field defined on a regular grid in rotated latlon coordinates.

  • dst (RegularGrid) – Destination grid onto which to project the field.

  • resampling (Resampling) – Resampling method, alias of rasterio.warp.Resampling.

  • src (RegularGrid, optional) – Definition of the input field grid

Raises:

ValueError – If the input field is not defined on a regular grid in rotated latlon or if the input field geography metadata does not have consistent grid parameters.

Returns:

Field regridded in the destination grid.

Return type:

xarray.DataArray