Mechanism for the green glow of the upper ionosphere