xarray_map
- PlasmaCalcs.tools.xarray_tools.xarray_indexing.xarray_map(array, f, *args_f, axis=None, axes=None, promote_dims_if_needed=True, missing_dims='raise', **kw_f)
func(array, *args_f, **kw_f), but axis/axes can be provided as strings!
Mainly useful if trying to apply f which expects unlabeled array & int axes inputs.
E.g. numpy.mean can use axis kwarg as iterable of ints,but here can provide axis as a dim name str or list of dim names.Probably not super useful for mean, since xarray provides xr.mean,but may be useful for other functions e.g. scipy.ndimage.gaussian_filter,which might not have an existing equivalent in xarray.array: xarray.DataArray or Datasetapply f to this array, or each array in this Datasetf: callablewill be called as f(array, *args_f, **kw_f),possibly will also be passed a value for axis or axes, if provided hereaxis, axes: None, str, or iterable of strsif provided, convert to axes positions in dataarray, and pass to f as int(s).Also promotes these coords to dims if necessary.promote_dims_if_needed: boolwhether 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.