<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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.*ph2
    ph2[...,0] = ph2[...,0]/2.
    ph2[...,-1] = ph2[...,-1]/2.

    return ph2.sum(axis=(-1,-2))