def ensemble_spread(X_f, metric, **kwargs):
    """
    Compute mean ensemble spread for a given skill metric.

    Parameters
    ----------
    X_f: array-like
        Array of shape (l,m,n) containing the forecast fields of shape (m,n)
        from l ensemble members.
    metric: str
        The deterministic skill metric to be used (list available in
        :func:`~pysteps.verification.interface.get_method`).

    Returns
    -------
    out: float
        The mean skill compted between all possible pairs of
        the ensemble members,
        which can be used as definition of mean ensemble spread (as in Zacharov
        and Rezcova 2009 with the FSS).

    References
    ----------
    :cite:`ZR2009`
    """
    if len(X_f.shape) != 3:
        raise ValueError(
            "the number of dimensions of X_f must be equal to 3, "
            + "but %i dimensions were passed" % len(X_f.shape)
        )
    if X_f.shape[0] < 2:
        raise ValueError(
            "the number of members in X_f must be greater than 1,"
            + " but %i members were passed" % X_f.shape[0]
        )

    compute_spread = get_method(metric, type="deterministic")

    lolo = X_f.shape[0]
    spread = []
    for member in range(lolo):
        for othermember in range(member + 1, lolo):
            spread_ = compute_spread(
                X_f[member, :, :], X_f[othermember, :, :], **kwargs
            )
            if isinstance(spread_, dict):
                spread_ = spread_[metric]
            spread.append(spread_)

    return np.mean(spread)
Compute mean ensemble spread for a given skill metric.

Parameters
----------
X_f: array-like
Array of shape (l,m,n) containing the forecast fields of shape (m,n)
from l ensemble members.
metric: str
The deterministic skill metric to be used (list available in
:func:`~pysteps.verification.interface.get_method`).

Returns
-------
out: float
The mean skill compted between all possible pairs of
the ensemble members,
which can be used as definition of mean ensemble spread (as in Zacharov
and Rezcova 2009 with the FSS).

References
----------
:cite:`ZR2009`
pysteps/verification/ensscores.py