earth2studio.statistics
.rank_histogram#
- class earth2studio.statistics.rank_histogram(ensemble_dimension, reduction_dimensions, number_of_bins=None, randomize_ties=True)[source]#
Compute the Rank Histogram for a given set of ensemble forecasts.
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 ranking over. Example: ‘ensemble’
reduction_dimensions (list[str]) – A list of dimensions over which to bin the ranks
number_of_bins (int | None, optional) – The number of bins to discretize the unit interval over. Best set to ensemble_size + 1, which is set automatically when None, by default None
randomize_ties (bool, optional) – When True randomize the rank in cases where multiple ensemble members are exactly equal to the observation. This produces an unbiased distribution of ranks in cases where ties occur frequently. If False, the rank will be computed as if the observation were larger than the tied ensemble members, by default True
- __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_dimensions.
- Parameters:
x (torch.Tensor) – Input tensor of ensemble data. The rank of observation input tensor y is determined with respect to the ensemble dimension of x.
x_coords (CoordSystem) – Ordered dict representing coordinate system that describes the x tensor. reduction_dimensions must be in coords.
y (torch.Tensor) – The observation input tensor.
y_coords (CoordSystem) – Ordered dict representing coordinate system that describes the y tensor. reduction_dimensions must be in coords.
- Returns:
Returns rank histogram tensor with appropriate reduced coordinates.
- Return type:
tuple[torch.Tensor, CoordSystem]