take_along_dimensions

PlasmaCalcs.tools.xarray_tools.xarray_dimensions.take_along_dimensions(array, dimensions, *, atleast_1d=False, **kw_isel)

returns result of taking array along each of these dimensions, in order.

result will be a numpy array with dtype=object, shape=(d0, d1, …),
where di = len(array.coords[dimensions[i]]).
each element of result will be an xarray.DataArray.
any dimension can be None –> result shape will be 1 at that dimension, and nothing will be taken.
E.g. take_along_dimensions(array, [None, ‘fluid’]) gives array of shape (1, len(fluids)).
if dimensions is an empty list:
result will be a scalar numpy array with result[()] = array,
unless atleast_1d=True; then result has shape (1,) and result[0] = array.