Modal analysis of inhomogeneous optical resonators.