xarray_closeness

PlasmaCalcs.tools.xarray_tools.xarray_dimensions.xarray_closeness(array, dim=None)

computes “closeness” along each dim: (array.isel(dim=0)/array).std()

(Special case: if array.isel(dim=0) is all 0s, closeness=0 if array is all 0, else inf.)
Result is a dataset with one scalar data_var telling closeness of each dim.
Note: the std() is always taken across ALL dims of the array.
[TODO] allow to keep some dims?
dim: None, str, or list of strs
if provided, only consider these dims.
See also: xarray_squeeze_close