PlasmaCalcs.tools.xarray_tools.xarray_indexing.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)
-
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 Dataset
- apply f to this array, or each array in this Dataset
- f: callable
- axis, axes: None, str, or iterable of strs
- if 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: 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.