improver.utilities.time_lagging module#
Provide support utilities for time lagging ensembles
- class GenerateTimeLaggedEnsemble(rebadge_realizations=False)[source]#
Bases:
BasePluginCombine realizations from different forecast cycles into one cube.
If a cube has no
realizationcoordinate, one is added. For example: If you provide two deterministic cubes, the output will have realization coordinates [0, 1].For fully deterministic input (no realization coordinates on any cube), added realizations are assigned sequentially in input order (0, 1, 2, …).
For mixed input (some cubes have realizations and others do not), missing coordinates are added only to cubes that need them. For example: If you provide one deterministic and one ensemble cube, the deterministic cube will be assigned a new realization, while the ensemble cube retains its original realization numbers.
If this creates duplicate realization numbers across the combined inputs, all realization numbers are rebadged to a unique sequential set in input order before merging. For example: If two cubes both have realization 0, the output will have realizations [0, 1] (rebadged).
If
rebadge_realizations=Trueis set, the final output cube’s realization coordinate will always be sequentially numbered from 0. For example: If the merged cube has 3 realizations, they will be numbered [0, 1, 2] regardless of their original values.
- __init__(rebadge_realizations=False)[source]#
Initialise plugin.
- Parameters:
rebadge_realizations (
bool) – If True, rebadge realization points on the final merged cube to sequential values starting at 0.
- _abc_impl = <_abc._abc_data object>#
- _check_validity_times_match(cubelist)[source]#
Raise ValueError if cubes have mismatched validity times.
- Parameters:
cubelist (
CubeList) – List of input forecasts.- Raises:
ValueError – If input cubes have mismatched validity times.
- Return type:
- _rebadge_duplicate_realizations(cubelist)[source]#
If duplicate realization numbers exist across the cubelist, rebadge all realization numbers to a unique sequential set in input order.
- add_realization_coord(cubelist)[source]#
Add a realization coordinate to each cube in the cubelist if not already present. This facilitates the creation of a time-lagged ensemble from deterministic forecasts.
- process(*cubes)[source]#
Take an input cubelist containing forecasts from different cycles and merges them into a single cube.
- The steps taken are:
Update forecast reference time and period to match the latest contributing cycle.
Check for duplicate realization numbers. If a duplicate is found, renumber all of the realizations uniquely.
Concatenate into one cube along the realization axis.
- Parameters:
cubelist – List of input forecasts
- Return type:
- Returns:
Concatenated forecasts
- Warns:
UserWarning – If only a single cube is provided, so time lagging will have
no effect.