improver.precipitation_type.snow_fraction module

Module containing the SnowFraction class.

class SnowFraction(model_id_attr=None)[source]

Bases: PostProcessingPlugin

Calculates a snow-fraction field from fields of snow and rain (rate or accumulation). Where no precipitation is present, the data are filled in from the nearest precipitating point.

snow_fraction = snow / (snow + rain)

__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_snow_fraction()[source]

Calculates the snow fraction data and interpolates to fill in the missing points.

Return type:

Cube

Returns:

Snow fraction cube.

static _get_input_cube_names(input_cubes)[source]

Identifies the rain and snow cubes from the presence of “rain” or “snow” in the cube names.

Parameters:

input_cubes (CubeList) – The unsorted rain and snow cubes.

Return type:

Tuple[str, str]

Returns:

rain_name and snow_name, in that order.

_get_input_cubes(input_cubes)[source]
Separates out the rain and snow cubes from the input list and checks that
  • No other cubes are present

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

  • Cubes have compatible units

  • Cubes have same dimensions

  • Cubes are not masked (or are masked with an all-False mask)

Parameters:

input_cubes (CubeList) – Contains exactly two cubes, one of rain and one of snow. Both must be either rates or accumulations of the same length and of compatible units.

Raises:

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

Return type:

None

process(input_cubes)[source]

Check input cubes, then calculate and interpolate a snow fraction cube.

Parameters:

input_cubes (CubeList) – Contains cubes of rain and snow, both must be either rates or accumulations.

Return type:

Cube

Returns:

Cube of snow-fraction. The data within this cube will contain values between 0 and 1. Points where no precipitation is present will be filled using a nearest-neighbour interpolation.

The cube meta-data will contain: * Input_cube name “snow_fraction” * Cube units set to (1).

Raises:

ValueError – if input cubes fail any comparison tests.