improver.metadata.probabilistic module
Utilities for interrogating IMPROVER probabilistic metadata
- _extract_diagnostic_name(cube_name, check_vicinity=False)[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 namecheck_vicinity (
bool
) – If False the function will return X as described above, which matches the name of the threshold-type coordinate on the cube. If True, the cube name is checked to see whether it is a vicinity diagnostic, and if so the function returns “X_in.*_vicinity”. This is the name of the equivalent diagnostic in percentile or realization space.
- Return type:
- Returns:
The name of the diagnostic underlying this probability
- Raises:
ValueError – If the input name does not match the expected regular expression (ie if cube_name_regex(cube_name) returns None).
- find_percentile_coordinate(cube)[source]
Find percentile coord in cube.
- Parameters:
cube (
Cube
) – Cube contain one or more percentiles.- Return type:
- Returns:
Percentile coordinate.
- 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.
- 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.
- format_cell_methods_for_diagnostic(cube)[source]
Remove reference to threshold-type coordinate from cell method comments that were previously on a probability cube. Modifies cube in place.
- format_cell_methods_for_probability(cube, threshold_name)[source]
Update cell methods on a diagnostic cube to reflect the fact that the data to which they now refer is on a coordinate. Modifies cube in place.
- get_diagnostic_cube_name_from_probability_name(cube_name)[source]
Get the name of the original diagnostic cube, including vicinity, from the name of the probability cube.
- Return type:
- get_threshold_coord_name_from_probability_name(cube_name)[source]
Get the name of the threshold coordinate from the name of the probability cube. This can be used to set or modify a threshold coordinate name after renaming or conversion from probabilities to percentiles / realizations.
- Return type:
- 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.
- is_percentile(cube)[source]
Determines whether a cube contains probability data at a range of percentiles.
- is_probability(cube)[source]
Determines whether a cube contains probability data at a range of thresholds.
- 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’).