For each field, returns the field regridded onto a new latitude-longitude grid.
Regridding, also called remapping or interpolation, is the process of changing the grid underneath field data values while preserving the qualities of the original data.
By default the the regridding is a first-order conservative interpolation, but bilinear interpolation is available. The latter method is particular useful for cases when the latitude and longitude coordinate cell boundaries are not known nor inferrable.
Metadata
The field’s domain must have well defined X and Y axes with latitude and longitude coordinate values, which may be stored as dimension coordinate objects or two dimensional auxiliary coordinate objects. The same is true for the destination grid, if it provided as part of another field.
The cyclicity of the X axes of the source field and destination grid is taken into account. If an X axis is in fact cyclic but is registered as such by its parent field (see cf.Field.iscyclic), then the cyclicity may be set with the src_cyclic or dst_cyclic parameters.
The output field’s coordinate objects which span the X and/or Y axes are replaced with those from the destination grid. Any fields contained in coordinate reference objects will also be regridded, if possible.
Mask
The data array mask of the field is automatically taken into account, such that the regridded data array will be masked in regions where the input data array is masked. By default the mask of the destination grid is also taken into account. If the destination field data has more than two dimensions then the mask is taken from the two dimensionsal section of the data where the indices of all axes other than X and Y are zero.
Method
The interpolation is carried by out using the ESMF package - a Python interface to the Earth System Modeling Framework (ESMF) regridding utility.
Logging
Whether ESMF logging is enabled or not is determined by cf.REGRID_LOGGING. If it is logging takes place after every call. By default logging is disabled.
Examples 1: |
---|
Regrid field f conservatively onto a grid contained in field g and point to the result with reference h.
>>> h = f.regrids(g)
Parameters: |
|
---|---|
Returns: |
|
Examples 2: |
Regrid f to the grid of g using bilinear regridding and forcing the source field f to be treated as cyclic.
>>> h = f.regrids(g, src_cyclic=True, method='bilinear')
Regrid f to the grid of g ignoring the mask of g.
>>> h = f.regrids(g, ignore_dst_mask=True)
Regrid f to 2D auxiliary coordinates lat and lon, which have their dimensions ordered ‘Y’ first then ‘X’.
>>> lat
<CF AuxiliaryCoordinate: latitude(110, 106) degrees_north>
>>> lon
<CF AuxiliaryCoordinate: longitude(110, 106) degrees_east>
>>> h = f.regrids({'longitude': lon, 'latitude': lat, 'axes': ('Y', 'X')})