improver.spotdata.apply_lapse_rate module

Apply temperature lapse rate adjustments to a spot data cube.

class SpotLapseRateAdjust(neighbour_selection_method='nearest', fixed_lapse_rate=None)[source]

Bases: PostProcessingPlugin

Adjusts spot data temperatures by a lapse rate to better represent the conditions at their altitude that may not be captured by the model orography.

__init__(neighbour_selection_method='nearest', fixed_lapse_rate=None)[source]
Parameters:
  • neighbour_selection_method (str) –

    The neighbour cube may contain one or several sets of grid coordinates that match a spot site. These are determined by the neighbour finding method employed. This keyword is used to extract the desired set of coordinates from the neighbour cube. The methods available will be all, or a subset, of the following:

    - nearest
    - nearest_land
    - nearest_land_minimum_dz
    - nearest_minimum_dz
    

    The method available in a neighbour cube will depend on the options that were specified when it was created.

  • fixed_lapse_rate (Optional[float]) – A float value that is the lapse rate to apply to all sites. This can be used instead of providing a gridded lapse rate cube. Value is given in Kelvin / metre of temperature change with ascent. For example a dry adiabatic lapse rate would be given as -0.0098.

_abc_impl = <_abc_data object>
_check_inputs(spot_data_cube, neighbour_cube, gridded_lapse_rate_cube)[source]

Checks cubes for compatibility, raising Exceptions as appropriate.

Raises:
  • ValueError – If the spot_data_cube are probabilities.

  • ValueError – If the lapse rate cube was provided but the diagnostic being processed is not air temperature or feels-like temperature.

  • ValueError – If neither or both a lapse rate cube and a fixed lapse rate are provided.

  • ValueError – If the lapse rate cube provided does not have the name “air_temperature_lapse_rate”

  • ValueError – If the lapse rate cube does not contain a single valued height coordinate or the heights do not match the spot_data_cube.

broadcast_fixed_lapse_rate(spot_data_cube)[source]

Create an array of fixed lapse rate values

Return type:

ndarray

get_gridded_lapse_rate(spot_data_cube, neighbour_cube, gridded_lapse_rate_cube=None)[source]

Extract the lapse rates that correspond to the spot sites and broadcast to the spot data shape.

Return type:

ndarray

process(spot_data_cube, neighbour_cube, gridded_lapse_rate_cube=None)[source]

Extract lapse rates from the appropriate grid points and apply them to the spot extracted temperatures.

The calculation is:

lapse_rate_adjusted_temperatures = temperatures + lapse_rate *
vertical_displacement
Parameters:
  • spot_data_cube (Cube) – A spot data cube of temperatures for the spot data sites, extracted from the gridded temperature field. These temperatures will have been extracted using the same neighbour_cube and neighbour_selection_method that are being used here.

  • neighbour_cube (Cube) – The neighbour_cube that contains the grid coordinates at which lapse rates should be extracted and the vertical displacement between those grid points on the model orography and the spot data sites actual altitudes. This cube is only updated when a new site is added.

  • gridded_lapse_rate_cube (Optional[Cube]) – A cube of temperature lapse rates on the same grid as that from which the spot data temperatures were extracted. If not provided a fixed lapse rate must have been specified.

Return type:

Cube

Returns:

A copy of the input spot_data_cube with the data modified by the lapse rates to give a better representation of the site’s temperatures.

extract_vertical_displacements(neighbour_cube, neighbour_selection_method_name)[source]

Extract vertical displacements between the model orography and sites.

Return type:

Cube