improver.cli.weighted_blending module

Script to run weighted blending.

process(*cubes, coordinate, weighting_method='linear', weighting_coord='forecast_period', weighting_config=None, attributes_config=None, cycletime=None, y0val=None, ynval=None, cval=None, model_id_attr=None, record_run_attr=None, spatial_weights_from_mask=False, fuzzy_length=20000.0)[source]

Runs weighted blending.

Check for inconsistent arguments, then calculate a weighted blend of input cube data using the options specified.

Parameters:
  • cubes (iris.cube.CubeList) – Cubelist of cubes to be blended.

  • coordinate (str) – The coordinate over which the blending will be applied.

  • weighting_method (str) – Method to use to calculate weights used in blending. “linear” (default): calculate linearly varying blending weights. “nonlinear”: calculate blending weights that decrease exponentially with increasing blending coordinates. “dict”: calculate weights using a dictionary passed in.

  • weighting_coord (str) – Name of coordinate over which linear weights should be scaled. This coordinate must be available in the weights dictionary.

  • weighting_config (dict or None) – Dictionary from which to calculate blending weights. Dictionary format is as specified in improver.blending.weights.ChoosingWeightsLinear

  • attributes_config (dict) – Dictionary describing required changes to attributes after blending

  • cycletime (str) – The forecast reference time to be used after blending has been applied, in the format YYYYMMDDTHHMMZ. If not provided, the blended file takes the latest available forecast reference time from the input datasets supplied.

  • y0val (float) – The relative value of the weighting start point (lowest value of blend coord) for choosing default linear weights. If used this must be a positive float or 0.

  • ynval (float) – The relative value of the weighting end point (highest value of blend coord) for choosing default linear weights. This must be a positive float or 0. Note that if blending over forecast reference time, ynval >= y0val would normally be expected (to give greater weight to the more recent forecast).

  • cval (float) – Factor used to determine how skewed the non-linear weights will be. A value of 1 implies equal weighting.

  • model_id_attr (str) – The name of the dataset attribute to be used to identify the source model when blending data from different models.

  • record_run_attr (Optional[str]) – The name of the dataset attribute to be used to store model and cycle sources in metadata, e.g. when blending data from different models. Requires model_id_attr.

  • spatial_weights_from_mask (bool) – If True, this option will result in the generation of spatially varying weights based on the masks of the data we are blending. The one dimensional weights are first calculated using the chosen weights calculation method, but the weights will then be adjusted spatially based on where there is masked data in the data we are blending. The spatial weights are calculated using the SpatiallyVaryingWeightsFromMask plugin.

  • fuzzy_length (float) – When calculating spatially varying weights we can smooth the weights so that areas close to areas that are masked have lower weights than those further away. This fuzzy length controls the scale over which the weights are smoothed. The fuzzy length is in terms of m, the default is 20km. This distance is then converted into a number of grid squares, which does not have to be an integer. Assumes the grid spacing is the same in the x and y directions and raises an error if this is not true. See SpatiallyVaryingWeightsFromMask for more details.

Returns:

Merged and blended Cube.

Return type:

iris.cube.Cube

Raises:
  • RuntimeError – If calc_method is linear and cval is not None.

  • RuntimeError – If calc_method is nonlinear and either y0val and ynval is not None.

  • RuntimeError – If calc_method is dict and weights_dict is None.