cf_xarray.set_options

class cf_xarray.set_options(**kwargs)[source]

Set options for cf-xarray in a controlled context.

Parameters:
custom_criteriadict

Translate from axis, coord, or custom name to variable name optionally using custom_criteria. Default: [].

warn_on_missing_variablesbool

Whether to raise a warning when variables referred to in attributes are not present in the object.

Examples

You can use set_options either as a context manager:

>>> import numpy as np
>>> import xarray as xr
>>> my_custom_criteria = {"ssh": {"name": "elev$"}}
>>> ds = xr.Dataset({"elev": np.arange(1000)})
>>> with cf_xarray.set_options(custom_criteria=my_custom_criteria):
...     xr.testing.assert_identical(ds["elev"], ds.cf["ssh"])
...

Or to set global options:

>>> cf_xarray.set_options(custom_criteria=my_custom_criteria)
>>> xr.testing.assert_identical(ds["elev"], ds.cf["ssh"])
__init__(**kwargs)[source]

Methods

__init__(**kwargs)

_apply_update(options_dict)[source]