User API

Regridder

util

xesmf.util.grid_2d(lon0_b, lon1_b, d_lon, lat0_b, lat1_b, d_lat)

2D rectilinear grid centers and bounds

Parameters
lon0_b, lon1_bfloat

Longitude bounds

d_lonfloat

Longitude step size, i.e. grid resolution

lat0_b, lat1_bfloat

Latitude bounds

d_latfloat

Latitude step size, i.e. grid resolution

Returns
dsxarray DataSet with coordinate values
xesmf.util.cf_grid_2d(lon0_b, lon1_b, d_lon, lat0_b, lat1_b, d_lat)

CF compliant 2D rectilinear grid centers and bounds.

Parameters
lon0_b, lon1_bfloat

Longitude bounds

d_lonfloat

Longitude step size, i.e. grid resolution

lat0_b, lat1_bfloat

Latitude bounds

d_latfloat

Latitude step size, i.e. grid resolution

Returns
dsxarray.DataSet with coordinate values
xesmf.util.grid_global(d_lon, d_lat, cf=False)

Global 2D rectilinear grid centers and bounds

Parameters
d_lonfloat

Longitude step size, i.e. grid resolution

d_latfloat

Latitude step size, i.e. grid resolution

cfbool

Return a CF compliant grid.

Returns
dsxarray DataSet with coordinate values
xesmf.util.split_polygons_and_holes(polys)

Split the exterior boundaries and the holes for a list of polygons.

If MultiPolygons are encountered in the list, they are flattened out in their constituents.

Parameters
polysSequence of shapely Polygons or MultiPolygons
Returns
exteriorslist of Polygons

The polygons without any holes

holeslist of Polygons

Holes of the polygons as polygons

i_extlist of integers

The index in polys of each polygon in exteriors.

i_hollist of integers

The index in polys of the owner of each hole in holes.

data

Standard test data for regridding benchmark.

xesmf.data.wave_smooth(lon, lat)

Spherical harmonic with low frequency.

Parameters
lon, lat2D numpy array or xarray DataArray

Longitute/Latitude of cell centers

Returns
f2D numpy array or xarray DataArray depending on input

2D wave field

Notes

Equation from [1] [2]:

\[\begin{split}Y_2^2 = 2 + \cos^2(\\theta) \cos(2 \phi)\end{split}\]

References

1

Jones, P. W. (1999). First-and second-order conservative remapping schemes for grids in spherical coordinates. Monthly Weather Review, 127(9), 2204-2210.

2

Ullrich, P. A., Lauritzen, P. H., & Jablonowski, C. (2009). Geometrically exact conservative remapping (GECoRe): regular latitude–longitude and cubed-sphere grids. Monthly Weather Review, 137(6), 1721-1741.