def spec_sum(ph2):
    """Compute total spectral sum of the real spectral quantity``ph^2``.

    Parameters
    ----------
    model : pyqg.Model instance
        The model object from which `ph` originates
    ph2 : real array
        The field on which to compute the sum

    Returns
    -------
    var_dens : float
        The sum of `ph2`
    """
    ph2 = 2.0 * ph2
    ph2[..., 0] = ph2[..., 0] / 2.0
    ph2[..., -1] = ph2[..., -1] / 2.0
    return ph2.sum(axis=(-1, -2))
