The simplest way to explain it is they break down the light that is passing through the atmosphere of the planet. Different gases have different effects on how light passes through them. With the right equipment, and most importantly knowledge, they can identify a lot of what an atmosphere is made of from amazing distances.
Latest Answers