improver.utilities.ancillary_creation module

class improver.utilities.ancillary_creation.OrographicAlphas(min_alpha=0.0, max_alpha=1.0, coefficient=1, power=1, invert_alphas=True)[source]

Bases: object

Class to generate alpha smoothing parameters for recursive filtering based on orography gradients.

__init__(min_alpha=0.0, max_alpha=1.0, coefficient=1, power=1, invert_alphas=True)[source]

Initialise class.

Parameters:
  • min_alpha (float) – The minimum value of alpha that you want to go into the recursive filter.
  • max_alpha (float) – The maximum value of alpha that you want to go into the recursive filter
  • coefficient (float) – The coefficient for the alpha calculation
  • power (float) – What power you want for your alpha equation
gradient_to_alpha(gradient_x, gradient_y)[source]

Generate alpha smoothing parameters from orography gradients in the x- and y- directions

Parameters:
  • gradient_x (iris.cube.Cube) – A cube of the normalised gradient in the x direction
  • gradient_y (iris.cube.Cube) – A cube of the normalised gradient in the y direction
Returns:

tuple containing

alpha_x (iris.cube.Cube) - A cube of orography-dependent

alphas calculated in the x direction.

alpha_y (iris.cube.Cube) - A cube of orography-dependent

alphas calculated in the y direction.

Return type:

(tuple)

process(cube)[source]

This creates the alpha cubes. It returns one for the x direction and one for the y direction. It uses the DifferenceBetweenAdjacentGridSquares plugin to calculate an average gradient across each grid square. These gradients are then used to calculate “alpha” smoothing arrays that are normalised between a user-specified max and min.

Parameters:cube (iris.cube.Cube) – A 2D cube of the orography for the grid we want to get alphas for.
Returns:tuple containing
alpha_x (iris.cube.Cube) - A cube of orography-dependent
alphas calculated in the x direction.
alpha_y (iris.cube.Cube) - A cube of orography-dependent
alphas calculated in the y direction.
Return type:(tuple)
static scale_alphas(cubes, min_output=0, max_output=1)[source]

This scales a set of alphas from input cubes to range between the minimum and maximum alpha values.

Parameters:
  • raw_alphas (iris.cube.Cubelist) – A list of alpha cubes that we need to take the cube_max and cube_min from.
  • min_output (float) – The minimum value we want our alpha to be
  • max_output (float) – The maximum value we want our alpha to be
Returns:

A list of alpha cubes scaled to within the range specified.

Return type:

scaled_cubes (iris.cube.CubeList)

unnormalised_alphas(gradient_cube)[source]

This generates initial alpha values from gradients using a generalised power law, whose parameters are set at initialisation. Current defaults give an output alphas_cube equal to the input gradient_cube.

Parameters:gradient_cube (iris.cube.Cube) – A cube of the normalised gradient
Returns:The cube of initial unscaled alphas
Return type:alphas_cube (iris.cube.Cube)
static update_alphas_metadata(alphas_cube)[source]

Update metadata in alphas cube. Remove any time coordinates and rename.

Parameters:alphas_cube (iris.cube.Cube) – A cube of alphas with “gradient” metadata
Returns:A cube of alphas with adjusted metadata
Return type:alphas_cube (iris.cube.Cube)
class improver.utilities.ancillary_creation.SaturatedVapourPressureTable(t_min=183.15, t_max=338.15, t_increment=0.1)[source]

Bases: object

Plugin to create a saturated vapour pressure lookup table.

__init__(t_min=183.15, t_max=338.15, t_increment=0.1)[source]

Initialise class.

Parameters:
  • t_min (float) – The minimum temperature for the range.
  • t_max (float) – The maximum temperature for the range.
  • t_increment (float) – The temperature increment at which to create values for the saturated vapour pressure between t_min and t_max.
process()[source]

Create a saturated vapour pressure lookup table by calling the Utilities.saturation_vapour_pressure_goff_gratch function in psychrometric_calculations.Utilities.

Returns:A cube of saturated vapour pressure values at temperature points defined by t_min, t_max, and t_increment (defined above).
Return type:svp (iris.cube.Cube)