grid_process.da_utils#
Module with general utility functions that operate on xarray.DataArray
Attributes#
Classes#
Xarray accessors class for general utility functions on DataArray |
Functions#
|
Transform a dataarray, containing model data and one or several |
|
Convert numerical values into classes as defined by |
Module Contents#
- logger#
- class DaUtils(da: xarray.DataArray)[source]#
Xarray accessors class for general utility functions on DataArray
- dataarray_accessor#
- da_to_ds(da: xarray.DataArray, vars_attrs: dict[collections.abc.Hashable, dict[collections.abc.Hashable, Any]]) xarray.Dataset[source]#
Transform a dataarray, containing model data and one or several variables specified by the variable dimension, to a dataset. The function also reassign the attributes of the data variables saved in
vars_attrs.- Parameters:
da (xarray.DataArray) – contains one or more variables specified in the variable dimension
vars_attrs (dict) – contains the attributes of each variables found along the variable dimension
- Returns:
ds – the dataset is composed of the data variables of the input DataArray
- Return type:
xarray.Dataset
See also
- bin_to_class(da: xarray.DataArray, bins: collections.abc.Sequence[float], bins_label: collections.abc.Sequence[str | int], da_name: str | None = None) xarray.DataArray[source]#
Convert numerical values into classes as defined by
binsandbins_label.Parameters:#
- daxarray.DataArray
array with numerical values
- binssequence of floats
defines the boudaries for the classes
- bins_labelsequence of str or int
class labels. len(
bin_labels) = len(bins) + 1- da_namestr, optional
used to rename the output DataArray. By default no renaming is done.
- returns:
class_da – same as input array but with data converted from numerical values to classes
- rtype:
xarray.DataArray