improver.between_thresholds module

Plugin to calculate probabilities of occurrence between specified thresholds

class OccurrenceBetweenThresholds(threshold_ranges, threshold_units)[source]

Bases: PostProcessingPlugin

Calculate the probability of occurrence between thresholds

__init__(threshold_ranges, threshold_units)[source]

Initialise the class. Threshold ranges must be specified in a unit that is NOT sensitive to differences at the 1e-5 (float32) precision level.

Parameters:
  • threshold_ranges (List[List[float]]) – List of 2-item iterables specifying thresholds between which probabilities should be calculated

  • threshold_units (str) – Units in which the thresholds are specified

Raises:

ValueError – If any of the specified thresholds are indistinguishable at the 1e-5 (float32) precision level

_abc_impl = <_abc_data object>
_calculate_probabilities()[source]

Calculate between_threshold probabilities cube

Return type:

Cube

Returns:

Merged cube containing recalculated probabilities

_get_multiplier()[source]

Check whether the cube contains “above” or “below” threshold probabilities. For “above”, the probability of occurrence between thresholds is the difference between probabilities at the lower and higher thresholds: P(lower) - P(higher). For “below” it is the inverse of this: P(higher) - P(lower), which is implemented by multiplying the difference by -1.

Return type:

float

Returns:

  1. or -1.

Raises:

ValueError – If the spp__relative_to_threshold attribute is not recognised

_slice_cube()[source]

Extract required slices from input cube

Return type:

List[List[Cube]]

Returns:

List of 2-item lists containing lower and upper threshold cubes

Raises:

ValueError – If any of the required constraints returns None

_update_metadata(output_cube, original_units)[source]

Update output cube name and threshold coordinate

Parameters:
  • output_cube (Cube) – Cube containing new “between_thresholds” probabilities

  • original_units (Unit) – Required threshold-type coordinate units

Return type:

None

process(cube)[source]

Calculate probabilities between thresholds for the input cube

Parameters:

cube (Cube) – Probability cube containing thresholded data (above or below)

Return type:

Cube

Returns:

Cube containing probability of occurrence between thresholds