earth2studio.statistics
.fss#
- class earth2studio.statistics.fss(reduction_dimensions, window_sizes, thresholds, spatial_dimensions=None, ensemble_dimension=None, batch_update=False)[source]#
Statistic for calculating the fractions skill score (FSS) of one tensors with respect to another over a set of given dimensions.
If ensemble_dimension is provided, computes the probabilistic FSS as defined by Necker et al. (2024): https://doi.org/10.1002/qj.4824.
- Parameters:
reduction_dimensions (List[str]) – A list of names corresponding to dimensions to perform the statistical reduction over. Example: [‘lat’, ‘lon’]
window_sizes (ArrayLike[int]) – A list of the window sizes (in pixels) applied when calculating FSS.
thresholds (ArrayLike[float]) – A list of the thresholds applied when calculating FSS.
spatial_dimensions (Tuple[str, str] | None = None) – Indicates the spatial dimensions. If None, it is assumed that these are the last two dimensions.
ensemble_dimension (str | None = None) – Ensemble dimension for computation of probabilistic FSS. If None (default), forecast is interpreted as deterministic.
batch_update (bool = False) – Whether to apply batch updates to the FSS with each invocation of __call__. This is particularly useful when data is recieved in a stream of batches. Each invocation of __call__ will return the running FSS.
- __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, typically the forecast or prediction tensor.
x_coords (CoordSystem) – Ordered dict representing coordinate system that describes the x tensor. reduction_dimensions must be in x_coords, as do ensemble_dimension and spatial_dimensions if provided in constructor.
y (torch.Tensor) – Input tensor #2 intended to be used as validation data..
y_coords (CoordSystem) – Ordered dict representing coordinate system that describes the y tensor. reduction_dimensions must be in y_coords, do spatial_dimensions if provided in constructor.
- Returns:
Returns root mean squared error tensor with appropriate reduced coordinates.
- Return type:
tuple[torch.Tensor, CoordSystem]