earthkit.meteo.score.xarray.crps_from_ensemble

earthkit.meteo.score.xarray.crps_from_ensemble(fcst, obs, over, method='ecdf', return_components=False, decomposition_method='underover')

Calculates the continuous ranked probability score (CRPS) of an ensemble forecast.

Warning

Experimental API. This function may change or be removed without notice.

The CRPS score for an ensemble forecast is defined as:

\begin{align*} \operatorname{CRPS}\left[f, o\right] = \frac{\sum_{i=1}^{M}(|f_i - o|)}{M} - \frac{\sum_{i=1}^{M}\sum_{j=1}^{M}(|f_i - f_j|)}{2K} \end{align*}

where:

  • \(f\) is the probabilistic ensemble forecast,

  • \(o\) are the observations,

  • \(K=M^2\) for the ‘ecdf’ method and \(M(M-1)\) for the ‘fair’ method,

With return_components=True, this function returns an xr.Dataset with variables for the decompositions defined below.

If the decomposition_method=”underover”, the xr.Dataset variables values are underforecast_penalty, overforecast_penalty, spread and either fcrps if method=”fair” or crps if method=”ecdf” (ordering is not guaranteed and might differ). The overall CRPS is given by underforecast_penalty + overforecast_penalty - spread.

\[\operatorname{CRPS}[f, o] = O(f, o) + U(f, o) - S(f, f)\]

where

\begin{align*} O(f, o) &= \frac{1}{M} \sum_{i=1}^{M} (f_i - o)\, \mathbb{1}_{\{f_i > o\}} \quad& \text{(overforecast penalty)} \\ U(f, o) &= \frac{1}{M} \sum_{i=1}^{M} (o - f_i)\, \mathbb{1}_{\{f_i < o\}} \quad& \text{(underforecast penalty)} \\ S(f, f) &= \frac{1}{2K} \sum_{i=1}^{M} \sum_{j=1}^{M} |f_i - f_j| \quad& \text{(forecast spread term)} \end{align*}

If the decomposition method is decomposition_method=”hersbach”, the xr.Dataset variables values are alpha, beta, crps and additionally also fcrps if method=”fair” (ordering is not guaranteed and might differ).

We denote by \(x_1 \le x_2 \le \dots \le x_M\) the members of the ensemble forecast \(f\) after sorting. The unfair CRPS decomposition for decomposition_method=”hersbach” is then given by

\begin{align*} \operatorname{CRPS}\left[f, o\right] = \sum_{i=1}^{M} \alpha_i p_i^2 + \beta_i (1-p_i)^2 \end{align*}

where

\begin{align*} \alpha_i = & \begin{cases} o - x_M & \text{if } o > x_M \\ x_{i+1} - x_i & \text{if } o > x_{i+1} \\ o - x_i & \text{if } x_{i+1} > o > x_{i} \\ 0 & \text{if } o < x_{i} \\ 0 & \text{if } o < x_{1} \\ \end{cases} \\ \beta_i = & \begin{cases} 0 & \text{if } o > x_M \\ 0 & \text{if } o > x_{i+1} \\ x_{i+1} - o & \text{if } x_{i+1} > o > x_{i} \\ x_{i+1} - x_i & \text{if } o < x_{i} \\ x_1 - o & \text{if } o < x_{1} \\ \end{cases} \\ p_i = & \begin{cases} \frac{i}{M} & \text{if } 0<i<M \\ 0 & \text{if } i=0 \\ 1 & \text{if } i=M \\ \end{cases} \end{align*}

Fair CRPS is obtained by adding a correcting term \(\frac{G}{2M}\) to the previous expression i.e.

\begin{align*} \operatorname{CRPS}\left[f, o\right] = \sum_{i=1}^{M} \alpha_i p_i^2 + \beta_i (1-p_i)^2 - \frac{G}{2M} \end{align*}

where

\[G = \frac{\sum_{i=1}^{M} \sum_{j=1}^{M} |x_i - x_j|}{M (M-1)}\]

Note that other CRPS decompositions exist; compare crps_from_cdf().

When return_components=False, only a xr.DataArray of the total CRPS is returned.

See also

This function leverages the scores.probability.crps_for_ensemble function.

Parameters:
  • fcst (xarray.DataArray) – The ensemble forecast xarray.

  • obs (xarray.DataArray) – The observations xarray.

  • over (str or list of str) – The dimension(s) over which to compute the CRPS.

  • method (str, optional) – The method to compute the CRPS. Either ‘ecdf’ or ‘fair’. Default is ‘ecdf’.

  • return_components (bool, optional) – Whether to return the components of the CRPS. Default is False.

  • decomposition_method (Literal['underover', 'hersbach'])

Returns:

The CRPS of the ensemble forecast compared to the observations.

Return type:

xarray.DataArray or xarray.Dataset