iris.analysis.calculus¶
Calculus operations on iris.cube.Cube
instances.
See also: NumPy
.
In this module:

iris.analysis.calculus.
cube_delta
(cube, coord)¶ Given a cube calculate the difference between each value in the given coord’s direction.
Args:
 coord
 either a Coord instance or the unique name of a coordinate in the cube. If a Coord instance is provided, it does not necessarily have to exist in the cube.
Example usage:
change_in_temperature_wrt_pressure = cube_delta(temperature_cube, 'pressure')
Note
Missing data support not yet implemented.

iris.analysis.calculus.
differentiate
(cube, coord_to_differentiate)¶ Calculate the differential of a given cube with respect to the coord_to_differentiate.
Args:
 coord_to_differentiate:
 Either a Coord instance or the unique name of a coordinate which exists in the cube. If a Coord instance is provided, it does not necessarily have to exist on the cube.
Example usage:
u_wind_acceleration = differentiate(u_wind_cube, 'forecast_time')
The algorithm used is equivalent to:
Where
d
is the differential,v
is the data value,c
is the coordinate value andi
is the index in the differential direction. Hence, in a normal situation if a cube has a shape (x: n; y: m) differentiating with respect to x will result in a cube of shape (x: n1; y: m) and differentiating with respect to y will result in (x: n; y: m1). If the coordinate to differentiate iscircular
then the resultant shape will be the same as the input cube.In the returned cube the coord_to_differentiate object is redefined such that the output coordinate values are set to the averages of the original coordinate values (i.e. the midpoints). Similarly, the output lower bounds values are set to the averages of the original lower bounds values and the output upper bounds values are set to the averages of the original upper bounds values. In more formal terms:
 C[i] = (c[i] + c[i+1]) / 2
 B[i, 0] = (b[i, 0] + b[i+1, 0]) / 2
 B[i, 1] = (b[i, 1] + b[i+1, 1]) / 2
where c and b represent the input coordinate values and bounds, and C and B the output coordinate values and bounds.
Note
Difference method used is the same as
cube_delta()
and therefore has the same limitations.
Note
Spherical differentiation does not occur in this routine.

iris.analysis.calculus.
curl
(i_cube, j_cube, k_cube=None)¶ Calculate the 2dimensional or 3dimensional spherical or cartesian curl of the given vector of cubes.
As well as the standard x and y coordinates, this function requires each cube to possess a vertical or zlike coordinate (representing some form of height or pressure). This can be a scalar or dimension coordinate.
Args:
 i_cube
 The i cube of the vector to operate on
 j_cube
 The j cube of the vector to operate on
Kwargs:
 k_cube
 The k cube of the vector to operate on
Return (i_cmpt_curl_cube, j_cmpt_curl_cube, k_cmpt_curl_cube)
If the kcube is not passed in then the 2dimensional curl will be calculated, yielding the result: [None, None, k_cube]. If the kcube is passed in, the 3dimensional curl will be calculated, returning 3 component cubes.
All cubes passed in must have the same data units, and those units must be spatiallyderived (e.g. ‘m/s’ or ‘km/h’).
The calculation of curl is dependent on the type of
CoordSystem()
in the cube. If theCoordSystem()
is either GeogCS or RotatedGeogCS, the spherical curl will be calculated; otherwise the cartesian curl will be calculated:Cartesian curl
When cartesian calculus is used, i_cube is the u component, j_cube is the v component and k_cube is the w component.
The Cartesian curl is defined as:
Spherical curl
When spherical calculus is used, i_cube is the vector component (e.g. eastward), j_cube is the component (e.g. northward) and k_cube is the radial component.
The spherical curl is defined as:
where phi is longitude, theta is latitude.