diagnostic.diagnostic#
Classes
|
A class representing a diagnostic that operates on the level of single datasets. |
|
An abstract class representing a diagnostic. |
|
A class representing a diagnostic that compares an ensemble to a reference. |
|
A class representing a diagnostic that compares an ensemble to itself. |
|
A class representing a diagnostic that compares a model to a reference. |
|
A class representing a diagnostic that compares a model to itself. |
- class DataSetDiagnostic(diagnostic_function, plotting_function, name=None, description=None, plot_type='single')[source]#
A class representing a diagnostic that operates on the level of single datasets.
- apply_dt(dt: DataTree, *args, **kwargs)[source]#
Apply the diagnostic to a DataTree by iterating over the each dataset in the tree.
- Parameters:
dt (DataTree) – The data to apply the diagnostic to.
- Returns:
The data after applying the diagnostic.
- Return type:
DataTree
- plot_dt_facetted(dt, var, axes, label='name', shared_cbar=None, **kwargs)[source]#
Plot the diagnostic by iterating over the leaves of a DataTree.
- Parameters:
dt (DataTree) – The DataTree to plot.
var (str) – The variable to plot.
axes (np.ndarray) – The axes to plot on.
label (str) – The attribute of the DataTree nodes to use as a title for the plots.
shared_cbar (str) – How to handle the vmin and vmax of the plot. Options are None, “min_max”, “abs”. If None, the vmin and vmax are not automatically set. Passing the vmin and vmax as kwargs will still result in shared colorbars. If “min_max”, the vmin and vmax are set respectively to the minimum and maximum over all the leaves of the DataTree. If “abs”, the vmin and vmax are set to the maximum of the absolute value of the minimum and maximum over all the leaves of the DataTree.
**kwargs – Keyword arguments to pass to the plotting function.
- Returns:
axes – The axes of the plot.
- Return type:
np.ndarray
- plot_dt_single(dt, var, ax, label='name', colors=None, **kwargs)[source]#
Plot the diagnostic by iterating over the leaves of a DataTree.
- Parameters:
dt (DataTree) – The DataTree to plot.
var (str) – The variable to plot.
ax (matplotlib.axis.Axis) – The axis to plot on.
label (str) – The attribute of the DataTree nodes to use as a title for the plots.
colors (dict or list) – The colors to use for the different leaves of the DataTree. Either a dictionary with the colors as values and the DataTree paths as keys or a list of colors.
**kwargs – Keyword arguments to pass to the plotting function.
- Returns:
ax – The axis of the plot.
- Return type:
matplotlib.axis.Axis
- class Diagnostic(diagnostic_function, plotting_function, name=None, description=None)[source]#
An abstract class representing a diagnostic.
- abstract apply(data)[source]#
Apply the diagnostic to the data.
- Parameters:
data – The data to apply the diagnostic to. Data can be an xarray DataTree, Dataset or DataArray.
- Returns:
The data after applying the diagnostic either as a DataTree, Dataset, DataArray, Scalar, or a pandas DataFrame.
- Return type:
Results
- property description#
Generate the docstring for the diagnostic.
- class Ensemble2Ref(diagnostic_function, plotting_function, name=None, description=None)[source]#
A class representing a diagnostic that compares an ensemble to a reference.
- apply(dt: DataTree, ref, **kwargs)[source]#
Apply the diagnostic to the data.
- Parameters:
dt (DataTree) – The data to apply the diagnostic to.
ref (xr.DataSet or DataTree) – The reference data to compare the data to.
- Returns:
The data after applying the diagnostic as a DataTree or a dictionary of results with the tree nodes as keys.
- Return type:
DataTree or dict
- plot(result, facetted=True, **kwargs)[source]#
Plot the diagnostic.
If axes are provided, the diagnostic is plotted facetted. If ax is provided, the diagnostic is plotted non-facetted. If neither axes nor ax are provided, the diagnostic is plotted on the current axis and no facetting is applied.
- Parameters:
result (DataTree) – The result of applying the ensemble diagnostic to a DataTree.
- Returns:
The figure representing the diagnostic.
- Return type:
Figure
- class Ensemble2Self(diagnostic_function, plotting_function, name=None, description=None, iterative_plotting=False)[source]#
A class representing a diagnostic that compares an ensemble to itself.
- apply(dt: DataTree, mask=None, **kwargs)[source]#
Apply the diagnostic to the data.
- Parameters:
dt (DataTree) – The data to apply the diagnostic to.
- Returns:
The data after applying the diagnostic as a DataTree or a dictionary of results with the tree nodes as keys.
- Return type:
DataTree or dict
- plot(result, variables=None, title=None, facetted=None, **kwargs)[source]#
Plot the diagnostic.
If facetted multiple plots on different axes are created. If not facetted, the plots are created on the same axis.
- Parameters:
result (DataTree) – The result of applying the ensemble diagnostic to a DataTree.
- Returns:
The figure representing the diagnostic.
- Return type:
Figure
- class Model2Ref(diagnostic_function, plotting_function, name=None, description=None, plot_type='facetted')[source]#
A class representing a diagnostic that compares a model to a reference.
- apply(ds: Dataset, ref: Dataset, mask=None, **kwargs)[source]#
Apply the diagnostic to the data. Only the common variables between the data and the reference are used.
- Parameters:
ds (xr.Dataset) – The data to apply the diagnostic to.
ref (xr.Dataset) – The reference data to compare the data to.
- Returns:
The data after applying the diagnostic.
- Return type:
xr.Dataset
- apply_dt(dt: DataTree, ref: Dataset, mask=None, **kwargs)[source]#
Apply the diagnostic to a DataTree.
- Parameters:
dt (DataTree) – The DataTree to apply the diagnostic to.
ref (xr.Dataset) – The reference data to compare the data to.
- Returns:
The DataTree after applying the diagnostic.
- Return type:
DataTree
- class Model2Self(diagnostic_function, plotting_function, name=None, description=None, plot_type='single')[source]#
A class representing a diagnostic that compares a model to itself.