Regrid

class ESMF.api.regrid.Regrid(srcfield=None, dstfield=None, filename=None, src_mask_values=None, dst_mask_values=None, regrid_method=None, pole_method=None, regrid_pole_npoints=None, line_type=None, norm_type=None, extrap_method=None, extrap_num_src_pnts=None, extrap_dist_exponent=None, unmapped_action=None, ignore_degenerate=None, create_rh=None, src_frac_field=None, dst_frac_field=None)

The Regrid object represents a regridding operator between two Fields. The creation of this object is analogous to ESMF_FieldRegridStore(), and calling this object corresponds to ESMF_FieldRegrid(). ESMF_FieldRegridRelease() is called when the Regrid object goes out of scope (this only happens when the Manager goes out of scope, there is a destroy() call for explicit deallocation of the Regrid).

For more information about the ESMF Regridding functionality, please see the ESMF Regrid documentation.

The following arguments are used to create a handle to a Regridding operation between two Fields.

REQUIRED:

:param Field srcfield: source Field associated with an underlying Grid,
Mesh or LocStream.
:param Field dstfield: destination Field associated with an underlying
Grid, Mesh or LocStream. The data in this Field may be overwritten by this call.

OPTIONAL:

Parameters:
  • filename (string) – the name of the file for writing weights.
  • src_mask_values (ndarray) – a numpy array of values that should be considered masked value on the source Field.
  • dst_mask_values (ndarray) – a numpy array of values that should be considered masked value on the destination Field.
  • regrid_method (RegridMethod) – specifies which RegridMethod to use. If None, defaults to BILINEAR.
  • pole_method (PoleMethod) – specifies which type of artificial pole to construct on the source Grid for regridding. If None, defaults to: NONE for regridmethod == CONSERVE, or ALLAVG for regridmethod != CONSERVE.
  • regrid_pole_npoints (int) – specifies how many points to average over if polemethod == ALLAVG.
  • line_type (LineType) – select the path of the line that connects two points on the surface of a sphere. This in turn controls the path along which distances are calculated and the shape of the edges that make up a cell. If None, defaults to: GREAT_CIRCLE for regridmethod == CONSERVE, or CART for regridmethod != CONSERVE.
  • norm_type (NormType) – control which type of normalization to do when generating conservative regridding weights. If None, defaults to DSTAREA.
  • extrap_method (ExtrapMethod) – Specify which extrapolation method to use on unmapped destination points after regridding.
  • extrap_num_src_pnts (int) – The number of source points to use for the extrapolation methods that use more than one source point (e.g. NEAREST_IDAVG). If not specified, defaults to 8.
  • extrap_dist_exponent (float) – The exponent to raise the distance to when calculating weights for the NEAREST_IDAVG extrapolation method. A higher value reduces the influence of more distant points. If not specified, defaults to 2.0.
  • unmapped_action (UnmappedAction) – specifies which action to take if a destination point is found which does not map to any source point. If None, defaults to ERROR.
  • ignore_degenerate (bool) – Ignore degenerate cells when checking the input Grids or Meshes for errors. If this is set to True, then the regridding proceeds, but degenerate cells will be skipped. If set to False, a degenerate cell produces an error. This currently only applies to CONSERVE, other regrid methods currently always skip degenerate cells. If None, defaults to False.
  • src_frac_field (ndarray) – return a numpy array of values containing weights corresponding to the amount of each Field value which contributes to the total mass of the Field.
  • dst_frac_field (ndarray) – return a numpy array of values containing weights corresponding to the amount of each Field value which contributes to the total mass of the Field.
__call__(srcfield, dstfield, filename=None, zero_region=None)

Call a regridding operation from srcfield to dstfield.

REQUIRED:

:param Field srcfield: the Field of source data to regrid. :param Field dstfield: the Field to hold the regridded data.

OPTIONAL:

Parameters:zero_region (Region) – specify which region of the field indices will be zeroed out before adding the values resulting from the interpolation. If None, defaults to TOTAL.
Returns:dstfield
copy()

Copy a Regrid in an ESMF-safe manner.

Returns:A Regrid shallow copy.
destroy()

Release the memory associated with a Regrid.