PlasmaCalcs.tools.xarray_tools.xarray_dimensions.xarray_squeeze

PlasmaCalcs.tools.xarray_tools.xarray_dimensions.xarray_squeeze(array, dim=None, *, keep=None, drop=True)
return array but drop redundant dims.
dims are redundant if np.all(array==array.isel(dim=0)).
This is a more aggressive version of array.squeeze():
all dims with size 1 are trivially redundant and will be dropped;
but here, additionally, all dims which are redundant in any way will be dropped.
dim: None, str, or list of strs
if provided, only consider dropping these dims.
keep: None, str, or list of strs
if provided, do not consider dropping these dims.
(can provide dim or keep, but not both.)
drop: bool
whether to drop coord for size-1 redundant dims.
if False, will keep scalar coord for size-1 redundant dims.
E.g. [[0,1,2],[0,1,2]] –> [0,1,2]. (But, as xarray, so result remains well-labeled.)