climpred.options.set_options

climpred.options.set_options#

class climpred.options.set_options(**kwargs)[source]#

Set options for climpred in a controlled context.

Analogous to set_options.

Parameters:
  • ``seasonality`` – {"dayofyear", "weekofyear", "month", "season"}, default: "month" # noqa: E501 Attribute to group dimension groupby(f"{dim}.{seasonality}""). Used in reference=climatology and HindcastEnsemble.remove_bias().

  • ``PerfectModel_persistence_from_initialized_lead_0`` – {True, False}, default False # noqa: E501 Which persistence function to use in PerfectModelEnsemble.verify/bootstrap(reference="persistence"). If False use compute_persistence(). If True use compute_persistence_from_first_lead().

  • ``warn_for_failed_PredictionEnsemble_xr_call`` – {True, False}, default True. # noqa: E501 Raise UserWarning when PredictionEnsemble.xr_call, e.g. .sel(lead=[1]) fails on one of the datasets.

  • ``warn_for_rename_to_climpred_dims`` – {True, False}, default True Raise UserWarning when dimensions are renamed to CLIMPRED_DIMS when PredictionEnsemble is instantiated.

  • ``warn_for_init_coords_int_to_annual`` – {True, False}, default True Raise UserWarning when init coordinate is of type integer and gets converted to annual cftime_range when PredictionEnsemble is instantiated.

  • ``climpred_warnings`` – {True, False}, default True Overwrites all options containing "*warn*".

  • ``bootstrap_resample_skill_func`` – {“loop”, “exclude_resample_dim_from_dim”, “resample_before”,”default”} # noqa: E501 Decide which resampling method to use in PredictionEnsemble.bootstrap(). default as in code.

  • ``resample_iterations_func`` – {"default", "resample_iterations", "resample_iterations_idx"} # noqa: E501 Decide which resample_iterations function to use from xskillscore. "default" as in code:

    • xskillscore.resample_iterations_idx() creates one large chunk

      and consumes much memory and is not recommended for large files.

    • xskillscore.resample_iterations() create many tasks but is more

      stable.

  • ``bootstrap_uninitialized_from_iterations_mean`` – {True, False} Exchange uninitialized skill with the iteration mean uninitialized. Defaults to False.

Examples

You can use set_options either as a context manager:

>>> kw = dict(
...     metric="mse",
...     comparison="e2o",
...     dim="init",
...     alignment="same_verifs",
...     reference="climatology",
... )
>>> with climpred.set_options(seasonality="month"):
...     HindcastEnsemble.verify(**kw).SST.sel(skill="climatology")
...
<xarray.DataArray 'SST' (lead: 10)>
array([0.03712573, 0.03712573, 0.03712573, 0.03712573, 0.03712573,
       0.03712573, 0.03712573, 0.03712573, 0.03712573, 0.03712573])
Coordinates:
  * lead     (lead) int32 1 2 3 4 5 6 7 8 9 10
    skill    <U11 'climatology'
Attributes:
    units:    (C)^2

Or to set global options:

>>> climpred.set_options(seasonality="month")  
<climpred.options.set_options object at 0x...>
__init__(**kwargs)[source]#

Methods

__init__(**kwargs)