improver.precipitation_type.freezing_rain module

Module containing the FreezingRain class.

class FreezingRain(model_id_attr=None)[source]

Bases: PostProcessingPlugin

Calculates a probability of freezing rain using rain, sleet and temperature probabilities.

__init__(model_id_attr=None)[source]

Initialise the class

Parameters:

model_id_attr (Optional[str]) – Name of the attribute used to identify the source model for blending.

_abc_impl = <_abc_data object>
_calculate_freezing_rain_probability(n_realizations)[source]

Calculate the probability of freezing rain from the probabilities of rain and sleet rates or accumulations, and the provided probabilities of temperature being below the freezing point of water.

If multiple realizations are present, the contribution of each realization is scaled by a (1 / n_realizations) factor to compute the mean across realizations. This approach is taken, as opposed to collapsing the realization coordinate later, to minimise the memory required.

(probability of rain + probability of sleet) x (probability T < 0C)

Parameters:

n_realizations (Optional[int]) – The number of realizations if using multi-realization data, else None.

Return type:

Cube

Returns:

Cube of freezing rain probabilities.

_extract_common_realizations()[source]

Picks out the realizations that are common to the rain, sleet, and temperature cubes.

Raises:

ValueError – If the input cubes have no shared realizations.

Return type:

None

_generate_template_cube(n_realizations)[source]

Generate a freezing rain cube with appropriate coordinates and metadata. The sleet cube is used as a basis for this to ensure that the lwe (liquid water equivalent) prefix is present in the output cube name.

Parameters:

n_realizations (Optional[int]) – The number of realizations if using multi-realization data, else None.

Return type:

Cube

Returns:

freezing_rain_cube

static _get_input_cube_names(input_cubes)[source]

Identifies the rain, sleet, and temperature cubes from the diagnostic names.

Parameters:

input_cubes (CubeList) – The unsorted rain, sleet, and temperature cubes.

Return type:

Tuple[str, str, str]

Returns:

rain_name, sleet_name, and temperature_name in that order.

Raises:
  • ValueError – If two input cubes have the same name.

  • ValueError – If rain, sleet, and temperature cubes cannot be distinguished by their names.

_get_input_cubes(input_cubes)[source]
Separates out the rain, sleet, and temperature cubes, checking that:
  • No other cubes are present

  • Cubes have same dimensions

  • Cubes represent the same time quantity (instantaneous or accumulation length)

  • Precipitation cube threshold units are compatible

  • Precipitation cubes have the same set of thresholds

  • A 273.15K (0 Celsius) temperature threshold is available

The temperature cube is also modified if necessary to return probabilties below threshold values. This data is then thinned to return only the probabilities of temperature being below the freezing point of water, 0 Celsius.

Parameters:

input_cubes (CubeList) – Contains exactly three cubes, a rain rate or accumulation, a sleet rate or accumulation, and an instantaneous or period temperature. Accumulations and periods must all represent the same length of time.

Raises:

ValueError – If any of the criteria above are not met.

Return type:

None

process(input_cubes)[source]

Check input cubes, then calculate a probability of freezing rain diagnostic. Collapses the realization coordinate if present.

Parameters:

input_cubes (CubeList) – Contains exactly three cubes, a rain rate or accumulation, a sleet rate or accumulation, and an instantaneous or period temperature. Accumulations and periods must all represent the same length of time.

Return type:

Cube

Returns:

Cube of freezing rain probabilties.