Skip to content

crps

Import path: earth2studio.statistics.crps

View source on GitHub

Documentation

Compute the Continuous Ranked Probability Score (CRPS).

Uses this formula # int [F(x) - 1(x-y)]^2 dx

where F is the emperical CDF and 1(x-y) = 1 if x > y.

This statistic reduces over a single dimension, where the presumed ensemble dimension does not appear in the truth/observation array.

Parameters:

  • ensemble_dimension (str) –

    A name corresponding to a dimension to perform the ensemble reduction over. Example: 'ensemble'

  • reduction_dimensions (list[str] | None, default: None ) –

    A list of dimensions over which to average the crps over. optional, by default none. If none, no additional reduction is done.

  • weights (Tensor | ndarray | None, default: None ) –

    An array containing weights to assign to the reduction dimensions. Note that these weights must have the same number of dimensions as passed in reduction_dimensions. Example: if reduction_dimensions = ['lat', 'lon'] then assert weights.ndim == 2. By default None.

  • fair (bool, default: False ) –

    If true, the CRPS is calculated using the fair CRPS formula. By default False.

__call__

__call__(x: DataArray, y: DataArray) -> DataArray

Apply metric to data x and y, reducing over reduction_dims. y must have every dimension of x except the ensemble dimension, if the metric has one, with matching coordinate values; it is transposed to x's order, not broadcast.

Parameters:

  • x (DataArray) –

    Input array of ensemble forecast or prediction data. This is the array over which the CRPS/CDF is calculated with respect to. reduction_dimensions must be in the dimensions of x.

  • y (DataArray) –

    Observation or validation array. Must not have the ensemble dimension.

Returns:

  • DataArray –

    Returns CRPS array with appropriate reduced coordinates.