xarray_ensure_dims
- PlasmaCalcs.tools.xarray_tools.xarray_dimensions.xarray_ensure_dims(array, coords, *, promote_dims_if_needed=True, missing_dims='raise', assert_1d=False, return_existing_dims=False)
return array but ensure these coords are dimensions.
coords: str or iterable of strings
coords to ensure are dimensions.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.0D coord –> array.expand_dims(coord)1D coord –> array.swap_dims(dict(dim=coord)) for associated dim2D+ coord –> crash with DimensionalityError.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.assert_1d: bool, default Falsewhether to assert that each of these coords is 1D (after promoting if needed).return_existing_dims: bool, default FalseTrue –> returns [array, set of dims (from input coords) which actually exist]probably only useful if missing_dims != ‘raise’.