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)wherewis 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_coordis 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.datetimeorcftime.datetime) –unit (
cf_units.Unit) –dtype (a numpy dtype) –
- Returns
The return value of
unit.date2numwith the requested dtype.- Return type
numpy.ndarrayof type dtype
- esmvalcore.iris_helpers.var_name_constraint(var_name)[source]
iris.Constraintusingvar_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.NameConstraintwith the argumentvar_nameinstead: this is an exact replacement.- Parameters
var_name (str) –
var_nameused for the constraint.- Returns
Constraint.
- Return type