uxarray.UxDataArray.isel

uxarray.UxDataArray.isel#

UxDataArray.isel(indexers=None, drop=False, missing_dims='raise', ignore_grid=False, inverse_indices=False, **indexers_kwargs)#

Return a new DataArray whose data is given by selecting indexes along the specified dimension(s).

Performs xarray-style integer-location indexing along specified dimensions. If a single grid dimension (‘n_node’, ‘n_edge’, or ‘n_face’) is provided and ignore_grid=False, the underlying grid is sliced accordingly, and remaining indexers are applied to the resulting DataArray.

Parameters:
  • indexers (Mapping[Any, Any], optional) – A mapping of dimension names to indexers. Each indexer may be an integer, slice, array-like, or DataArray. Mutually exclusive with indexing via kwargs.

  • drop (bool, default=False) – If True, drop any coordinate variables indexed by integers instead of retaining them as length-1 dimensions.

  • missing_dims ({'raise', 'warn', 'ignore'}, default='raise') – Behavior when indexers reference dimensions not present in the array. - ‘raise’: raise an error - ‘warn’: emit a warning and ignore missing dimensions - ‘ignore’: ignore missing dimensions silently

  • ignore_grid (bool, default=False) – If False (default), allow slicing on one grid dimension to automatically update the associated UXarray grid. If True, fall back to pure xarray behavior.

  • inverse_indices (bool, default=False) – For grid-based slicing, pass this flag to Grid.isel to invert indices when selecting (useful for staggering or reversing order).

  • **indexers_kwargs (dimension=indexer pairs, optional) – Alternative syntax for specifying indexers via keyword arguments.

Returns:

A new UxDataArray indexed according to indexers and updated grid if applicable.

Return type:

UxDataArray

Raises:

ValueError – If more than one grid dimension is selected and ignore_grid=False.