Iris helper functions
Auxiliary functions for iris
.
Functions:
|
Add new leading dimension to cube. |
|
Convert datetime object into numeric value with requested dtype. |
|
|
- esmvalcore.iris_helpers.add_leading_dim_to_cube(cube, dim_coord)[source]
Add new leading dimension to cube.
An input cube with shape
(x, ..., z)
will be transformed to a cube with shape(w, x, ..., z)
wherew
is the length ofdim_coord
. Note that the data is broadcasted to the new shape.- Parameters
cube (iris.cube.Cube) – Input cube.
dim_coord (iris.coords.DimCoord) – Dimensional coordinate that is used to describe the new leading dimension. Needs to be 1D.
- Returns
Transformed input cube with new leading dimension.
- Return type
- Raises
CoordinateMultiDimError –
dim_coord
is not 1D.
- esmvalcore.iris_helpers.date2num(date, unit, dtype=<class 'numpy.float64'>)[source]
Convert datetime object into numeric value with requested dtype.
This is a custom version of
cf_units.Unit.date2num()
that guarantees the correct dtype for the return value.- Parameters
date (
datetime.datetime
orcftime.datetime
) –unit (
cf_units.Unit
) –dtype (a numpy dtype) –
- Returns
The return value of
unit.date2num
with the requested dtype.- Return type
numpy.ndarray
of type dtype
- esmvalcore.iris_helpers.var_name_constraint(var_name)[source]
iris.Constraint
usingvar_name
.Warning
Deprecated since version 2.6.0: This function has been deprecated in ESMValCore version 2.6.0 and is scheduled for removal in version 2.8.0. Please use the function
iris.NameConstraint
with the argumentvar_name
instead: this is an exact replacement.- Parameters
var_name (str) –
var_name
used for the constraint.- Returns
Constraint.
- Return type