import dascore as dc
patch = dc.get_example_patch()
window = patch.isel(time=slice(0, 100, 2), distance=[3, 1, 3])
assert window.shape == (3, 50)
channel = patch.isel(distance=3)
assert channel.dims == ("time",)
assert channel.get_array("distance").shape == ()isel
isel(
self ,
indexers: collections.abc.Mapping[collections.abc.Mapping[str, Any], None] = None,
drop: bool = False,
missing_dims: str = raise,
**indexers_kwargs: Any ,
)-> ‘Self’
Select sample positions with xarray-compatible dimension indexing.
isel exists for xarray compatibility: it supports the DataArray.isel operations described below, so code written for xarray works on patches. Patch.select, kept for backwards compatibility, has DASCore’s tuple range notation, relative selections, and filtering that preserves dimensions and source order.
Parameters
| Parameter | Description |
|---|---|
| indexers |
Mapping of dimension names to integer positions, slices, or 1D integer arrays or boolean masks. Tuples raise; use a slice or a list. Supply this or keyword indexers. |
| drop |
Drop coordinates made scalar by indexing. By default they are retained as scalar coordinates. Scalar indexers remove their dimension either way; use a one-element list to retain a length-one dimension. |
| missing_dims |
How to handle absent dimensions: "raise", "warn", or "ignore".
|
| **indexers_kwargs | Dimension indexers supplied as keywords. |
Slices use Python’s exclusive stop and support strides and negative indices. Evenly sampled slice results stay compact; floating coordinate values can differ from xarray by rounding relative to the original range, as with select. Arrays preserve order and repetitions; arrays on multiple dimensions select every combination of positions. Out-of-bounds scalar and array indices raise. Labelled xarray indexers and multidimensional indexer arrays are not supported.
Examples
See Also
Patch.sel : Xarray-compatible label indexing. Patch.select : Range filtering and relative selections.