Medium effects for terrestrial and atmospheric neutrino oscillations