earth2studio.statistics
.crps#
- class earth2studio.statistics.crps(ensemble_dimension, reduction_dimensions=None, weights=None)[source]#
Compute the Continuous Ranked Probably 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 tensor.
- Parameters:
ensemble_dimension (str) – A name corresponding to a dimension to perform the ensemble reduction over. Example: ‘ensemble’
reduction_dimensions (list[str]) – A list of dimensions over which to average the crps over. optional, by default none. If none, no additional reduction is done.
weights (torch.Tensor, optional) – A tensor 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.
- __call__(x, x_coords, y, y_coords)[source]#
Apply metric to data x and y, checking that their coordinates are broadcastable. While reducing over reduction_dims.
- Parameters:
x (torch.Tensor) – Input tensor of ensemble forecast or prediction data. This is the tensor over which the CRPS/CDF is calculated with respect to.
x_coords (CoordSystem) – Ordered dict representing coordinate system that describes the x tensor. reduction_dimensions must be in coords.
y (torch.Tensor) – Observation or validation tensor.
y_coords (CoordSystem) – Ordered dict representing coordinate system that describes the y tensor. reduction_dimensions must be in coords.
- Returns:
Returns CRPS tensor with appropriate reduced coordinates.
- Return type:
tuple[torch.Tensor, CoordSystem]