A spectral theory for weakly nonlinear instabilities of slowly divergent shear flows