diagnostic.diagnostic.DataSetDiagnostic#

class DataSetDiagnostic(diagnostic_function, plotting_function, name=None, description=None, plot_type='single')[source]#

Bases: Diagnostic

A class representing a diagnostic that operates on the level of single datasets.

__init__(diagnostic_function, plotting_function, name=None, description=None, plot_type='single')[source]#

Initialize the DataSetDiagnostic.

Parameters:

plot_type (str) – The type of plot to create. Options are “single” or “facetted”. If “single”, plot_dt will plot all the leaves of the DataTree on the same axis. If “facetted”, plot_dt will plot all the leaves of the DataTree on different axes.

Methods

__init__(diagnostic_function, plotting_function)

Initialize the DataSetDiagnostic.

apply(data)

Apply the diagnostic to the data.

apply_dt(dt, *args, **kwargs)

Apply the diagnostic to a DataTree by iterating over the each dataset in the tree.

plot(result[, title])

Plot the diagnostic.

plot_dt(dt, *args, **kwargs)

plot_dt_facetted(dt, var, axes[, label, ...])

Plot the diagnostic by iterating over the leaves of a DataTree.

plot_dt_single(dt, var, ax[, label, colors])

Plot the diagnostic by iterating over the leaves of a DataTree.

Attributes

description

Generate the docstring for the diagnostic.

abstract apply(data)#

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

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

property description#

Generate the docstring for the diagnostic.

plot(result, title=None, **kwargs)#

Plot the diagnostic. Single ax plots.

Parameters:

result (xr.Dataset or xr.DataArray or DataTree) – The output of the diagnostic function.

Returns:

ax – The axis (singular) of the plot.

Return type:

matplotlib.axis.Axis

plot_dt(dt, *args, **kwargs)[source]#
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