An interactive playground

Spectroscopy: reading the barcode in light

Split light into its colours and it stops being just "light". It becomes a measurement. The dark and bright lines in a spectrum tell you what something is made of, how hot it is, how fast it moves and how long ago the light set off.

Each chapter below is a small lab with real physics behind the sliders. They run from a candle flame and an old sodium street lamp to a single unexplained line found by JWST in 2023.

Sunlight through a spectroscope, computed on this page: a 5772 K glow with the dark lines Joseph von Fraunhofer lettered in 1814.
Experiment 1

Where light comes from

Anything warm glows, and the hotter it is the bluer the glow. This thermal light is a smooth rainbow whose peak slides with temperature (Wien's law, λpeak = 2898 µm·K / T). A candle peaks in the infrared and only its blue-starved tail is visible, so it looks orange. The Sun peaks in the green and looks white.

A thin glowing gas is different: it only emits at a few exact colours. That is why street lamps make such a good spectroscopy lesson. Low-pressure sodium lamps, the orange lights of many roads from the 1930s until the 2000s and 2010s, put almost all their light into two lines near 589 nm. That made them the most efficient lamps of the 20th century, and also useless for telling a red car from a blue one. Astronomers loved them: one narrow filter removed their glow from the night sky. Turn up the pressure and the lines smear into a broad peach band with a dark notch in the middle, where cooler sodium at the edge of the arc tube absorbs its own light. Modern white LEDs are a blue chip plus a yellow phosphor, and they spill light across the whole spectrum, which no single filter can remove.

Light-source bench

Inside the orange street lamp

If you grew up under low-pressure sodium lights you probably remember three things: the eerie orange world, the faint buzz, and the dim pink glow when a lamp first came on. Each has a physical cause.

Why only one colour

Sodium has a single outer electron, and its easiest jump is from the ground state (3s) to the next level up (3p). Falling back releases a 589 nm photon. The electron's spin interacting with its orbit splits that level in two, giving the famous doublet at 589.0 and 589.6 nm. In a low-pressure lamp almost every collision ends in that one jump.

Why everything turned grey

With a single wavelength your eye has nothing to compare. A red car and a blue car only differ in how much 589 nm light they reflect, so they become lighter or darker shades of the same orange. Your brain normally adjusts to the colour of the light, but here there is nothing to adjust, and the street looks like an old monochrome photo. Faces looked bloodless because skin's redness was simply not in the light. Compare the fruit row above.

Why they were everywhere

By luck, 589 nm sits near the peak of human vision: the eye is about 76 % as sensitive there as at its best colour, near 555 nm. The bench above computes about 480 lumens per watt of emitted light (some of it is infrared). The best real lamps reached about 200 lm/W (a little less once the ballast is counted), the most efficient lamps until LEDs. For half a century that made them the cheapest way to light a road.

The pink start

Sodium is a solid metal at room temperature, so the tube also holds neon with a trace of argon to strike the arc. That is the dim pink-red glow at switch-on. Over about ten minutes the discharge heats the tube to around 260 °C, the sodium evaporates and takes over, and the colour turns to sodium orange.

The buzz

Old lamps ran on a magnetic ballast, a heavy coil in the lamp head that limits the current. Its iron sheets change length slightly with every half-cycle of the current (magnetostriction), so they hummed at twice the mains frequency: 100 Hz in Europe, 120 Hz in North America. The light flickered at that rate too: too fast to see directly, but it could make spinning wheels and waving hands look jerky.

Engineering tricks

Hot sodium attacks ordinary glass, so the U-shaped tube is lined with sodium-resistant glass, and its small dimples give liquid sodium cool spots to collect in. The outer jacket carries a thin coating that reflects infrared back onto the tube, like a thermos, so the lamp stays hot on little power.

High pressure: broad, with a notch

The peachy high-pressure sodium lamps that followed run far hotter, in a tube of translucent alumina ceramic because no glass survives. The atoms collide so often that the doublet smears into a broad band. Cooler sodium near the tube wall then absorbs the very centre, leaving a dark notch at 589 nm (slide the pressure to 1 above). Colours improve, efficiency drops, and the astronomers' simple filter stops working.

Sodium in the sky

About 90 km up there is a thin natural layer of sodium atoms, left behind by burning meteors. Large telescopes shine 589 nm lasers into it to make an artificial "guide star", measure how the air blurs it, and bend a flexible mirror to undo the blur. The colour of old street lights now helps take some of the sharpest images made from the ground.

Experiment 2

Splitting light: prism or grating

Isaac Newton spread sunlight with a glass prism in 1666 and coined the word spectrum. A prism works because glass slows blue light a little more than red (its refractive index depends on wavelength), so each colour bends by a different amount. The spread is uneven: blue is fanned out widely and red is squeezed together.

In 1821 Fraunhofer built the first precise diffraction grating: 260 fine parallel wires, soon followed by glass plates ruled with a diamond. Each groove re-radiates the light, and the waves add up only in directions where d·sin θ = m·λ. The result is an almost linear spectrum, repeated in several orders m. More grooves under the beam give sharper lines: the resolving power is R = λ/Δλ = m·N. Higher orders spread the colours further but start to overlap: second-order violet lands on top of first-order red.

Spectroscope on a bench
Experiment 3

Fingerprints of the elements

In 1859 Gustav Kirchhoff and Robert Bunsen held salts in Bunsen's new, nearly invisible gas flame and looked through a prism. Every element painted its own pattern of bright lines, the same every time. Sodium was always the yellow pair, lithium a crimson line, potassium a deep red one. Within two years they had found two elements nobody knew existed: caesium, named for its sky-blue lines, and rubidium for its dark red ones.

Kirchhoff then shone strong sunlight through a sodium flame and saw the yellow lines turn darker than the background. The dark D lines in sunlight were sodium, absorbing. His three rules come out of one equation: a cloud of gas in front of a light source adds its own glow and dims what comes from behind, at exactly the colours it can absorb.

  • A hot dense body gives a continuous spectrum (no gas, or a lamp behind thin gas).
  • Hot thin gas on a dark background gives bright lines.
  • Cooler gas in front of a hotter source gives dark lines at the same places. Make the gas exactly as hot as the lamp and the lines vanish completely.
Gas cell in front of a lamp

Reference barcodes

Bright-line patterns as a laboratory spectroscope shows them. Matching an unknown spectrum against such strips is how elements were, and still are, identified.
Experiment 4

The hydrogen ladder

In 1885 a Swiss school teacher, Johann Balmer, found a formula that fitted the four visible hydrogen lines to about one part in 40 000. Nobody knew why it worked. In 1913 Niels Bohr explained it: the electron can only sit on certain rungs with energy En = −13.6 eV / n², and a jump between rungs releases one photon whose energy is the difference. Jumps that end on rung 2 give the visible Balmer series, jumps to rung 1 the ultraviolet Lyman series, and jumps to rungs 3 and 4 the infrared Paschen and Brackett series. Spectral lines were among the first hard evidence for quantum mechanics.

Bohr atom

Why hot stars show the strongest hydrogen lines

In the 1910s Annie Jump Cannon sorted hundreds of thousands of stellar spectra into the classes O B A F G K M, and A stars like Sirius have by far the deepest Balmer lines. That looked like "A stars have the most hydrogen". In 1925 Cecilia Payne showed the opposite. Balmer absorption needs atoms sitting on rung 2. Cool stars have almost none there, and in the hottest stars the hydrogen is ionised. Only near 10 000 K is the balance just right. Correcting for this, she found stars are made mostly of hydrogen and helium, a result so surprising that she was talked into calling it "almost certainly not real". It was real.

Saha–Boltzmann: hydrogen atoms ready to absorb Balmer light
The fraction of all hydrogen in rung n = 2 versus surface temperature (Boltzmann excitation times Saha ionisation, at a fixed electron pressure). The bands are Cannon's spectral classes.
Experiment 5

Doppler shifts and the stretched universe

A source moving away from you has its lines shifted to longer wavelengths, and one moving toward you to shorter. In 1912 Vesto Slipher found the Andromeda galaxy approaching at about 300 km/s. Over the next decade nearly every other galaxy he measured turned out to be receding. Edwin Hubble (1929) tied the shift to distance, and today we read it as space itself stretching while the light is in flight. Astronomers write the stretch as redshift z: every wavelength arrives (1 + z) times longer.

That is why the James Webb Space Telescope works in the infrared. The ultraviolet and visible light of the first galaxies arrives stretched by a factor of 10 or more.

A young galaxy at redshift z
Experiment 6

What the instrument actually sees

A real spectrum is never the perfect one. The spectrograph blurs every line to a width λ/R. The detector chops the spectrum into pixels, and light arrives as countable photons with random (Poisson) noise, plus readout noise and the glow of the sky. Whether two lines can be told apart, and how well a ratio can be measured, depends on all of this together.

Two doublets on this bench carry real physics. The [O II] pair at 3726 and 3729 Å changes its brightness ratio with gas density, so resolving it gives a density meter for galaxies billions of light years away. Hα and Dα are 0.18 nm apart because deuterium is twice as heavy as hydrogen; the same small shift in the Balmer lines is how Harold Urey discovered deuterium in 1931.

Spectrograph simulator
Experiment 7

A single mystery line

Usually a spectrum shows several lines, and their spacing gives the redshift right away. But sometimes there is only one. One emission line is a wavelength with no label. Is it hydrogen Hα from a galaxy 9 billion light years away, Lyman α from one of the first galaxies, or something closer and stranger?

In 2023 JWST pointed its NIRSpec spectrograph at the Hubble Ultra Deep Field in a new way. It opened almost all of its quarter of a million micro-shutters and closed only those over known foreground galaxies, which made a wide slitless survey. Huberty et al. (ApJ 1009, 117, 2026) found one line at 1.6004 µm with no galaxy behind it, even in some of the deepest images ever taken. This lab lets you follow their reasoning, or test yourself on random galaxies.

How you work it out

  1. Is it real? They saw it in four dither positions and two telescope orientations. A cosmic-ray hit or detector glitch does not move with the sky.
  2. Where is it? In slitless spectroscopy a pixel's wavelength depends on where the source sits. Two orientations about 90° apart pin down both the position and the wavelength (see the small figure below the lab).
  3. Guess an identity and predict. Each guess fixes z, and that tells you exactly where its partner lines must appear and how bright some of them must be. Some ratios are fixed by atomic physics ([O III] 5007/4959 = 2.98). Some are fixed by recombination (Hα/Hβ ≈ 2.86 before dust). Some only "usually" hold.
  4. Check the brightness budget. No galaxy shows up in deep imaging, so almost all the light is in the line. Its equivalent width (EW) is enormous, and each identity has a known ceiling.
Line detective
Lines found (matched filter, ≥ 5σ) — pick the one to identify
Your hypothesis — what is this line?

Where is it? Two orientations

With no slit, a source's light is spread sideways along the dispersion direction, so a line at detector position x could come from any spot along a track on the sky, each with a different wavelength. Rotating the telescope by about 90° gives a second track. Only where the tracks cross do both orientations agree on the wavelength. Huberty et al. required agreement within 6 Å. Slide the candidate along the first track.

What the paper concluded

Each everyday identity fails somewhere. As [O III] 5007 its fixed partner at 4959 Å should have been seen at about 3σ. As Hα it needs Hβ (about 3σ, unless dust hides it) and an EW right at the theoretical ceiling for a newborn starburst. As [O II] the EW is far beyond anything known. As Lyman α at z = 12.2 it needs a nearly neutral universe to let the line through, and an EW above 580 Å. A flaring star would show its neighbouring Brackett lines, and a supernova shining in Paβ should show Paγ. The authors suggest it might be transient, perhaps a tidal disruption event or an unusual supernova, which switched on after the 2022 imaging. That removes the EW problem. Tick "transient" above to see how the verdicts loosen. The honest answer, for now, is we don't know. Follow-up spectroscopy should settle it.

History

Who invented it, and how it got better

No single person invented spectroscopy. It grew from a prism experiment into the main way we learn what the universe is made of. Some milestones (the "lab" links jump to the matching experiment):

Today

Is it still state of the art?

Yes. If anything, spectroscopy has never been more central. Images tell you where things are and roughly how bright. Spectra tell you composition, temperature, density, motion and distance, so almost every big new telescope is built around a spectrograph. What keeps improving is the how:

Many objects at once

Fibre-fed spectrographs such as DESI on Kitt Peak take 5000 spectra per pointing to map tens of millions of galaxies. Integral-field units such as MUSE take a spectrum at every pixel of an image.

Extreme precision

HARPS-class spectrographs measure stellar wobbles near 1 m/s and ESPRESSO aims for 10 cm/s, calibrated with frequency combs. The Earth tugs the Sun by only about 9 cm/s.

Clocks

The best clocks are spectroscopy: lasers locked to one narrow atomic transition (strontium, ytterbium) keep time to about a second in the age of the universe.

Is there something better?

For some questions, yes, or rather complementary. Photometric redshifts (colours from images) are far cheaper for huge samples, but less precise. Gravitational waves and neutrinos carry information light cannot. Mass spectrometry, a cousin that sorts by mass instead of colour, beats optical methods for many chemistry jobs.

Where it branched out

The idea of "measure how something responds, colour by colour" spread far beyond astronomy:

Medicine

Your pulse oximeter is a two-colour spectrometer: oxygenated blood absorbs red and infrared light differently. MRI grew out of NMR spectroscopy, and police breath-alcohol instruments use infrared absorption.

Chemistry & industry

Infrared and Raman spectra are fingerprints of molecules, used to check medicines, sort plastics for recycling, grade food and catch art forgeries by their pigments.

Earth from space

Hyperspectral satellites map minerals, crop health and algae. Dedicated instruments spot methane and CO₂ plumes from individual facilities.

Other worlds

Mars rovers zap rocks with a laser and read the flash (ChemCam, SuperCam). JWST reads exoplanet atmospheres in starlight filtered through them during transits.

Physics itself

Quantum mechanics was built to explain spectral lines. The Lamb shift in hydrogen spurred modern quantum electrodynamics, and today spectroscopy tests whether the constants of nature drift.

Cosmology

Redshift surveys measure the expansion history of the universe and dark energy. The cosmic microwave background's blackbody spectrum is the most perfect one ever measured.

What is computed and what is simplified

  • Computed exactly: Planck curves, Wien's law, hydrogen wavelengths (Rydberg), the grating equation, prism refraction with Sellmeier glass data, the vacuum-to-air conversion (Morton 2000), flat ΛCDM ages and distances (Planck 2018 parameters), Saha–Boltzmann populations, the [O II] density relation (Sanders et al. 2016) and colours via the CIE 1931 observer (multi-lobe fit). The built-in tests check these against known values.
  • Approximate: line lists keep only the strongest lines with rough relative intensities (real ratios change with temperature and lamp). Lamp spectra (sodium pressure, LEDs, fluorescent phosphors) are hand-built models with the right shapes, not measured spectra. The gas cell uses a single Gaussian line width and ignores excitation changes. Colour rendering uses partial chromatic adaptation. The grating's order brightnesses are illustrative.
  • The mystery line: the spectrum is regenerated from the paper's published numbers (1.6004 µm, 2.5×10⁻¹⁸ erg s⁻¹ cm⁻², FWHM 13.2 Å, noise tuned to its ~9×10⁻¹⁹ 3σ limits, imaging EW limit 7620 Å). It is not the real data. Expected companion ratios and EW ceilings are rounded literature values. The detective reasons from the paper's own measurements (Table 2). Partner wavelengths are scaled from the exact redshift; the paper quotes some from rounded redshifts (z = 1.44, 2.20), so a few differ by ~10 Å (for example [O III] 4959 at 1.5851 µm here, 15 864 Å in the paper). The verdicts are a teaching aid, not a re-analysis. The random galaxies use typical line ratios, a Calzetti dust law and a rough IGM transmission.
  • History and facts: dates, names and numbers in the prose, timeline and "Today" cards were checked against encyclopaedias, original papers and manufacturer data in November 2026. Rounded figures (lamp efficacy, wobble sizes, clock precision) are given as "about".
  • Galaxy at redshift z: a schematic young-galaxy spectrum displayed at low resolution so the lines are visible on a log axis. Its "velocity" readout is the special-relativistic Doppler equivalent. Cosmological redshift is not really a velocity.