PlasmaCalcs.tools.xarray_tools.xarray_coords.xarray_str_coords
- PlasmaCalcs.tools.xarray_tools.xarray_coords.xarray_str_coords(array, coords=None, newname='str_{coord}', *, drop=True, promote=False)
- return copy of array with coords replaced by str coords (& renamed to str_coord)E.g. array.pc.str_coords(‘fluid’) –> result[‘str_fluid’] == str(f) for f in array[‘fluid’]
- coords: None, str, or iterable of strs
- coords to replace with str. None –> all coords.
- newcoord: str
- string for new (converted-to-str) coord names: newcoord.format(coord=coord).Default: ‘str_{coord}’. To keep original names, use ‘{coord}’
- drop: bool
- whether to drop original coords’ values.True –> drop original coords.False –> add new coords but do not adjust original coords.
- promote: bool
- whether to promote all non-dim new str coords to dimensions.if True, xarray_promote_dim for all new str coords.