xarray.set_options

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

Set options for xarray in a controlled context.

Currently supported options:

  • display_width: maximum display width for repr on xarray objects. Default: 80.

  • display_max_rows: maximum display rows. Default: 12.

  • arithmetic_join: DataArray/Dataset alignment in binary operations. Default: 'inner'.

  • file_cache_maxsize: maximum number of open files to hold in xarray’s global least-recently-usage cached. This should be smaller than your system’s per-process file descriptor limit, e.g., ulimit -n on Linux. Default: 128.

  • warn_for_unclosed_files: whether or not to issue a warning when unclosed files are deallocated (default False). This is mostly useful for debugging.

  • cmap_sequential: colormap to use for nondivergent data plots. Default: viridis. If string, must be matplotlib built-in colormap. Can also be a Colormap object (e.g. mpl.cm.magma)

  • cmap_divergent: colormap to use for divergent data plots. Default: RdBu_r. If string, must be matplotlib built-in colormap. Can also be a Colormap object (e.g. mpl.cm.magma)

  • keep_attrs: rule for whether to keep attributes on xarray Datasets/dataarrays after operations. Either True to always keep attrs, False to always discard them, or 'default' to use original logic that attrs should only be kept in unambiguous circumstances. Default: 'default'.

  • display_style: display style to use in jupyter for xarray objects. Default: 'text'. Other options are 'html'.

You can use set_options either as a context manager:

>>> ds = xr.Dataset({"x": np.arange(1000)})
>>> with xr.set_options(display_width=40):
...     print(ds)
...
<xarray.Dataset>
Dimensions:  (x: 1000)
Coordinates:
  * x        (x) int64 0 1 2 ... 998 999
Data variables:
    *empty*

Or to set global options:

>>> xr.set_options(display_width=80)  
<xarray.core.options.set_options object at 0x...>
__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(**kwargs)

Initialize self.