Nonlinear Harmonic Analysis of Unsteady Transonic Inviscid and Viscous Flows