Modeling of optical pumping experiments in CO. I. Time-resolved experiments