Self-Absorption in Resonance Raman and Rayleigh Scattering: A Numerical Solution