Skip to main content
โ† Back to Exoplanet Science samples
๐ŸชExoplanet Scienceยท20 minยทSample Lesson

Atmospheric Retrieval Codes: Reading an Exoplanet's Air from Light

In September 2023, astronomers pointed the James Webb Space Telescope at K2-18b, a planet 124 light-years away that we will never visit, land a probe on, or photograph up close. Yet within weeks they announced they had detected dimethyl sulfide and methane in its atmosphere -- specific molecules, on a specific planet, trillions of miles away. They didn't do this with a giant zoom lens. They did it with atmospheric retrieval codes: software that takes a smear of starlight and mathematically reconstructs what gases a planet's atmosphere contains, layer by layer.

What You'll Learn

- How transmission spectroscopy captures a fingerprint of an exoplanet's atmosphere - What a retrieval code actually calculates, and why it's a statistics problem, not a photography problem - The role of Bayesian inference and molecular absorption lines in identifying gases - Why the same starlight data can support more than one interpretation, and how scientists handle that uncertainty

Starlight as a Chemistry Report

When an exoplanet passes in front of its star (a transit), some starlight grazes through the thin ring of the planet's atmosphere on its way to our telescopes. Different gases absorb light at very specific wavelengths -- water vapor, methane, and carbon dioxide each leave a distinct pattern of dips in the spectrum, like a barcode. Webb's instruments split that starlight into hundreds of narrow wavelength channels and measure exactly how much dimmer the star appears at each one during a transit. The result is a transmission spectrum: a graph of brightness dips across wavelengths. But a spectrum alone doesn't tell you the answer -- it's raw data. Turning it into 'this atmosphere is 90% hydrogen with traces of methane' requires the retrieval code.

How a Retrieval Code Actually Works

A retrieval code starts by building a model atmosphere from scratch: it guesses a temperature structure, a mix of gases, and a cloud layer, then calculates what transmission spectrum that imaginary atmosphere would produce. It compares that prediction to the real Webb data. If they don't match, the code adjusts its guesses -- more methane, less cloud, a different temperature -- and tries again. This is repeated using a statistical method called Bayesian inference, often implemented through algorithms like MCMC (Markov Chain Monte Carlo) or nested sampling, which can test hundreds of thousands to millions of atmosphere combinations. Each combination gets scored on how well it matches the data, and the code gradually converges on the range of atmosphere models that are most probable given the evidence -- not a single certain answer, but a probability distribution.

Why 'Retrieval' and Not 'Detection'

Scientists deliberately use the word 'retrieval' rather than 'detection' because the code isn't directly seeing molecules -- it's retrieving the most statistically likely explanation for the light pattern. That's why K2-18b's dimethyl sulfide claim was reported with a confidence level (around 3-sigma, meaning roughly a 1-in-370 chance it's a statistical fluke) rather than certainty -- 3-sigma is promising but well short of the 5-sigma standard usually required to call a result a confirmed discovery in physics.

Why the Same Data Can Have Multiple Explanations

A major challenge in this field is degeneracy: different combinations of gases and cloud layers can sometimes produce very similar spectra. For K2-18b, some retrieval teams' codes favored a mix including dimethyl sulfide (a molecule that on Earth is produced almost exclusively by living organisms, like marine phytoplankton), while other teams re-analyzed the same public data and argued the dip could instead be explained by other sulfur compounds or by carbon dioxide combined with clouds -- with no life required at all. This is why exoplanet scientists now routinely run multiple independent retrieval codes (with names like petitRADTRANS, NEMESIS, and POSEIDON) on the same dataset before publishing, and why they report confidence levels instead of flat statements. The debate over K2-18b is still unresolved as of 2026, precisely because retrieval is a statistical best-fit process, not a direct readout.

โ“

What is a transmission spectrum actually measuring?

โ“

Why did scientists disagree about the dimethyl sulfide detection on K2-18b even though they were looking at the same Webb data?

๐ŸŽฏ

Build a Simple 'Retrieval' by Hand

On paper, draw a simple graph with wavelength (1 to 5, arbitrary units) on the x-axis and 'brightness dip' (0 to 10) on the y-axis. Plot 5 fake data points representing a spectrum. Then create two different 'model atmospheres' (Model A: mostly water vapor; Model B: water vapor plus methane) and sketch a curve for each that could reasonably pass through your 5 points. Write 2-3 sentences explaining which model you think fits better and why, and what real retrieval codes do differently (test thousands of models, not just two) to reach a more reliable answer.

Go Further

Search for 'petitRADTRANS' or 'POSEIDON exoplanet retrieval' to see real open-source retrieval codes that scientists use -- some are available for anyone to explore, including students.

Want to keep learning?

Sign up for free to access the full curriculum โ€” all subjects, all ages.

Start Learning Free