climpred.reference.compute_persistence_from_first_lead

climpred.reference.compute_persistence_from_first_lead#

climpred.reference.compute_persistence_from_first_lead(initialized: Dataset, verif: Dataset | None = None, metric: str | Metric = 'pearson_r', alignment: str = 'same_inits', dim: str | List[str] | None = 'init', comparison: str | Comparison = 'm2e', **metric_kwargs: Any | None)[source]#

Compute persistence skill based on first lead in initialized.

This function unlike compute_persistence() is sensitive to comparison. Requires climpred.set_options(PerfectModel_persistence_from_initialized_lead_0=True).

Parameters:
  • initialized – The initialized ensemble.

  • verif – Verification data. Not used.

  • metric – Metric name to apply at each lag for the persistence computation. Default: ‘pearson_r’

  • alignment – which inits or verification times should be aligned?

    • maximize: maximize the degrees of freedom by slicing initialized and verif to a common time frame at each lead.

    • same_inits: slice to a common init frame prior to computing metric. This philosophy follows the thought that each lead should be based on the same set of initializations.

    • same_verif: slice to a common/consistent verification time frame prior to computing metric. This philosophy follows the thought that each lead should be based on the same set of verification dates.

  • dim – dimension to apply metric over.

  • ** metric_kwargs – additional keywords to be passed to metric (see the arguments required for a given metric in Metrics).

Returns:

pers

Results of persistence forecast with the input metric

applied.

Example

>>> with climpred.set_options(
...     PerfectModel_persistence_from_initialized_lead_0=True
... ):
...     PerfectModelEnsemble.verify(
...         metric="mse",
...         comparison="m2e",
...         dim=["init", "member"],
...         reference="persistence",
...     ).sel(
...         skill="persistence"
...     )  # persistence sensitive to comparison
<xarray.Dataset>
Dimensions:  (lead: 20)
Coordinates:
  * lead     (lead) int64 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
    skill    <U11 'persistence'
Data variables:
    tos      (lead) float32 0.01056 0.01962 0.02925 ... 0.08033 0.08731 0.07578
Attributes:
    prediction_skill_software:                         climpred https://clim...
    skill_calculated_by_function:                      PerfectModelEnsemble....
    number_of_initializations:                         12
    number_of_members:                                 10
    metric:                                            mse
    comparison:                                        m2e
    dim:                                               ['init', 'member']
    reference:                                         ['persistence']
    PerfectModel_persistence_from_initialized_lead_0:  True
>>> with climpred.set_options(
...     PerfectModel_persistence_from_initialized_lead_0=False
... ):
...     PerfectModelEnsemble.verify(
...         metric="mse",
...         comparison="m2e",
...         dim=["init", "member"],
...         reference="persistence",
...     ).sel(
...         skill="persistence"
...     )  # persistence not sensitive to comparison
<xarray.Dataset>
Dimensions:  (lead: 20)
Coordinates:
  * lead     (lead) int64 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
    skill    <U11 'persistence'
Data variables:
    tos      (lead) float32 0.02794 0.04554 0.08024 ... 0.06327 0.09077 0.05898
Attributes:
    prediction_skill_software:                         climpred https://clim...
    skill_calculated_by_function:                      PerfectModelEnsemble....
    number_of_initializations:                         12
    number_of_members:                                 10
    metric:                                            mse
    comparison:                                        m2e
    dim:                                               ['init', 'member']
    reference:                                         ['persistence']
    PerfectModel_persistence_from_initialized_lead_0:  False
Reference:
  • Chapter 8 (Short-Term Climate Prediction) in Van den Dool, Huug. Empirical methods in short-term climate prediction. Oxford University Press, 2007.