climpred.horizon.horizon

climpred.horizon.horizon(cond)[source]

Calculate the predictability horizon based on a condition `cond.

Parameters

cond (xr.DataArray, xr.Dataset) – User-defined boolean array where True means the system is predictable at the given lead. E.g., this could be based on the dynamical forecast beating a reference forecast, p values, confidence intervals, etc. cond should contain the dimension lead at the minimum.

Returns

xr.DataArray, xr.Dataset – predictability horizon reduced by lead dimension.

Example

>>> skill = PerfectModelEnsemble.verify(
...     metric="acc",
...     comparison="m2e",
...     dim=["init", "member"],
...     reference=["persistence"],
... )
>>> horizon(skill.sel(skill="initialized") > skill.sel(skill="persistence"))
<xarray.Dataset>
Dimensions:  ()
Data variables:
    tos      float64 15.0
Attributes:
    units:          years
    standard_name:  forecast_period
    long_name:      Lead
    description:    Forecast period is the time interval between the forecast...
>>> bskill = PerfectModelEnsemble.bootstrap(
...     metric="acc",
...     comparison="m2e",
...     dim=["init", "member"],
...     reference="uninitialized",
...     iterations=201,
... )
>>> horizon(bskill.sel(skill="uninitialized", results="p") <= 0.05)
<xarray.Dataset>
Dimensions:  ()
Coordinates:
    results  <U12 'p'
    skill    <U13 'uninitialized'
Data variables:
    tos      float64 10.0
Attributes:
    units:          years
    standard_name:  forecast_period
    long_name:      Lead
    description:    Forecast period is the time interval between the forecast...