earthkit.meteo.score.xarray.crps_from_cdf

earthkit.meteo.score.xarray.crps_from_cdf(fcst, obs, over, weight=None, return_components=False)

Calculates the continuous ranked probability score (CRPS) for forecasts provided as CDFs.

Warning

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

The CRPS score for a CDF forecast is defined as:

\begin{align*} o(x) &= 0 ~\text{if}~ x < \text{obs and}~ 1 ~\text{if}~ x \ge \text{obs}, \\ \operatorname{CRPS}\left[f, o\right] &= \int_{-\infty}^{\infty}{w(x)\,(f(x) - o(x))^2\,\text{d}x} \end{align*}

where:

  • \(f\) is the forecast CDF,

  • \(o\) is the observation converted to CDF form,

  • \(w(x)\) is an optional non-negative threshold weight function.

With return_components=True, this function returns the decomposition defined below. The output is an xarray.Dataset with no new dimension added; instead it contains data variables named crps, underforecast_penalty, and overforecast_penalty at the same non-threshold coordinates. The overall CRPS is given by underforecast_penalty + overforecast_penalty.

\[\operatorname{CRPS}[f, o] = O(f, o) + U(f, o)\]
\begin{align*} O(f, o) &= \int_{\text{obs}}^{\infty}{w(x)\,(f(x) - 1)^2\, \text{d}x} \quad& \text{(overforecast penalty)} \\ U(f, o) &= \int_{-\infty}^{\text{obs}}{w(x)\,f(x)^2\,\text{d}x} \quad& \text{(underforecast penalty)} \end{align*}

Note that there are several ways to decompose the CRPS and this decomposition differs from the one used in crps_from_ensemble().

See also

This function leverages the scores.probability.crps_cdf function.

Parameters:
  • fcst (xarray DataArray) – Forecast CDF values with threshold dimension over.

  • obs (xarray DataArray) – Observations (not in CDF form). Must not include the over dimension.

  • over (str) – The single threshold dimension for the CDF values.

  • weight (xarray DataArray, optional) – Threshold weights along over. Must include over as a dimension and be broadcastable to fcst. If None, a weight of 1 is used.

  • return_components (bool, optional) – Whether to return the under/over forecast components as additional data variables. Default is False.

Returns:

The CRPS of the CDF compared to the observations.

Return type:

xarray.DataArray or xarray.Dataset