improver.utilities.gradient_between_vertical_levels module#
Calculate the gradient between two vertical levels.
- class GradientBetweenVerticalLevels[source]#
Bases:
BasePluginCalculate the gradient between two vertical levels. The gradient is calculated as the difference between the input cubes divided by the difference in height.
- _abc_impl = <_abc._abc_data object>#
- static extract_cube_from_list(cubes, name)[source]#
Extract a cube from a cubelist based on the name if it exists. If the cube is found it is removed from the cubelist.
- gradient_over_vertical_levels(cubes, geopotential_height, orography)[source]#
Calculate the gradient between two vertical levels. The gradient is calculated as the difference between the two cubes in cubes divided by the difference in height.
If the cubes are provided at height levels this is assumed to be a height above ground level and the height above sea level is calculated by adding the height of the orography to the height coordinate. If the cubes are provided at pressure levels, the height above sea level is extracted from a geopotential_height cube. If both cubes have a height coordinate then no additional cubes are required.
- Parameters:
cubes (
CubeList) – Two cubes containing a diagnostic at two different vertical levels. The cubes must contain either a height or pressure scalar coordinate. If the cubes contain a height scalar coordinate this is assumed to be a height above ground level.geopotential_height (
Optional[Cube]) – Optional cube that contains the height above sea level of pressure levels. This cube is required if any input cube is defined at pressure level. This is used to extract the height above sea level at the pressure level of the input cubes.orography (
Optional[Cube]) – Optional cube containing the orography height above sea level. This cube is required if exactly one input cube is defined at height levels and is used to convert the height above ground level to height above sea level.
- Return type:
- Returns:
A cube containing the gradient between the cubes between two vertical levels.
- Raises:
ValueError – If exactly one input cube is defined at height levels and no orography cube is provided.
ValueError – If either input cube is defined at pressure levels and no geopotential_height cube is provided.
- process(*cubes)[source]#
Process the input cubes to calculate the gradient between two vertical levels.
- Parameters:
cubes (
CubeList) – A cubelist of two cubes containing a diagnostic at two vertical levels. The cubes must contain either a height or pressure scalar coordinate. If exactly one of the cubes contain a height scalar coordinate this is assumed to be a height above ground level and a cube with the name “surface_altitude” must also be provided. If either cube contains a pressure scalar coordinate a cube with the name “geopotential_height” must be provided.If both cubes are on height levels then no additional cubes are required.- Return type:
- Returns:
A cube containing the gradient between two vertical levels. The cube will be named gradient of followed by the name of the input cubes.