improver.between_thresholds module

Plugin to calculate probabilities of occurrence between specified thresholds

class improver.between_thresholds.OccurrenceBetweenThresholds(threshold_ranges, threshold_units)[source]

Bases: improver.BasePlugin

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 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_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 213
_abc_registry = <_weakrefset.WeakSet object>
_calculate_probabilities()[source]

Calculate between_threshold probabilities cube

Returns

Merged cube containing recalculated probabilities

Return type

iris.cube.Cube

_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.

Returns

  1. or -1.

Return type

float

Raises

ValueError – If the spp__relative_to_threshold attribute is not recognised

_slice_cube()[source]

Extract required slices from input cube

Returns

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

Return type

list or iris.cube.Cube

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 (iris.cube.Cube) – Cube containing new “between_thresholds” probabilities

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

process(cube)[source]

Calculate probabilities between thresholds for the input cube

Parameters

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

Returns

Cube containing probability of occurrence between thresholds

Return type

iris.cube.Cube