erlab.accessors.utils¶
Functions
|
|
|
Classes
|
Base class for accessors. |
|
Base class for accessors. |
|
|
|
|
|
|
|
|
- class erlab.accessors.utils.InteractiveDataArrayAccessor(xarray_obj)[source]¶
Bases:
ERLabDataArrayAccessor
xarray.DataArray.qshow
accessor for interactive visualization.- __call__(*args, **kwargs)[source]¶
Visualize the data interactively.
Chooses the appropriate interactive visualization method based on the number of dimensions in the data.
- Parameters:
*args – Positional arguments passed onto the interactive visualization function.
**kwargs – Keyword arguments passed onto the interactive visualization function.
- hvplot(*args, **kwargs)[source]¶
hvplot
-based interactive visualization.- Parameters:
*args – Positional arguments passed onto
DataArray.hvplot()
.**kwargs – Keyword arguments passed onto
DataArray.hvplot()
.
- Raises:
ImportError – If
hvplot
is not installed.
- class erlab.accessors.utils.InteractiveDatasetAccessor(xarray_obj)[source]¶
Bases:
ERLabDatasetAccessor
xarray.Dataset.qshow
accessor for interactive visualization.- __call__(*args, **kwargs)[source]¶
Visualize the data interactively.
Chooses the appropriate interactive visualization method based on the data variables.
- Parameters:
*args – Positional arguments passed onto the interactive visualization function.
**kwargs – Keyword arguments passed onto the interactive visualization function.
- hvplot(*args, **kwargs)[source]¶
hvplot
-based interactive visualization.- Parameters:
*args – Positional arguments passed onto
Dataset.hvplot()
.**kwargs – Keyword arguments passed onto
Dataset.hvplot()
.
- Raises:
ImportError – If
hvplot
is not installed.
- class erlab.accessors.utils.PlotAccessor(xarray_obj)[source]¶
Bases:
ERLabDataArrayAccessor
xarray.DataArray.qplot
accessor for plotting data.- __call__(*args, **kwargs)[source]¶
Plot the data.
If a 2D data array is provided, it is plotted using
plot_array
. Otherwise, it is equivalent to callingxarray.DataArray.plot()
.- Parameters:
*args – Positional arguments to be passed to the plotting function.
**kwargs – Keyword arguments to be passed to the plotting function.
- class erlab.accessors.utils.SelectionAccessor(xarray_obj)[source]¶
Bases:
ERLabDataArrayAccessor
xarray.DataArray.qsel
accessor for convenient selection and averaging.- __call__(indexers=None, *, verbose=False, **indexers_kwargs)[source]¶
Select and average data along specified dimensions.
- Parameters:
indexers (Mapping[Hashable, float | slice] | None) –
Dictionary specifying the dimensions and their values or slices. Position along a dimension can be specified in three ways:
As a scalar value:
alpha=-1.2
If no width is specified, the data is selected along the nearest value. It is equivalent to
xarray.DataArray.sel
withmethod='nearest'
.As a value and width:
alpha=5, alpha_width=0.5
The data is averaged over a slice of width
alpha_width
, centered atalpha
.As a slice:
alpha=slice(-10, 10)
The data is selected over the specified slice. No averaging is performed.
One of
indexers
orindexers_kwargs
must be provided.verbose (bool) – If
True
, print information about the selected data and averaging process. Default isFalse
.**indexers_kwargs – The keyword arguments form of
indexers
. One ofindexers
orindexers_kwargs
must be provided.
- Returns:
The selected and averaged data.
- Return type:
- Raises:
ValueError – If a specified dimension is not present in the data.