Provides ESMF representations of grids/UGRID meshes and a modified regridder.
- class esmf_regrid.esmf_regridder.GridInfo(lons, lats, lonbounds, latbounds, crs=None, circular=False, areas=None, mask=None, center=False)#
Class for handling structured grids.
This class holds information about lat-lon type grids. That is, grids defined by lists of latitude and longitude values for points/bounds (with respect to some coordinate reference system i.e. rotated pole). It contains methods for translating this information into
esmpyobjects. In particular, there are methods for representing as a
esmpy.api.grid.Gridand as a
Grid. This esmpy
Fieldis designed to contain enough information for area weighted regridding and may be inappropriate for other
GridInfoobject describing the grid.
ArrayLike) – A 1D or 2D array or list describing the longitudes of the grid points.
ArrayLike) – A 1D or 2D array or list describing the latitudes of the grid points.
ArrayLike) – A 1D or 2D array or list describing the longitude bounds of the grid. Should have length one greater than
ArrayLike) – A 1D or 2D array or list describing the latitude bounds of the grid. Should have length one greater than
circular (bool, default=False) – Describes if the final longitude bounds should be considered contiguous with the first.
center (bool, default=False) – Describes if the center points of the grid cells are used in regridding calculations.
- class esmf_regrid.esmf_regridder.RefinedGridInfo(lonbounds, latbounds, resolution=3, crs=None, mask=None)#
Class for handling structured grids represented in
esmpyin higher resolution.
A specialised version of
GridInfo. Designed to provide higher accuracy conservative regridding for rectilinear grids, especially those with particularly large cells which may not be well represented by
esmpy. This class differs from
GridInfoprimarily in the way it represents itself as a
Fieldis designed to be a higher resolution version of the given grid and should contain enough information for area weighted regridding but may be inappropriate for other
RefinedGridInfoobject describing the grid.
ArrayLike) – A 1D array or list describing the longitude bounds of the grid. Must be strictly increasing (for example, if a bound goes from 170 to -170 consider transposing -170 to 190).
ArrayLike) – A 1D array or list describing the latitude bounds of the grid. Must be strictly increasing.
resolution (int, default=400) – A number describing how many latitude slices each cell should be divided into when passing a higher resolution grid to ESMF.
- class esmf_regrid.esmf_regridder.Regridder(src, tgt, method='conservative', precomputed_weights=None)#
Regridder for directly interfacing with
Create a regridder from descriptions of horizontal grids/meshes.
scipy.sparse.spmatrix, optional) – If
esmpywill be used to calculate regridding weights. Otherwise,
esmpywill be bypassed and
precomputed_weightswill be used as the regridding weights.
- regrid(src_array, norm_type='fracarea', mdtol=1)#
Perform regridding on an array of data.
ArrayLike) – Array whose shape is compatible with
mdtol (float, default=1) – A number between 0 and 1 describing the missing data tolerance. Depending on the value of
mdtol, if a cell in the target grid is not sufficiently covered by unmasked cells of the source grid, then it will be masked.
mdtol=1means that only target cells which are not covered at all will be masked,
mdtol=0means that all target cells that are not entirely covered will be masked, and
mdtol=0.5means that all target cells that are less than half covered will be masked.
An array whose shape is compatible with
- Return type: