arviz_base.xarray_var_iter#

arviz_base.xarray_var_iter(data, var_names=None, combined=None, skip_dims=None, dim_to_idx=None, reverse_selections=False, dim_order=None)[source]#

Convert xarray data to an iterator over vectors.

Iterates over each var_name and all of its coordinates, returning selected subsets as DataArray.

Parameters:
dataxarray.Dataset

Posterior data in an xarray

var_namesiterator of hashable, optional

Should be a subset of data.data_vars. Defaults to all of them. Passed to xarray_sel_iter.

combinedbool, optional

Whether to combine chains or leave them separate. Passed to xarray_sel_iter.

skip_dimsset, optional

Dimensions to not iterate over. Passed to xarray_sel_iter.

dim_to_idxdict, optional

Mapping from dimension names to index names to define a different way to loop over that dimension. Passed to xarray_sel_iter.

reverse_selectionsbool, optional

Whether to reverse selections before iterating. Passed to xarray_sel_iter.

dim_order: list, optional

Order for the first dimensions. Skips dimensions not found in the variable.

Yields:
var_namestr

Variable name to which selection, iselection and data_subset correspond to.

selectiondict of {hashableany}

Keys are coordinate names and values are scalar coordinate values.

iselectiondict of {hashableany}

Keys are dimension names and values are positional indexes (might not be scalars).

data_subsetxarray.DataArray)

Values of the variable at those coordinates.

See also

xarray_sel_iter

Return the iterator without the DataArray subset corresponding to the selection.