xskillscore.rank_histogram

xskillscore.rank_histogram(observations, forecasts, dim=None, member_dim='member', random_for_tied=True, keep_attrs=True)

Returns the rank histogram (Talagrand diagram) along the specified dimensions.

Parameters:
  • observations (xarray.Dataset or xarray.DataArray) – The observations or set of observations.

  • forecasts (xarray.Dataset or xarray.DataArray) – Forecast with required member dimension member_dim.

  • dim (str or list of str, optional) – Dimension(s) over which to compute the histogram of ranks. Defaults to None meaning compute over all dimensions

  • member_dim (str, optional) – Name of ensemble member dimension. By default, ‘member’.

  • random_for_tied (bool) – Whether to randomly generate ranks for tied values so that, on average, tied values result in a flat histogram - see Hamill 2001

  • keep_attrs (bool, optional) – Whether to copy attributes from the first argument to the output.

Returns:

  • rank_histogram (xarray.Dataset or xarray.DataArray) – New object containing the histogram of ranks

  • Reference

  • ———

  • * Hamill, T. M. (2001). Interpretation of Rank Histograms for Verifying – Ensemble Forecasts. Monthly Weather Review, 129(3), 550–560. doi: 10/dkkvh3

Examples

>>> observations = xr.DataArray(
...     np.random.normal(size=(3, 3)),
...     coords=[("x", np.arange(3)), ("y", np.arange(3))],
... )
>>> forecasts = xr.DataArray(
...     np.random.normal(size=(3, 3, 3)),
...     coords=[("x", np.arange(3)), ("y", np.arange(3)), ("member", np.arange(3))],
... )
>>> xs.rank_histogram(observations, forecasts, dim="x")
<xarray.DataArray 'histogram_rank' (y: 3, rank: 4)> Size: 96B
array([[0, 0, 1, 2],
       [0, 1, 2, 0],
       [0, 0, 2, 1]])
Coordinates:
  * y        (y) int64 24B 0 1 2
  * rank     (rank) float64 32B 1.0 2.0 3.0 4.0

Notes

See http://www.cawcr.gov.au/projects/verification/