improver.utilities.deterministic_realization_selector module#
Module containing a deterministic realization selector.
- class DeterministicRealizationSelector(target_realization_number=0, attribute='primary_input_realizations_to_clusters')[source]#
Bases:
PostProcessingPluginPlugin to extract a deterministic realization from a set of realizations that have been clustered using the improver.clustering.realization_clustering plugin.
- __init__(target_realization_number=0, attribute='primary_input_realizations_to_clusters')[source]#
Initialise the plugin.
- _abc_impl = <_abc._abc_data object>#
- static extract_cluster_from_cube(target_key, forecast_cube)[source]#
Extract the cluster containing the target realization. This cube becomes our deterministic realization.
- find_target_key(cluster_cube)[source]#
Find the key (cluster) of the cluster cube, that contains the target realization. This cluster will become the deterministic realization.
- process(cubes)[source]#
Extracts the target deterministic realization from the forecast cubes. Identifies the cluster cube, (containing the attribute: “primary_input_realizations_to_clusters”) and the forecast cube from the input cubelist. Determines the target realization, and its cluster, extracts this from the forecast cube and returns the deterministic_realization_cube.
- Parameters:
cubes (
CubeList) – A list of two cubes containing a forecast and a cluster cube. The cluster cube will contain the attribute: “primary_input_realizations_to_clusters”. This will be used to split the forecasts and cluster cube and determine which realizations to extract from the forecast cube.- Return type:
- Returns:
Forecast cube containing only the cluster with the target realization.
This cluster becomes our deterministic realization.
- Raises:
If the target realization, does not exist or cannot be extracted.
- split_input_cubelist(input_cubelist)[source]#
Splits the input cubelist into two cubes, depending on whether they contain the attribute:”primary_input_realizations_to_clusters”.
- Parameters:
input_cubelist (
CubeList) – A list of cubes containing two cubes with only one which contains the attribute: “primary_input_realizations_to_clusters”.- Returns:
“primary_input_realizations_to_clusters”. - Cube, to be the forecast_cube, which doesn’t contain the attribute: “primary_input_realizations_to_clusters”.
- Return type:
Cube, to be the cluster_cube, which contains the attribute
- Raises:
If the input cubelist contains more than two cubes. - If the forecast_cube or cluster_cube cannot be found in the input.