xarray_stats

PlasmaCalcs.tools.xarray_tools.xarray_agg_stats.xarray_stats(array, dim=None, stats=None, *, keep=None, promote_dims_if_needed=True, missing_dims='raise', to_da=None, **kw)

returns Dataset of stats for array: min, mean, median, max, std, rms.

array: xarray.DataArray or xarray.Dataset

the array (or dataset) from which to compute stats.
if dataset, compute separate stats for each data var,
and result will be a dataset with ‘stat’ dim;
equivalent to doing xarray_stats for each data_var, with ``to_da``=’stat’.
dim: None, str, or iterable of strs
apply operation along these dimensions
stats: None or iterable of str from (‘min’, ‘mean’, ‘median’, ‘max’, ‘std’, ‘rms’)
which stats to compute & include in the result.
None –> equivalent to stats=[‘min’, ‘mean’, ‘median’, ‘max’, ‘std’, ‘rms’].
keep: None, str, or iterable of strs
apply operation along all except for these dimensions.
(can provide keep or dim, but not both.)
promote_dims_if_needed: bool
whether to promote non-dimension coords to dimensions.
if False, raise DimensionKeyError if any relevant coord is not already a dimension.
missing_dims: str in (‘ignore’, ‘warn’, ‘raise’)
what to do if any coord is not found:
‘ignore’ –> do nothing.
‘warn’ –> raise a warning.
‘raise’ –> raise DimensionKeyError.
if not ‘raise’, any missing dims will be skipped.
to_da: None, bool, or str
whether to return DataArray instead of Dataset.
None –> True if array is a Dataset, else False.
False –> result is a Dataset with stats as data vars.
(incompatible with input array being a Dataset)
True –> equivalent to to_da=’stat’.
str –> stats reported along this dimension (must not already exist in array).
result type is the same type as input (DataArray or Dataset).
additional kwargs are passed to array.min, mean, median, max, and std.
Can provide skipna=True/False to skip NaNs or not; default True for float dtypes.