improver.utilities.cube_constraints module

Module for helping to create Iris constraints.

create_sorted_lambda_constraint(coord_name, values, tolerance=1e-07)[source]

Create a lambda constraint for a range. This formulation of specifying a lambda constraint has the benefit of not needing to hardcode the name for the coordinate, so that this can be determined at runtime.

The created function uses float values. As a result, a small tolerance is used to spread the ends of the ranges to help with float equality matching. Note that the relative tolerance will not affect values of zero. Adding/subtracting an absolute tolerance is not done due to the difficulty of selecting an appropriate value given the very small values of precipitation rates expressed in m s-1.

Parameters:
  • coord_name (str) – Name of the coordinate.

  • values (List[float]) – A list of two values that represent the inclusive end points of a range.

  • tolerance (float) – A relative tolerance value to ensure equivalence matching when using float32 values. Values of zero will be unchanged.

Return type:

Constraint

Returns:

Constraint representative of a range of values.