earthkit.meteo.score.crps_from_cdf¶
- earthkit.meteo.score.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 anxarray.Datasetwith no new dimension added; instead it contains data variables namedcrps,underforecast_penalty, andoverforecast_penaltyat the same non-threshold coordinates. The overall CRPS is given byunderforecast_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 dimensionover.obs (
xarray DataArray) – Observations (not in CDF form). Must not include theoverdimension.over (
str) – The single threshold dimension for the CDF values.weight (
xarray DataArray, optional) – Threshold weights alongover. Must includeoveras a dimension and be broadcastable tofcst. IfNone, 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:
xarray.DataArrayorxarray.Dataset– The CRPS of the CDF compared to the observations.The function returns an objectofthe same type as the input arguments.
- Return type:
xarray.DataArray