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

class LightningMultivariateProbability_USAF2024[source]

Bases: PostProcessingPlugin

The algorithm outputs the probability of at least one lightning strike within 20 km of the location in a three hour period. The probabilities are calculated for each individual ensemble member, and then they are averaged for the ensemble probability forecast.

Inputs: Convective Available Potential Energy (CAPE in J/kg. Most Unstable CAPE is ideal and was used to determine the regression statistics, but surface-based CAPE is supported and yields similar results but will not forecast elevated convection.) Lifted Index (liftind in K) Precipitable Water (pwat in kg m-2 or mm. This is used as mm in the regression equations) Convective Inhibition (CIN in J/kg) 3-hour Accumulated Precipitation (apcp in kg m-2 or millimetres) Outputs: 20 km lightning probability over the valid time of the accumulated precipitation

Description of the algorithm:

Regression equation when CAPE and APCP are greater than zero: lprob= cape*APCP lprob=0.13*ln(lprob+0.7)+0.05

If APCP is very low, a separate regression equation is used to predict lightning probability. The definition of “very low” is raised slightly when PWAT values are high. This is because the model often produces showery precipitation that doesn’t access the actual instability in very moist environments: lprob_noprecip=CAPE/(CIN+100.0) lprob_noprecip=0.025*ln(lprob_noprecip+0.31)+0.03 APCP=APCP-(PWAT/1000)

IF APCP is less than 0.01 inches THEN lprob=lprob_noprecip If there is no CAPE but the atmosphere is “close” to unstable, lightning does sometimes occur, especially when heavy precipitation may have stabilized the atmosphere in the model. Unstable values of lifted index are positive here: LIFTIDX=LIFTIDX+4.0 IF LIFTIDX is less than 0 K THEN LIFTIDX=0.0 IF CAPE<=0 J/kg THEN lprob=0.2*(LIFTIDX*APCP)^0.5

Finally, the probability of lightning is reduced when there is not much PW, because graupel cannot form and start the whole charging process. Therefore we reduce the probability: IF PWAT is less than 20 mm THEN lprob=lprob*(PWAT/20.0)

Limit final probabilities to 95% as that is as skillful as the regression equations could get: IF lprob is greater than 0.95 THEN lprob=0.95

_abc_impl = <_abc_data object>
static _extract_input(cubes, cube_name)[source]

Extract the relevant cube based on the cube name.

Parameters:
  • cubes (CubeList) – Cubes from which to extract required input.

  • cube_name (str) – Name of cube to extract.

Return type:

Cube

Returns:

The extracted cube.

_get_inputs(cubes)[source]

Separates CAPE, LI, PW, CIN, and APCP 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 accumulation time.

Return type:

Tuple[Cube, Cube]

process(cubes, model_id_attr=None)[source]

From the supplied CAPE, Lifted Index, Precipitable Water, CIN, and 3-hr Accumulated Precipitation cubes, calculate a probability of lightning cube.

Parameters:
  • cubes (CubeList) – Cubes of CAPE, Lifted Index, Precipitable Water, CIN, and 3-hr Accumulated Precipitation cubes.

  • 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, doesn’t match the others, or has incorrect units

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