diagnostic.diagnostic.Model2Self#

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

Bases: DataSetDiagnostic

A class representing a diagnostic that compares a model to itself.

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

Initialize the Model2Self diagnostic.

Methods

__init__(diagnostic_function, plotting_function)

Initialize the Model2Self diagnostic.

apply(ds[, mask])

Apply the diagnostic to the data.

apply_dt(dt[, mask])

Apply the diagnostic to a DataTree.

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.

apply(ds: Dataset, mask=None, **kwargs)[source]#

Apply the diagnostic to the data.

Parameters:

ds (xr.Dataset) – The data to apply the diagnostic to.

Returns:

The data after applying the diagnostic.

Return type:

xr.Dataset

apply_dt(dt: DataTree, mask=None, **kwargs)[source]#

Apply the diagnostic to a DataTree.

Parameters:

dt (DataTree) – The DataTree to apply the diagnostic to.

Returns:

The DataTree 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)#
plot_dt_facetted(dt, var, axes, label='name', shared_cbar=None, **kwargs)#

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)#

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