def binary_mse_compute(bmse, return_scales=True):
    """
    Compute the BMSE.

    Parameters
    ----------
    bmse: dict
        The BMSE object initialized with
        :py:func:`pysteps.verification.spatialscores.binary_mse_init`
        and accumulated with
        :py:func:`pysteps.verification.spatialscores.binary_mse_accum`.
    return_scales: bool, optional
        Whether to return the spatial scales resulting from the wavelet
        decomposition.

    Returns
    -------
    BMSE: array_like
        One-dimensional array containing the binary MSE for each spatial scale.
    scales: list, optional
        If ``return_scales=True``, return the spatial scales in pixels resulting
        from the wavelet decomposition.
    """

    scales = bmse["scales"]
    n_scales = len(scales)
    eps = bmse["eps"]

    BMSE = np.zeros(n_scales)
    for j in range(n_scales):
        mse = bmse["mse"][j]
        BMSE[j] = 1 - mse / (2 * eps * (1 - eps) / n_scales)

    BMSE[~np.isfinite(BMSE)] = np.nan

    if return_scales:
        return BMSE, scales
    else:
        return BMSE
Compute the BMSE.

Parameters
----------
bmse: dict
The BMSE object initialized with
:py:func:`pysteps.verification.spatialscores.binary_mse_init`
and accumulated with
:py:func:`pysteps.verification.spatialscores.binary_mse_accum`.
return_scales: bool, optional
Whether to return the spatial scales resulting from the wavelet
decomposition.

Returns
-------
BMSE: array_like
One-dimensional array containing the binary MSE for each spatial scale.
scales: list, optional
If ``return_scales=True``, return the spatial scales in pixels resulting
from the wavelet decomposition.
pysteps/verification/spatialscores.py