improver.lapse_rate module

Module containing lapse rate calculation plugins.

class ApplyGriddedLapseRate[source]

Bases: PostProcessingPlugin

Class to apply a lapse rate adjustment to a temperature data forecast

_abc_impl = <_abc_data object>
_calc_orog_diff(source_orog, dest_orog)[source]

Get difference in orography heights, in metres

Parameters:
  • source_orog (Cube) – 2D cube of source orography heights (units modified in place)

  • dest_orog (Cube) – 2D cube of destination orography heights (units modified in place)

Return type:

Cube

Returns:

The difference cube

static _check_dim_coords(temperature, lapse_rate)[source]

Throw an error if the dimension coordinates are not the same for temperature and lapse rate cubes

Parameters:
  • temperature (Cube) –

  • lapse_rate (Cube) –

Return type:

None

process(temperature, lapse_rate, source_orog, dest_orog)[source]

Applies lapse rate correction to temperature forecast. All cubes’ units are modified in place.

Parameters:
  • temperature (Cube) – Input temperature field to be adjusted

  • lapse_rate (Cube) – Cube of pre-calculated lapse rates

  • source_orog (Cube) – 2D cube of source orography heights

  • dest_orog (Cube) – 2D cube of destination orography heights

Return type:

Cube

Returns:

Lapse-rate adjusted temperature field, in Kelvin

class LapseRate(max_height_diff=35, nbhood_radius=7, max_lapse_rate=0.0294, min_lapse_rate=-0.0098)[source]

Bases: BasePlugin

Plugin to calculate the lapse rate from orography and temperature cubes.

References

The method applied here is based on the method used in the 2010 paper: https://rmets.onlinelibrary.wiley.com/doi/abs/10.1002/met.177

Code methodology:

  1. Apply land/sea mask to temperature and orography datasets. Mask sea points as NaN since image processing module does not recognise Numpy masks.

  2. Creates “views” of both datasets, where each view represents a neighbourhood of points. To do this, each array is padded with NaN values to a width of half the neighbourhood size.

  3. For all the stored orography neighbourhoods - take the neighbours around the central point and create a mask where the height difference from the central point is greater than 35m.

  4. Loop through array of neighbourhoods and take the height and temperature of all grid points and calculate the temperature/height gradient = lapse rate

  5. Constrain the returned lapse rates between min_lapse_rate and max_lapse_rate. These default to > DALR and < -3.0*DALR but are user configurable

__init__(max_height_diff=35, nbhood_radius=7, max_lapse_rate=0.0294, min_lapse_rate=-0.0098)[source]

The class is called with the default constraints for the processing code.

Parameters:
  • max_height_diff (float) – Maximum allowable height difference between the central point and points in the neighbourhood over which the lapse rate will be calculated (metres). The default value of 35m is from the referenced paper.

  • nbhood_radius (int) – Radius of neighbourhood around each point. The neighbourhood will be a square array with side length 2*nbhood_radius + 1. The default value of 7 is from the referenced paper.

  • max_lapse_rate (float) – Maximum lapse rate allowed.

  • min_lapse_rate (float) – Minimum lapse rate allowed.

_abc_impl = <_abc_data object>
_create_windows(temp, orog)[source]

Uses neighbourhood tools to pad and generate rolling windows of the temp and orog datasets.

Parameters:
  • temp (ndarray) – 2D array (single realization) of temperature data, in Kelvin

  • orog (ndarray) – 2D array of orographies, in metres

Return type:

Tuple[ndarray, ndarray]

Returns:

  • Rolling windows of the padded temperature dataset.

  • Rolling windows of the padded orography dataset.

_generate_lapse_rate_array(temperature_data, orography_data, land_sea_mask_data)[source]

Calculate lapse rates and apply filters

Parameters:
  • temperature_data (ndarray) – 2D array (single realization) of temperature data, in Kelvin

  • orography_data (ndarray) – 2D array of orographies, in metres

  • land_sea_mask_data (ndarray) – 2D land-sea mask

Return type:

ndarray

Returns:

Lapse rate values

process(temperature, orography, land_sea_mask, model_id_attr=None)[source]

Calculates the lapse rate from the temperature and orography cubes.

Parameters:
  • temperature (Cube) – Cube of air temperatures (K).

  • orography (Cube) – Cube containing orography data (metres)

  • land_sea_mask (Cube) – Cube containing a binary land-sea mask. True for land-points and False for Sea.

  • model_id_attr (Optional[str]) – Name of the attribute used to identify the source model for blending. This is inherited from the input temperature cube.

Return type:

Cube

Returns:

Cube containing lapse rate (K m-1)

Raises:
  • TypeError – If input cubes are not cubes:

  • ValueError – If input cubes are the wrong units.:

compute_lapse_rate_adjustment(lapse_rate, orog_diff, max_orog_diff_limit=50)[source]

Compute the lapse rate adjustment i.e. the lapse rate multiplied by the relevant orographic difference. The lapse rate is assumed to be appropriate for a fixed vertical displacement between the source and destination orographies. If the the vertical displacement is greater than the limit specified, further vertical ascent or descent is assumed to follow the environmental lapse rate (also known as standard atmosphere lapse rate). Note that this is an extension of Sheridan et al., 2018, which applies this vertical displacement limit for positive lapse rates only.

For the specific case of a deep unresolved valley with a positive lapse rate at the altitude of the source orography, the atmosphere can be imagined to be compartmentalised into two regions. Firstly, a cold pool section that extends below the altitude of the source orography by the value given by the max orography difference specified (70 m in Sheridan et al., 2018) and secondly, a standard atmosphere section for the remaining orographic difference. The total lapse rate adjustment is the sum of the contributions from these two vertical sections.

References

Sheridan, P., S. Vosper, and S. Smith, 2018: A Physically Based Algorithm for Downscaling Temperature in Complex Terrain. J. Appl. Meteor. Climatol., 57, 1907–1929, https://doi.org/10.1175/JAMC-D-17-0140.1.

Parameters:
  • lapse_rate (ndarray) – Array containing lapse rate in units of K/m.

  • orog_diff (ndarray) – Array containing the difference in orography (destination orography minus source orography) in metres.

  • max_orog_diff_limit (float) – Maximum vertical displacement in metres to be corrected using the lapse rate provided. Vertical displacement in excess of this value will be corrected using the environmental lapse rate (also known as standard atmosphere lapse rate). This defaults to 50. Sheridan et al. use 70 m. As lapse rate adjustment could be performed both for gridded data and for site data in sequence, the adjustments could accumulate. To limit the possible cumulative effect from multiple lapse rate corrections, a default lower than 70m has been chosen.

Return type:

ndarray

Returns:

The vertical lapse rate adjustment to be applied to correct a temperature forecast in units of K.