improver.cli.realization_selection module

Contents

improver.cli.realization_selection module#

Script to select realizations based on clustering results.

process(*cubes, forecast_period, model_id_attr='mosg__model_configuration', cycletime=None, selection_attr=None, selection_attr_value='cluster_medoid')[source]#

Select realizations from input forecast cubes according to cluster assignments.

Parameters:
  • cubes (list of Cube) – List of input cubes, including forecast cubes and a cluster cube. The cluster cube is identified by the presence of the “primary_input_realization_to_cluster_medoid” attribute.

  • forecast_period (int) – The forecast period (in seconds) to use for interrogating the cluster mapping attributes in order to select the appropriate realizations.

  • model_id_attr (str) – The name of the cube attribute used to identify the model source.

  • cycletime (str) – The forecast_reference_time on the input forecast cubes will be reset to this value. The forecast periods will be adjusted accordingly with the validity times kept fixed. cycletime should be provided in the format YYYYMMDDTHHMMZ (e.g., 20240101T0000Z). If not provided, the forecast_reference_time on the input cubes will be left unchanged.

  • selection_attr (str) – Optional name of a cube attribute to add to the output to identify that these realizations were selected using this plugin. If not provided, no attribute is added.

  • selection_attr_value (str) – The value to assign to the selection_attr attribute. Default is “cluster_medoid”.

Returns:

A merged Cube containing the selected realizations, with realization indices matching the cluster indices.

Return type:

Cube