Dynamic Coarse-Graining Via Large-Deviation Theory