improver.lightning module

Module containing lightning classes.

class LightningFromCapePrecip[source]

Bases: PostProcessingPlugin

Apply latitude-dependent thresholds to CAPE and precipitation rate to derive a presence-of-lightning cube.

Lightning is based on the presence of both CAPE and precipitation rate with thresholds varying linearly between

CAPE (J kg-1)

Precipitation rate (mm h-1)

Mid-latitudes (above 50 degrees N or S)

350

1

Tropics (below 10 degrees N or S)

500

4

_abc_impl = <_abc_data object>
static _get_inputs(cubes)[source]

Separates CAPE and precipitation rate cubes and checks that the following match: forecast_reference_time, spatial coords, time-bound interval and that CAPE time is at the lower bound of precipitation rate time. The precipitation rate data must represent a period of 1 or 3 hours.

Return type:

Tuple[Cube, Cube]

process(cubes, model_id_attr=None)[source]

From the supplied CAPE and precipitation-rate cubes, calculate a probability of lightning cube.

Parameters:
  • cubes (CubeList) – Cubes of CAPE and Precipitation rate.

  • model_id_attr (Optional[str]) – The name of the dataset attribute to be used to identify the source model when blending data from different models.

Return type:

Cube

Returns:

Cube of lightning data

Raises:

ValueError – If one of the cubes is not found or doesn’t match the other

latitude_to_threshold(latitude, midlatitude, tropics)[source]

Rescale a latitude range into a range of threshold values suitable for thresholding a different diagnostic. This is based on the value provided for that diagnostic at midlatitude (more than 50 degrees from the equator) and in the tropics (closer than 10 degrees from the equator). Varies linearly in between.

Parameters:
  • latitude (ndarray) – An array of latitude points (e.g. cube.coord(“latitude”).points)

  • midlatitude (float) – The threshold value to return above 50N or below 50S.

  • tropics (float) – The threshold value to return below 10N or above 10S.

Return type:

ndarray

Returns:

An array of thresholds, one for each latitude point