iris.experimental.stratify

Routines for putting data on new strata (aka. isosurfaces), often in the Z direction.

In this module:

iris.experimental.stratify.relevel(cube, src_levels, tgt_levels, axis=None, interpolator=None)[source]

Interpolate the cube onto the specified target levels, given the source levels of the cube.

For example, suppose we have two datasets P(i,j,k) and H(i,j,k) and we want P(i,j,H). We call relevel() with cube=P, src_levels=H and tgt_levels being an array of the values of H we would like.

This routine is especially useful for computing isosurfaces of phenomenon that are generally monotonic in the direction of interpolation, such as height/pressure or salinity/depth.

Args:

cubeCube

The phenomenon data to be re-levelled.

src_levelsCube, Coord or string

Describes the source levels of the cube that will be interpolated over. The src_levels must be in the same system as the tgt_levels. The dimensions of src_levels must be broadcastable to the dimensions of the cube. Note that, the coordinate name containing the source levels in the cube may be provided.

tgt_levelsarray-like

Describes the target levels of the cube to be interpolated to. The tgt_levels must be in the same system as the src_levels. The dimensions of the tgt_levels must be broadcastable to the dimensions of the cube, except in the nominated axis of interpolation.

axisint, Coord or string

The axis of interpolation. Defaults to the first dimension of the cube, which is typically the z-dimension. Note that, the coordinate name specifying the z-dimension of the cube may be provided.

interpolatorcallable or None

The interpolator to use when computing the interpolation. The function will be passed the following positional arguments:

(tgt-data, src-data, cube-data, axis-of-interpolation)

If the interpolator is None, stratify.interpolate() will be used with linear interpolation and NaN extrapolation.

An example of constructing an alternative interpolation scheme:

from functools import partial
interpolator = partial(stratify.interpolate,
                       interpolation=stratify.INTERPOLATE_NEAREST,
                       extrapolation=stratify.EXTRAPOLATE_LINEAR)