improver.blending.calculate_weights_and_blend module¶
Plugin to calculate blend weights and blend data across a dimension
-
class
improver.blending.calculate_weights_and_blend.WeightAndBlend(blend_coord, wts_calc_method, weighting_coord=None, wts_dict=None, y0val=None, ynval=None, cval=None, inverse_ordering=False)[source]¶ Bases:
improver.BasePluginWrapper class to calculate weights and blend data across cycles or models
-
__init__(blend_coord, wts_calc_method, weighting_coord=None, wts_dict=None, y0val=None, ynval=None, cval=None, inverse_ordering=False)[source]¶ Initialise central parameters
- Parameters
blend_coord (str) – Coordinate over which blending will be performed (eg “model” for grid blending)
wts_calc_method (str) – Weights calculation method (“linear”, “nonlinear” or “dict”)
weighting_coord (str) – Coordinate over which linear weights should be calculated (from dictionary)
wts_dict (dict) – Dictionary containing parameters for linear weights calculation
y0val (float) – Relative weight of first file for default linear weights plugin
ynval (float) – Relative weight of last file for default linear weights plugin
cval (float) – Parameter for default non-linear weights plugin
inverse_ordering (bool) – Option to invert weighting order for non-linear weights plugin so that higher blend coordinate values get higher weights (eg if cycle blending over forecast reference time).
-
_abc_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version= 213¶
-
_abc_registry= <_weakrefset.WeakSet object>¶
-
_calculate_blending_weights(cube)[source]¶ Wrapper for plugins to calculate blending weights by the appropriate method.
- Parameters
cube (iris.cube.Cube) – Cube of input data to be blended
- Returns
Cube containing 1D array of weights for blending
- Return type
-
_update_spatial_weights(cube, weights, fuzzy_length)[source]¶ Update weights using spatial information
- Parameters
cube (iris.cube.Cube) – Cube of input data to be blended
weights (iris.cube.Cube) – Initial 1D cube of weights scaled by self.weighting_coord
fuzzy_length (float) – Distance (in metres) over which to smooth weights at domain boundaries
- Returns
Updated 3D cube of spatially-varying weights
- Return type
-
process(cubelist, cycletime=None, model_id_attr=None, spatial_weights=False, fuzzy_length=20000, attributes_dict=None)[source]¶ Merge a cubelist, calculate appropriate blend weights and compute the weighted mean. Returns a single cube collapsed over the dimension given by self.blend_coord.
- Parameters
cubelist (iris.cube.CubeList) – List of cubes to be merged and blended
cycletime (str) – Forecast reference time to use for output cubes, in the format YYYYMMDDTHHMMZ. If not set, the latest of the input cube forecast reference times is used.
model_id_attr (str) – Name of the attribute by which to identify the source model and construct “model” coordinates for blending.
spatial_weights (bool) – If true, calculate spatial weights.
fuzzy_length (float) – Distance (in metres) over which to smooth spatial weights. Default is 20 km.
attributes_dict (dict or None) – Changes to cube attributes to be applied after blending
-