xrrange

PlasmaCalcs.tools.xarray_tools.xarray_grids.xrrange(range_info, name='range', *, coords={}, **kw_data_array)

create a 1D xarray.DataArray of np.arange(*range_info), using name for array, dim, & coord.

if range_info is a single number, use np.arange(range_info) instead.
Equivalent: xr.DataArray(np.arange(*range_info), coords={name: np.arange(*range_info)}, …)
range_info: int or iterable of 1, 2, or 3 ints (or None)
(will be passed directly to np.arange.)
1 int provided –> stop
2 ints provided –> start, stop
3 ints provided –> start, stop, step
name: str
name of the range. Result name, dim, and coord will all use this name.
coords: dict
if provided, update default coords using this dict.
E.g. xrrange(4, ‘x’, coords={‘y’: 7}) coords will be {‘x’: np.arange(4), ‘y’: 7}.
E.g. xrrange(4, ‘x’, coords={‘x’: np.arange(4)+10}) coord for ‘x’ will be [10,11,12,13].
Example: xrrange(4, ‘x’) # ==xr.DataArray(np.arange(4), coords={‘x’: np.arange(4)}, name=’x’)
<xarray.DataArray ‘x’ (x: 4)> Size: 32B
0 1 2 3
Coordinates:
* x (x) int64 32B 0 1 2 3