esmf_regrid.experimental.unstructured_scheme module#

Provides an iris interface for unstructured regridding.

class esmf_regrid.experimental.unstructured_scheme.GridToMeshESMFRegridder(src_grid_cube, target_mesh_cube, mdtol=None, method='conservative', precomputed_weights=None, resolution=None)[source]#

Bases: object

Regridder class for rectilinear to unstructured Cube\ s.

Create regridder for conversions between source grid and target mesh.

Parameters
  • src_grid_cube (iris.cube.Cube) – The rectilinear Cube cube providing the source grid.

  • target_mesh_cube (iris.cube.Cube) – The unstructured Cube providing the target mesh.

  • mdtol (float, optional) – Tolerance of missing data. The value returned in each element of the returned array will be masked if the fraction of masked data exceeds mdtol. mdtol=0 means no missing data is tolerated while mdtol=1 will mean the resulting element will be masked if and only if all the contributing elements of data are masked. Defaults to 1 for conservative regregridding and 0 for bilinear regridding.

  • method (str, default="conservative") – Either “conservative” or “bilinear”. Corresponds to the ESMF methods CONSERVE or BILINEAR used to calculate weights.

  • precomputed_weights (scipy.sparse.spmatrix, optional) – If None, ESMF will be used to calculate regridding weights. Otherwise, ESMF will be bypassed and precomputed_weights will be used as the regridding weights.

  • resolution (int, optional) – If present, represents the amount of latitude slices per cell given to ESMF for calculation. If resolution is set, src_grid_cube must have strictly increasing bounds (bounds may be transposed plus or minus 360 degrees to make the bounds strictly increasing).

class esmf_regrid.experimental.unstructured_scheme.MeshToGridESMFRegridder(src_mesh_cube, target_grid_cube, mdtol=None, method='conservative', precomputed_weights=None, resolution=None)[source]#

Bases: object

Regridder class for unstructured to rectilinear Cube\ s.

Create regridder for conversions between source mesh and target grid.

Parameters
  • src_mesh_cube (iris.cube.Cube) – The unstructured Cube providing the source mesh.

  • target_grid_cube (iris.cube.Cube) – The Cube providing the target grid.

  • mdtol (float, optional) – Tolerance of missing data. The value returned in each element of the returned array will be masked if the fraction of masked data exceeds mdtol. mdtol=0 means no missing data is tolerated while mdtol=1 will mean the resulting element will be masked if and only if all the contributing elements of data are masked. Defaults to 1 for conservative regregridding and 0 for bilinear regridding.

  • method (str, default="conservative") – Either “conservative” or “bilinear”. Corresponds to the ESMF methods CONSERVE or BILINEAR used to calculate weights.

  • precomputed_weights (scipy.sparse.spmatrix, optional) – If None, ESMF will be used to calculate regridding weights. Otherwise, ESMF will be bypassed and precomputed_weights will be used as the regridding weights.

  • resolution (int, optional) – If present, represents the amount of latitude slices per cell given to ESMF for calculation. If resolution is set, target_grid_cube must have strictly increasing bounds (bounds may be transposed plus or minus 360 degrees to make the bounds strictly increasing).

esmf_regrid.experimental.unstructured_scheme.regrid_rectilinear_to_unstructured(src_cube, mesh_cube, mdtol=0, method='conservative', resolution=None)[source]#

Regrid rectilinear Cube onto unstructured mesh.

Return a new Cube with data values calculated using weights generated by ESMF to give the weighted mean of data values from src_cube regridded onto the horizontal mesh of mesh_cube. The dimensions on the Cube associated with the grid will replaced by a dimension associated with the mesh. That dimension will be the the first of the grid dimensions, whether it is associated with the x or y coordinate. Since two dimensions are being replaced by one, coordinates associated with dimensions after the grid will become associated with dimensions one lower. This function requires that the horizontal dimension of mesh_cube is described by a 2D mesh with data located on the faces of that mesh for conservative regridding and located on either faces or nodes for bilinear regridding. This function allows the horizontal grid of grid_cube to be either rectilinear or curvilinear (i.e. expressed in terms of two orthogonal 1D coordinates or via a pair of 2D coordinates). This function also requires that the Coord\ s describing the horizontal grid have bounds.

Parameters
  • src_cube (iris.cube.Cube) – A rectilinear instance of Cube that supplies the data, metadata and coordinates.

  • mesh_cube (iris.cube.Cube) – An unstructured instance of Cube that supplies the desired horizontal mesh definition.

  • mdtol (float, default=0) – Tolerance of missing data. The value returned in each element of the returned Cube\ ‘s data array will be masked if the fraction of masked data in the overlapping cells of the source cube exceeds mdtol. This fraction is calculated based on the area of masked cells within each target cell. mdtol=0 means no missing data is tolerated while mdtol=1 will mean the resulting element will be masked if and only if all the overlapping cells of the src_cube are masked.

  • method (str, default="conservative") – Either “conservative” or “bilinear”. Corresponds to the ESMF methods CONSERVE or BILINEAR used to calculate weights.

  • resolution (int, optional) – If present, represents the amount of latitude slices per cell given to ESMF for calculation.

Returns

A new Cube instance.

Return type

iris.cube.Cube

esmf_regrid.experimental.unstructured_scheme.regrid_unstructured_to_rectilinear(src_cube, grid_cube, mdtol=0, method='conservative', resolution=None)[source]#

Regrid unstructured Cube onto rectilinear grid.

Return a new Cube with data values calculated using weights generated by ESMF to give the weighted mean of data values from src_cube regridded onto the horizontal grid of grid_cube. The dimension on the Cube belonging to the mesh will replaced by the two dimensions associated with the grid. This function requires that the horizontal dimension of src_cube is described by a 2D mesh with data located on the faces of that mesh for conservative regridding and located on either faces or nodes for bilinear regridding. This function allows the horizontal grid of grid_cube to be either rectilinear or curvilinear (i.e. expressed in terms of two orthogonal 1D coordinates or via a pair of 2D coordinates). This function also requires that the Coord\ s describing the horizontal grid have bounds.

Parameters
  • src_cube (iris.cube.Cube) – An unstructured instance of Cube that supplies the data, metadata and coordinates.

  • grid_cube (iris.cube.Cube) – An instance of Cube that supplies the desired horizontal grid definition.

  • mdtol (float, default=0) – Tolerance of missing data. The value returned in each element of the returned Cube\ ‘s data array will be masked if the fraction of masked data in the overlapping cells of src_cube exceeds mdtol. This fraction is calculated based on the area of masked cells within each target cell. mdtol=0 means no missing data is tolerated while mdtol=1 will mean the resulting element will be masked if and only if all the overlapping cells of src_cube are masked.

  • method (str, default="conservative") – Either “conservative” or “bilinear”. Corresponds to the ESMF methods CONSERVE or BILINEAR used to calculate weights.

  • resolution (int, optional) – If present, represents the amount of latitude slices per cell given to ESMF for calculation.

Returns

A new Cube instance.

Return type

iris.cube.Cube