Did you know that we can measure the magnetic field on the surface of the Sun?
That is something I find absolutely marvellous, that we can measure magnetism on something over 92 million miles away from here, on a surface that’s over 5000 degrees celsius. It’s one hell of a trick, for sure.
It’s accomplished by using a phenomenon called the Zeeman effect, and just a pinch of quantum mechanics. Electrons orbiting the nucleus are only allowed in a set of distinct energy levels, so they can only absorb energy to jump from one level to another. Photons of light have only a certain energy related to their wavelength (or colour); this means that to jump from one given energy level to another, only a very specific colour of light will do.
This means that when certain colours of light hit that atom, they’ll be absorbed and cause electrons to jump into higher energy levels. This causes certain colours of light to be missing when you look at a rainbow (or spectrum) of the light. You can calculate where these lines would be from quantum mechanics. This is how we know what the Sun is made from, for instance.
Now, when you add a magnetic field to the mix, things get a little more interesting. The magnetic field affects the orbit of the electrons, and splits one energy level into many more. This means that there are now more ways for electrons to jump from one level to another, so your neat little spectral absorbtion line will split into many lines: this is the Zeeman effect. You can tell from how much the line has split what the magnetic field strength is.
All these results can be calculated from quantum mechanics, and the Zeeman effect works just as well here on the ground as it does in the Sun. It’s brilliant!
Extra: Spectral lines work in reverse, too. Electrons in higher energy levels in an atom can only lose energy and go into a lower level by emitting a photon of a precise colour. Streetlights, for instance, work by exciting electrons in sodium, which then emit a photon of a very particular orange colour as they drop down into a lower level. This means that streetlights are almost exactly monochromatic (i.e. a single colour).