xarray.DataArray.qsel¶
- DataArray.qsel(self, indexers=None, **indexers_kwargs)[source]¶
Select and average data along specified dimensions.
- Parameters:
indexers (
Mapping[Hashable,float|slice] |None, default:None) –Dictionary specifying the dimensions and their values or slices. Position along a dimension can be specified in three ways:
As a scalar value or a collection of scalar values:
alpha=-1.2oralpha=[-1.2, 0.0, 1.2]:If no width is specified, the data is selected along the nearest value for each element. It is equivalent to calling
xarray.DataArray.sel()withmethod='nearest'.As a value and width:
alpha=5, alpha_width=0.5The data is averaged over a slice of width
alpha_width, centered atalpha. Ifalphais a collection, the data is averaged over multiple slices and concatenated along the dimension.As a slice:
alpha=slice(-10, 10)The data is selected over the specified slice. No averaging is performed. This is equivalent to calling
xarray.DataArray.sel()with a slice.
One of
indexersorindexers_kwargsmust be provided.**indexers_kwargs – The keyword arguments form of
indexers. One ofindexersorindexers_kwargsmust be provided.
- Returns:
DataArray– The selected and averaged data.
Note
Unlike
xarray.DataArray.sel(), this method treats all dimensions without coordinates as equivalent to having coordinates assigned from 0 ton-1, wherenis the size of the dimension. For example:da = xr.DataArray(np.random.rand(10), dims=("x",)) da.sel(x=slice(2, 3)) # This works da.sel(x=slice(2.0, 3.0)) # This raises a TypeError da.qsel(x=slice(2.0, 3.0)) # This works