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:
- data
xarray.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_dims
set
, optional Dimensions to not iterate over. Passed to
xarray_sel_iter
.- dim_to_idx
dict
, 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.
- data
- Yields:
- var_name
str
Variable name to which selection, iselection and data_subset correspond to.
- selection
dict
of {hashableany
} Keys are coordinate names and values are scalar coordinate values.
- iselection
dict
of {hashableany
} Keys are dimension names and values are positional indexes (might not be scalars).
- data_subset
xarray.DataArray
) Values of the variable at those coordinates.
- var_name
See also
xarray_sel_iter
Return the iterator without the DataArray subset corresponding to the selection.