MCPcopy Index your code
hub / github.com/pydata/xarray / isel

Method isel

xarray/core/datatree.py:2289–2349  ·  view source on GitHub ↗

Returns a new data tree with each array indexed along the specified dimension(s). This method selects values from each array using its `__getitem__` method, except this method does not require knowing the order of each array's dimensions. Parameters

(
        self,
        indexers: Mapping[Any, Any] | None = None,
        drop: bool = False,
        missing_dims: ErrorOptionsWithWarn = "raise",
        **indexers_kwargs: Any,
    )

Source from the content-addressed store, hash-verified

2287 return type(self).from_dict(result, name=self.name)
2288
2289 def isel(
2290 self,
2291 indexers: Mapping[Any, Any] | None = None,
2292 drop: bool = False,
2293 missing_dims: ErrorOptionsWithWarn = "raise",
2294 **indexers_kwargs: Any,
2295 ) -> Self:
2296 """Returns a new data tree with each array indexed along the specified
2297 dimension(s).
2298
2299 This method selects values from each array using its `__getitem__`
2300 method, except this method does not require knowing the order of
2301 each array's dimensions.
2302
2303 Parameters
2304 ----------
2305 indexers : dict, optional
2306 A dict with keys matching dimensions and values given
2307 by integers, slice objects or arrays.
2308 indexer can be an integer, slice, array-like or DataArray.
2309 If DataArrays are passed as indexers, xarray-style indexing will be
2310 carried out. See :ref:`indexing` for the details.
2311 One of indexers or indexers_kwargs must be provided.
2312 drop : bool, default: False
2313 If ``drop=True``, drop coordinates variables indexed by integers
2314 instead of making them scalar.
2315 missing_dims : {"raise", "warn", "ignore"}, default: "raise"
2316 What to do if dimensions that should be selected from are not present in the
2317 Dataset:
2318 - "raise": raise an exception
2319 - "warn": raise a warning, and ignore the missing dimensions
2320 - "ignore": ignore the missing dimensions
2321
2322 **indexers_kwargs : {dim: indexer, ...}, optional
2323 The keyword arguments form of ``indexers``.
2324 One of indexers or indexers_kwargs must be provided.
2325
2326 Returns
2327 -------
2328 obj : DataTree
2329 A new DataTree with the same contents as this data tree, except each
2330 array and dimension is indexed by the appropriate indexers.
2331 If indexer DataArrays have coordinates that do not conflict with
2332 this object, then these coordinates will be attached.
2333 In general, each array's data will be a view of the array's data
2334 in this dataset, unless vectorized indexing was triggered by using
2335 an array indexer, in which case the data will be a copy.
2336
2337 See Also
2338 --------
2339 DataTree.sel
2340 Dataset.isel
2341 """
2342
2343 def apply_indexers(dataset, node_indexers):
2344 return dataset.isel(node_indexers, drop=drop)
2345
2346 indexers = either_dict_or_kwargs(indexers, indexers_kwargs, "isel")

Callers 1

apply_indexersMethod · 0.45

Calls 2

_selective_indexingMethod · 0.95
either_dict_or_kwargsFunction · 0.90

Tested by

no test coverage detected