improver.blending.blend_across_adjacent_points module

Module containing Blending classes that blend over adjacent points, as opposed to collapsing the whole dimension.

class improver.blending.blend_across_adjacent_points.TriangularWeightedBlendAcrossAdjacentPoints(coord, central_point, parameter_units, width, weighting_mode)[source]

Bases: object

Apply a Weighted blend to a coordinate, using triangular weights at each point in the coordinate. Returns a cube with the same coordinates as the input cube, with each point in the coordinate of interest having been blended with the adjacent points according to a triangular weighting function of a specified width.

There are two modes of blending:

  1. Weighted mean across the dimension of interest.
  2. Weighted maximum across the dimension of interest, where probabilities are multiplied by the weights and the maximum is taken.
__init__(coord, central_point, parameter_units, width, weighting_mode)[source]

Set up for a Weighted Blending plugin

Parameters:
  • coord (string) – The name of a coordinate dimension in the cube that we will blend over.
  • central_point (float or int) – Central point at which the output from the triangular weighted blending will be calculated.
  • parameter_units (string) – The units of the width of the triangular weighting function and the units of the central_point. This does not need to be the same as the units of the coordinate we are blending over, but it should be possible to convert between them.
  • width (float) – The width of the triangular weighting function we will use to blend.
  • weighting_mode (string) – The mode of blending, either weighted_mean or weighted_maximum. Weighted average finds the weighted mean across the dimension of interest. Maximum probability multiplies the values across the dimension of interest by the given weights and returns the maximum value.
Raises:

ValueError – If an invalid weighting_mode is given

_find_central_point(cube)[source]

Find the cube that contains the central point, otherwise, raise an exception.

Parameters:cube (iris.cube.Cube) – Cube containing input for blending.
Returns:Cube containing central point.
Return type:central_point_cube (iris.cube.Cube)
Raises:ValueError – Central point is not available within the input cube.
process(cube)[source]

Apply the weighted blend for each point in the given coordinate.

Parameters:cube (iris.cube.Cube) – Cube containing input for blending.
Returns:The processed cube, with the same coordinates as the input central_cube. The points in one coordinate will be blended with the adjacent points based on a triangular weighting function of the specified width.
Return type:blended_cube (iris.cube.Cube)