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: strname of the array. Result name, dim, and coord will all use this name.coords: dictif 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: boolwhether to be lenient about the input arraylike, to also accept,if lenient=True:0Darraylike–> result will be 1D array of length 11D xr.DataArray with dimension ==name–> returnarraylike, unchanged.(if lenient=False, then these cases will instead crash.)Example: xr1d([1,7,3], ‘x’)<xarray.DataArray ‘x’ (x: 3)> Size: 24Barray([1, 7, 3])Coordinates:* x (x) int64 24B 1 7 3