def recompose_fft(decomp, **kwargs):
    """
    Recompose a cascade obtained with decomposition_fft by inverting the
    normalization and summing the cascade levels.

    Parameters
    ----------
    decomp: dict
        A cascade decomposition returned by decomposition_fft.

    Returns
    -------
    out: numpy.ndarray
        A two-dimensional array containing the recomposed cascade.
    """
    levels = decomp["cascade_levels"]
    if decomp["normalized"]:
        mu = decomp["means"]
        sigma = decomp["stds"]

    if not decomp["normalized"] and not (
        decomp["domain"] == "spectral" and decomp["compact_output"]
    ):
        result = np.sum(levels, axis=0)
    else:
        if decomp["compact_output"]:
            weight_masks = decomp["weight_masks"]
            result = np.zeros(weight_masks.shape[1:], dtype=complex)

            for i in range(len(levels)):
                if decomp["normalized"]:
                    result[weight_masks[i]] += levels[i] * sigma[i] + mu[i]
                else:
                    result[weight_masks[i]] += levels[i]
        else:
            result = [levels[i] * sigma[i] + mu[i] for i in range(len(levels))]
            result = np.sum(np.stack(result), axis=0)

    if "field_mean" in decomp:
        result += decomp["field_mean"]

    return result
Recompose a cascade obtained with decomposition_fft by inverting the
normalization and summing the cascade levels.

Parameters
----------
decomp: dict
A cascade decomposition returned by decomposition_fft.

Returns
-------
out: numpy.ndarray
A two-dimensional array containing the recomposed cascade.
pysteps/cascade/decomposition.py