<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_var(model, ph):
 """Compute variance of ``p`` from Fourier coefficients ``ph``. Parameters model : pyqg.Model instance The model object from which `ph` originates ph : complex array The field on which to compute the variance Returns ------- var_dens : float The variance of `ph` """


    var_dens = 2. * np.abs(ph)**2 / model.M**2
    # only half of coefs [0] and [nx/2+1] due to symmetry in real fft2
    var_dens[...,0] /= 2
    var_dens[...,-1] /= 2
    return var_dens.sum(axis=(-1,-2))