improver.metadata.probabilistic module

Utilities for interrogating IMPROVER probabilistic metadata

improver.metadata.probabilistic.extract_diagnostic_name(cube_name)[source]

Extract the standard or long name X of the diagnostic from a probability cube name of the form ‘probability_of_X_above/below_threshold’, ‘probability_of_X_between_thresholds’, or ‘probability_of_X_in_vicinity_above/below_threshold’.

Parameters

cube_name (str) – The probability cube name

Returns

The name of the diagnostic underlying this probability

Return type

str

Raises

ValueError – If the input name does not match the expected regular expression (ie if cube_name_regex(cube_name) returns None).

improver.metadata.probabilistic.find_percentile_coordinate(cube)[source]

Find percentile coord in cube.

Parameters

cube (iris.cube.Cube) – Cube contain one or more percentiles.

Returns

Percentile coordinate.

Return type

iris.coords.Coord

Raises
  • TypeError – If cube is not of type iris.cube.Cube.

  • CoordinateNotFoundError – If no percentile coordinate is found in cube.

  • ValueError – If there is more than one percentile coords in the cube.

improver.metadata.probabilistic.find_threshold_coordinate(cube)[source]

Find threshold coordinate in cube.

Compatible with both the old (cube.coord(“threshold”)) and new (cube.coord.var_name == “threshold”) IMPROVER metadata standards.

Parameters

cube (iris.cube.Cube) – Cube containing thresholded probability data

Returns

Threshold coordinate

Return type

iris.coords.Coord

Raises
  • TypeError – If cube is not of type iris.cube.Cube.

  • CoordinateNotFoundError – If no threshold coordinate is found.

improver.metadata.probabilistic.in_vicinity_name_format(cube_name)[source]

Generate the correct name format for an ‘in_vicinity’ probability cube, taking into account the ‘above/below_threshold’ or ‘between_thresholds’ suffix required by convention.

Parameters

cube_name (str) – The non-vicinity probability cube name to be formatted.

Returns

Correctly formatted name following the accepted convention e.g. ‘probability_of_X_in_vicinity_above_threshold’.

Return type

str

improver.metadata.probabilistic.probability_cube_name_regex(cube_name)[source]

Regular expression matching IMPROVER probability cube name. Returns None if the cube_name does not match the regular expression (ie does not start with ‘probability_of’).

Parameters

cube_name (str) – Probability cube name