PlasmaCalcs.tools.xarray_tools.xarray_misc.xarray_with_data

PlasmaCalcs.tools.xarray_tools.xarray_misc.xarray_with_data(xarray, data, dims=None, *, name=None)
return data as an xr.DataArray with dims, coords, name, and attrs copied from xarray.
Similar to DataArray.copy(data=data), but here allows a bit more control.
dims: None, str, or iterable of str
if provided, only include these dims (and related coords) in the result.
Useful if only interested in some of the dims,
e.g. if array has x,y,z,t dims but only want to mimic dims and coords from x,t.
name: None, bool, or str
whether to also include name in result
None –> True if array has name, else False
True –> name = array.name.
str –> name = name.