xarray.set_options#
- class xarray.set_options(**kwargs)[source]#
Set options for xarray in a controlled context.
- Parameters:
arithmetic_broadcast (
bool, default:True) – Whether to perform automatic broadcasting in binary operations.arithmetic_compat (
{"identical", "equals", "broadcast_equals", "no_conflicts", "override", "minimal"}, default:"minimal") – How to compare non-index coordinates of the same name for potential conflicts when performing binary operations. (For the alignment of index coordinates in binary operations, see arithmetic_join.)“identical”: all values, dimensions and attributes of the coordinates must be the same.
“equals”: all values and dimensions of the coordinates must be the same.
“broadcast_equals”: all values of the coordinates must be equal after broadcasting to ensure common dimensions.
“no_conflicts”: only values which are not null in both coordinates must be equal. The returned coordinate then contains the combination of all non-null values.
“override”: skip comparing and take the coordinates from the first operand.
“minimal”: drop conflicting coordinates.
arithmetic_join (
{"inner", "outer", "left", "right", "exact"}, default:"inner") – DataArray/Dataset index alignment in binary operations:“outer”: use the union of object indexes
“inner”: use the intersection of object indexes
“left”: use indexes from the first object with each dimension
“right”: use indexes from the last object with each dimension
“exact”: instead of aligning, raise ValueError when indexes to be aligned are not equal
chunk_manager (
str, default:"dask") – Chunk manager to use for chunked array computations when multiple options are installed.facetgrid_figsize (
{"computed", "rcparams"}ortupleoffloat, default:"computed") – HowFacetGriddetermines figure size whenfigsizeis not explicitly passed:"computed": figure size is derived fromsizeandaspectparameters (current default behavior)."rcparams": usematplotlib.rcParams['figure.figsize']as the total figure size.(width, height): use a fixed figure size (in inches).
cmap_divergent (
strormatplotlib.colors.Colormap, default:"RdBu_r") – Colormap to use for divergent data plots. If string, must be matplotlib built-in colormap. Can also be a Colormap object (e.g. mpl.colormaps[“magma”])cmap_sequential (
strormatplotlib.colors.Colormap, default:"viridis") – Colormap to use for nondivergent data plots. If string, must be matplotlib built-in colormap. Can also be a Colormap object (e.g. mpl.colormaps[“magma”])display_expand_attrs (
{"default", True, False}) – Whether to expand the attributes section for display ofDataArrayorDatasetobjects. Can beTrue: to always expand attrsFalse: to always collapse attrsdefault: to expand unless over a pre-defined limit
display_expand_coords (
{"default", True, False}) – Whether to expand the coordinates section for display ofDataArrayorDatasetobjects. Can beTrue: to always expand coordinatesFalse: to always collapse coordinatesdefault: to expand unless over a pre-defined limit
display_expand_data (
{"default", True, False}) – Whether to expand the data section for display ofDataArrayobjects. Can beTrue: to always expand dataFalse: to always collapse datadefault: to expand unless over a pre-defined limit
display_expand_data_vars (
{"default", True, False}) – Whether to expand the data variables section for display ofDatasetobjects. Can beTrue: to always expand data variablesFalse: to always collapse data variablesdefault: to expand unless over a pre-defined limit
display_expand_indexes (
{"default", True, False}) – Whether to expand the indexes section for display ofDataArrayorDataset. Can beTrue: to always expand indexesFalse: to always collapse indexesdefault: to expand unless over a pre-defined limit (always collapse for html style)
display_max_children (
int, default:12) – Maximum number of children to display for each node in a DataTree.display_max_html_elements (
int, default:300) – Maximum number of HTML elements to include in DataTree HTML displays. Additional items are truncated.display_max_rows (
int, default:12) – Maximum display rows.display_max_items (
int, default20) – Maximum number of items to display for a DataTree before collapsing child nodes, across all levels.display_values_threshold (
int, default:200) – Total number of array elements which trigger summarization rather than full repr for variable data views (numpy arrays).display_style (
{"text", "html"}, default:"html") – Display style to use in jupyter for xarray objects.display_width (
int, default:80) – Maximum display width forrepron xarray objects.file_cache_maxsize (
int, default:128) – 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 -non Linux.keep_attrs (
{"default", True, False}) – Whether to keep attributes on xarray Datasets/dataarrays after operations. Can beTrue: to always keep attrsFalse: to always discard attrsdefault: to use original logic that attrs should only be kept in unambiguous circumstances
netcdf_engine_order (sequence, default
[``’netcdf4’, ``'h5netcdf','scipy']) – Preference order of backend engines to use when reading or writing netCDF files withopen_dataset()andto_netcdf()ifengineis not explicitly specified. May be any permutation or subset of['netcdf4', 'h5netcdf', 'scipy'].use_bottleneck (
bool, default:True) – Whether to usebottleneckto accelerate 1D reductions and 1D rolling reduction operations.use_flox (
bool, default:True) – Whether to usenumpy_groupiesand flox` to accelerate groupby and resampling reductions.use_new_combine_kwarg_defaults (
bool, defaultFalse) – Whether to use new kwarg default values for combine functions:concat(),merge(),open_mfdataset(). New values are:data_vars: Nonecoords: “minimal”compat: “override”join: “exact”
use_numbagg (
bool, default:True) – Whether to usenumbaggto accelerate reductions. Takes precedence overuse_bottleneckwhen both are True.use_opt_einsum (
bool, default:True) – Whether to useopt_einsumto accelerate dot products.warn_for_unclosed_files (
bool, default:False) – Whether or not to issue a warning when unclosed files are deallocated. This is mostly useful for debugging.
Examples
It is possible to use
set_optionseither as a context manager:>>> ds = xr.Dataset({"x": np.arange(1000)}) >>> with xr.set_options(display_width=40): ... print(ds) ... <xarray.Dataset> Size: 8kB Dimensions: (x: 1000) Coordinates: * x (x) int64 8kB 0 1 ... 999 Data variables: *empty*
Or to set global options:
>>> xr.set_options(display_width=80) <xarray.core.options.set_options object at 0x...>
Methods
__init__(**kwargs)