xr1d

PlasmaCalcs.tools.xarray_tools.xarray_grids.xr1d(arraylike, name, *, coords={}, lenient=False, **kw_data_array)

create a 1D xarray.DataArray from arraylike, using name for array, dim, & coord.

Equivalent: xr.DataArray(arraylike, coords={name: arraylike}, name=name, dims=name)
name: str
name of the array. Result name, dim, and coord will all use this name.
coords: dict
if provided, update default coords using this dict.
E.g. xr1d([1,2,3], ‘x’, coords={‘y’: 7}) coords will be {‘x’: [1,2,3], ‘y’: 7}.
E.g. xr1d([1,2,3], ‘x’, coords={‘x’: [11,12,13]}) coord for ‘x’ will be [11,12,13].
lenient: bool
whether to be lenient about the input arraylike, to also accept,
if lenient=True:
0D arraylike –> result will be 1D array of length 1
1D xr.DataArray with dimension == name –> return arraylike, unchanged.
(if lenient=False, then these cases will instead crash.)
Example: xr1d([1,7,3], ‘x’)
<xarray.DataArray ‘x’ (x: 3)> Size: 24B
array([1, 7, 3])
Coordinates:
* x (x) int64 24B 1 7 3