Skip to content

log_spectral_distance

Import path: earth2studio.statistics.log_spectral_distance

View source on GitHub

Documentation

Statistic for calculating the radially averaged 2D log spectral distance (LSD) of one tensor with respect to another over a set of given dimensions. This is given in decibel (dB) as 10 * sqrt( mean( log10( psd(x) / psd(y) )**2 ) ).

Parameters:

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

    A list of names corresponding to additional dimensions (besides the wavenumber) to perform the statistical reduction over.

  • spatial_dimensions (tuple[str, str] | None, default: None ) –

    Indicates the spatial dimensions. If None, it is assumed that these are the last two dimensions.

  • ensemble_dimension (str | None, default: None ) –

    Indicates the ensemble dimension, if not None. The LSD is computed between each ensemble member in the prediction and the corresponding observation.

  • wavenumber_cutoff (int | None, default: None ) –

    If a positive integer, use only the first wavenumber_cutoff modes to compute LSD. If a negative integer, use all except the last -wavenumber_cutoff modes. If None (default), use all modes.

  • batch_update (bool, default: False ) –

    Whether to apply batch updates to the LSD 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 LSD.

__call__

__call__(
    x: Tensor,
    x_coords: CoordSystem,
    y: Tensor,
    y_coords: CoordSystem,
) -> tuple[Tensor, CoordSystem]

Apply metric to data x and y, checking that their coordinates are broadcastable. While reducing over reduction_dims.

If batch_update was passed True upon metric initialization then this method returns the running sample RMSE over all seen batches.

Parameters:

  • x (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 (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:

  • tuple[Tensor, CoordSystem] –

    Returns root mean squared error tensor with appropriate reduced coordinates.