isel

function of dascore.proc.coords source

isel(
    patch: Patch ,
    indexers: collections.abc.Mapping[collections.abc.Mapping[str, Any], None] = None,
    drop: bool = False,
    missing_dims: str = raise,
    **indexers_kwargs: Any ,
)-> ‘PatchType’

Select sample positions with xarray-compatible dimension indexing.

This method is provided for compatibility with xarray’s DataArray.isel for the supported indexing operations described below. Use Patch.select for DASCore’s tuple range notation, relative selections, and filtering that preserves dimensions and source order.

Parameters

Parameter Description
patch Patch to index.
indexers Mapping of dimension names to integer positions, slices, or 1D integer
arrays or boolean masks. 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.
Note

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

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 == ()

See Also

Patch.sel : Xarray-compatible label indexing. Patch.select : Range filtering and relative selections.