xarray_promote_dim

PlasmaCalcs.tools.xarray_tools.xarray_dimensions.xarray_promote_dim(array, coord, *coords_as_args)

Promote this coord (or these coords) to be a dimension, if it isn’t already.

coord: str or iterable of strs
name of coord(s) to promote.
if already in array.dims, do nothing.
if 0D, array.expand_dims(coord).
(This occurs when coord has no associated dimension, in array.)
if 1D, array.swap_dims(dict(dim=coord)),
where dim is the dimension associated with coord.
if 2D+, crash with DimensionalityError.
returns array, or a copy of array where coord is one of the dimensions.