# Atmospheric Retrievals with petitRADTRANS

Evert Nasedkin¹¶, Paul Mollière¹, and Doriann Blain¹

1 Max Planck Institut für Astronomie, DE ¶ Corresponding author

DOI: 10.21105/joss.05875

## Software

* Review 🐰

* Repository 🐰

* Archive 🐰

Editor: Dan Foreman-Mackey 👎

## Reviewers:

* @QuentChangeat

* @VChristiaens

Submitted: 12 September 2023

Published: 02 April 2024

## License

Authors of papers retain copyright and release the work under a Creative Commons Attribution 4.0 International License (CC BY 4.0).

## Summary

petitRADTRANS (pRT) is a fast radiative transfer code used for computing emission and transmission spectra of exoplanet atmospheres (Mollière et al., 2019), combining a FORTRAN back end with a Python based user interface. It is widely used in the exoplanet community with 222 references in the literature to date, and has been benchmarked against numerous similar tools, including many listed in (MacDonald & Batalha, 2023). The spectra calculated with pRT can be used as a forward model for fitting spectroscopic data using Monte Carlo techniques, commonly referred to as an atmospheric retrieval (Madhusudhan & Seager, 2009). The new retrieval module combines fast forward modelling with nested sampling codes, allowing for atmospheric retrievals on a large range of different types of exoplanet data. Thus it is now possible to use pRT to easily and quickly infer the atmospheric properties of exoplanets in both transmission and thermal emission.

## Statement of need

Atmospheric retrievals are a cornerstone of exoplanet atmospheric characterisation. Previously this required interfacing with a sampler and writing a likelihood function in order to explore a parameter space and fit input data, following the description provided in (Mollière et al., 2019). pRT now provides a powerful and user-friendly tool for researchers to fit exoplanet spectra with a range of built-in or custom atmospheric models. Various thermal structures, chemistry and cloud parameterisations and opacity calculation methods can be combined and used to perform parameter estimation and model comparison for a given atmospheric spectrum. The new retrieval module standardises data input, parameter setup, likelihood calculation and interfaces with Multinest, allowing for both simple 'out-of-the-box' retrievals as well as fully customisable setups. New tutorials and documentation have been published to facilitate the adoption of the retrieval module as a widely used tool in the exoplanet community. With increasing volumes of both ground- and space-based spectra available, it is necessary for exoplanet researchers to have access to a range of characterisation tools. While many other retrieval codes exist, pRT offers a computationally efficient and highly flexible framework for inferring the properties of a wide variety of exoplanets. While most feature of pRT are available in other retrieval codes, few of the implement the diversity of the pRT feature set; the availability of both correlated-k and line-by-line opacities, free, equilibrium, and disequilibrium chemistry, and multiple cloud implementations in a single framework let it stand out as a uniquely flexible approach to atmospheric retrievals.

## petitRADTRANS Retrieval Module

The new retrieval module combines the existing Radtrans forward modelling class with a nested sampler via a likelihood function to perform an atmospheric retrieval. Both MultiNest (Buchner et al., 2014; Feroz et al., 2009, 2019; Feroz & Hobson, 2008) and Ultranest (Buchner
et al., 2014; Buchner, 2019) samplers are available, with both offering MPI implementations that allow for easy parallelisation.

Datasets, priors and other retrieval hyper parameters are set through the RetrievalConfig class, while the models module includes a range of complete atmospheric models that can be fit to the data. Users can also define their own model function, either by making use of temperature profiles from the physics module and chemistry parameterisations from the chemistry module or by implementing their own forward model. Once set up, the Retrieval class is used to run the retrieval using the chosen sampler and to produce publication ready figures.

<figure><img src="image_1.png" /><figcaption>Figure 1: Typical example of default pRT outputs. This highlights the fit of a transmission spectrum model to JWST/NIRISS/SOSS data of WASP 39 b as part of the Transiting Early Release Science program.</figcaption></figure>

Multiple datasets can be included into a single retrieval, with each dataset receiving its own Radtrans object used for the radiative transfer calculation where some or all forward model parameters may be shared between the different data sets. This allows for highly flexible retrievals where multiple spectral resolutions, wavelength ranges and even atmospheric models can be combined in a single retrieval. Each dataset can also receive scaling factors (for the flux, uncertainties or both), error inflation factors and offsets. The model functions are used to compute a spectrum $\vec{S}$, which is convolved to the instrumental resolution and binned to the wavelength bins of the data using a custom binning function to account for non-uniform bin sizes. The resulting spectrum compared to the data with flux $\vec{F}$ and covariance $C$ in the likelihood function:

$$ -2 \log \mathcal{L} = (\vec{S} - \vec{F})^T C^{-1} (\vec{S} - \vec{F}) + \log (2\pi \det(C)). \quad (1) $$

The second term is included in the likelihood to allow for uncertainties to vary as a free parameter during the retrieval, and penalises overly large uncertainties. A likelihood function for high resolution data based on that of (Gibson et al., 2020) is also available.

pRT can compute spectra either using line-by-line calculations, or using correlated-k (c-k) tables for defining the opacities of molecular species. We include up-to-date correlated-k line lists from Exomol (Chubb et al., 2021; McKemmish et al., 2016; Polyansky et al., 2018; Tennyson & Yurchenko, 2012) and HITEMP Hargreaves et al. (2020), with the full set of available opacities listed in the online documentation. The exo-k package is used to resample the correlated-k opacity tables to a lower spectral resolution in order to reduce the computation time (Leconte, 2021). Combining the c-k opacities of multiple species requires mixing the
distributions in *g* space. This operation is necessary when calculating emission spectra and accounting for multiple scattering in the clouds. Previously, this was accomplished by taking 1000 samples of each distribution. This sampling process resulted in non-deterministic spectral calculations with a small (up to 1%) scatter about the expected result, which could lead to unexpected behaviour from the nested sampler as the same set of parameters could result in different log-likelihood. pRT has been updated to fully mix the c-k distributions, iteratively mixing in any species with a significant opacity contribution: a species is only mixed in if the highest opacity value in a given spectral bin is larger than a threshold value. This threshold value is obtained by listing the smallest opacity value for every species in a given spectral bin, and then setting the threshold to 1% of the largest value from the list for each spectral bin. The resulting grid is linearly interpolated back to the 16 *g* points at each pressure and frequency bin as required by pRT. This fully deterministic process produces stable log-likelihood calculations, and resulted in a 5× improvement in the speed of the c-k mixing function.

Various thermal, chemical and cloud parameterisations are available in pRT. Built-in temperature profiles range from interpolated splines to physically motivated profiles as in Guillot (2010) and Mollière et al. (2020). Equilibrium and disequilibrium chemistry can be interpolated from a pre-computed grid on-the-fly. Chemical abundances can also be freely retrieved, with the additional possibility of using a combination of free and chemically consistent abundances. Cloud parameterisations range from a 'grey' continuum opacity applied at all wavelengths, to clouds parameterised as in Ackerman & Marley (2001), using log-normal or Hansen (1971) particle size distributions with real optical opacities for different compositions and particle shapes, and including self-scattering. Users can also pass functions to the Radtrans object that encode any absorption or scattering opacity as a function of wavelength and atmospheric position, allowing for a generic cloud implementation. Included in pRT is an option to use an adaptive pressure grid with a higher resolution around the location of the cloud base, allowing for more precise positioning of the cloud layers within the atmosphere.

Photometric data are fully incorporated into the retrieval process. The spectral model is multiplied by a filter transmission profile from the SVO database using the species package (Stolker et al., 2020). This results in accurate synthetic photometry, which can be compared to the values specified by the user with the add_photometry function.

Publication-ready summary plots of best fits, temperature and abundance profiles and corner plots can be automatically generated. Multiple retrieval results can be combined in the plots for model comparisons. Such results have been benchmarked against other widely used retrieval codes, such as PLATON (Zhang et al., 2019), POSEIDON (Grant et al., 2023) and ARCIS in (Dyrek et al., 2024). The forthcoming retrieval comparison of the JWST Early Release Science (ERS) program will comprehensively compare pRT and other retrieval codes in the analysis of WASP-39b (Welbanks et al., in prep). Figure 1 shows the fit of a transmission model to the JWST/NIRISS/SOSS observations of WASP 39 b (Feinstein et al., 2023) from the ERS program.

## Acknowledgements

We gratefully acknowledge contributions to petitRADTRANS from Eleonara Alei, Karan Molaverdikhani, Francois Rozet, Aaron David Schneider, Tomas Stolker, Nick Wogan and Mantas Zilinskas. Thanks as well to our reviewers, Quentin Changeat and Valentin Christiaens, as well as our editor Dan Foreman-Mackey.

## References

Ackerman, A. S., & Marley, M. S. (2001). Precipitating Condensation Clouds in Substellar Atmospheres. *Astrophysical Journal*, *556*(2), 872–884. https://doi.org/10.1086/321540
Buchner, J. (2019). Collaborative Nested Sampling: Big Data versus Complex Physical Models. *Publications of the ASP, 131*(1004), 108005. https://doi.org/10.1088/1538-3873/aae7fc

Buchner, J., Georgakakis, A., Nandra, K., Hsu, L., Rangel, C., Brightman, M., Merloni, A., Salvato, M., Donley, J., & Kocevski, D. (2014). X-ray spectral modelling of the AGN obscuring region in the CDFS: Bayesian model selection and catalogue. *Astronomy & Astrophysics*, 564, A125. https://doi.org/10.1051/0004-6361/201322971

Chubb, K. L., Rocchetto, M., Al-Refaie, A. F., Waldmann, I., Min, M., Barstow, J., Mollière, P., Phillips, M. W., Tennyson, J., & Yurchenko, S. N. (2021). The ExoMoLOP Database: Cross-sections and k-tables for Molecules of Interest in High-Temperature Exoplanet Atmospheres. *Astronomy & Astrophysics*, 646, A21. https://doi.org/10.1051/0004-6361/202038350

Dyrek, A., Min, M., Decin, L., Bouwman, J., Crouzet, N., Mollière, P., Lagage, P.-O., Konings, T., Tremblin, P., Güdel, M., Pye, J., Waters, R., Henning, T., Vandenbussche, B., Ardevol Martinez, F., Argyriou, I., Ducrot, E., Heinke, L., van Looveren, G., ... Wright, G. (2024). SO₂, silicate clouds, but no CH₄ detected in a warm Neptune. *Nature*, 625(7993), 51–54. https://doi.org/10.1038/s41586-023-06849-0

Feinstein, A. D., Radica, M., Welbanks, L., Murray, C. A., Ohno, K., Coulombe, L.-P., Espinoza, N., Bean, J. L., Teske, J. K., Benneke, B., Line, M. R., Rustamkulov, Z., Saba, A., Tsiaras, A., Barstow, J. K., Fortney, J. J., Gao, P., Knutson, H. A., MacDonald, R. J., ... Zhang, X. (2023). Early Release Science of the exoplanet WASP-39b with JWST NIRISS. *Nature*, 614(7949), 670–675. https://doi.org/10.1038/s41586-022-05674-1

Feroz, F., & Hobson, M. P. (2008). Multimodal nested sampling: An efficient and robust alternative to Markov Chain Monte Carlo methods for astronomical data analyses. *Monthly Notices of the RAS*, 384(2), 449–463. https://doi.org/10.1111/j.1365-2966.2007.12353.x

Feroz, F., Hobson, M. P., & Bridges, M. (2009). MULTINEST: An efficient and robust Bayesian inference tool for cosmology and particle physics. *Monthly Notices of the RAS*, 398(4), 1601–1614. https://doi.org/10.1111/j.1365-2966.2009.14548.x

Feroz, F., Hobson, M. P., Cameron, E., & Pettitt, A. N. (2019). Importance Nested Sampling and the MultiNest Algorithm. *The Open Journal of Astrophysics*, 2(1), 10. https://doi.org/10.21105/astro.1306.2144

Gibson, N. P., Merritt, S., Nugroho, S. K., Cubillos, P. E., de Mooij, E. J. W., Mikal-Evans, T., Fossati, L., Lothringer, J., Nikolov, N., Sing, D. K., Spake, J. J., Watson, C. A., & Wilson, J. (2020). Detection of Fe I in the atmosphere of the ultra-hot Jupiter WASP-121b, and a new likelihood-based approach for Doppler-resolved spectroscopy. *Monthly Notices of the RAS*, 493(2), 2215–2228. https://doi.org/10.1093/mnras/staa228

Grant, D., Lewis, N. K., Wakeford, H. R., Batalha, N. E., Glidden, A., Goyal, J., Mullens, E., MacDonald, R. J., May, E. M., Seager, S., Stevenson, K. B., Valenti, J. A., Visscher, C., Alderson, L., Allen, N. H., Cañas, C. I., Colón, K., Clampin, M., Espinoza, N., ... Watkins, L. L. (2023). JWST-TST DREAMS: Quartz Clouds in the Atmosphere of WASP-17b. *Astrophysical Journal Letters*, 956(2), L29. https://doi.org/10.3847/2041-8213/acfc3b

Guillot, T. (2010). On the radiative equilibrium of irradiated planetary atmospheres. *Astronomy & Astrophysics*, 520, A27. https://doi.org/10.1051/0004-6361/200913396

Hansen, J. E. (1971). Multiple Scattering of Polarized Light in Planetary Atmospheres Part II. Sunlight Reflected by Terrestrial Water Clouds. *Journal of Atmospheric Sciences*, 28(8), 1400–1426. https://doi.org/10.1175/1520-0469(1971)028%3C1400:MSOPLI%3E2.0.CO;2

Hargreaves, R. J., Gordon, I. E., Rey, M., Nikitin, A. V., Tyuterev, V. G., Kochanov, R. V., & Rothman, L. S. (2020). An Accurate, Extensive, and Practical Line List of Methane for the HITEMP Database. *Astrophysical Journal, Supplement*, 247(2), 55. https://doi.org/10.3847/1538-4365/ab7a1a
Leconte, J. (2021). Spectral binning of precomputed correlated-k coefficients. *Astronomy & Astrophysics*, 645, A20. https://doi.org/10.1051/0004-6361/202039040

MacDonald, R. J., & Batalha, N. E. (2023). A Catalog of Exoplanet Atmospheric Retrieval Codes. *Research Notes of the American Astronomical Society*, 7(3), 54. https://doi.org/10.3847/2515-5172/acc46a

Madhusudhan, N., & Seager, S. (2009). A Temperature and Abundance Retrieval Method for Exoplanet Atmospheres. *Astrophysical Journal*, 707(1), 24–39. https://doi.org/10.1088/0004-637X/707/1/24

McKemmish, L. K., Yurchenko, S. N., & Tennyson, J. (2016). ExoMol Molecular line lists – XVIII. The spectrum of Vanadium Oxide. *Monthly Notices of the RAS*, 643, 771–793. https://doi.org/10.1093/mnras/stw1969

Mollière, P., Stolker, T., Lacour, S., Otten, G. P. P. L., Shangguan, J., Charnay, B., Molyarova, T., Nowak, M., Henning, Th., Marleau, G.-D., Semenov, D. A., van Dishoeck, E., Eisenhauer, F., Garcia, P., Garcia Lopez, R., Girard, J. H., Greenbaum, A. Z., Hinkley, S., Kervella, P., ... Zurlo, A. (2020). Retrieving scattering clouds and disequilibrium chemistry in the atmosphere of HR 8799e. *Astronomy & Astrophysics*, 640, A131. https://doi.org/10.1051/0004-6361/202038325

Mollière, P., Wardenier, J. P., Boekel, R. van, Henning, Th., Molaverdikhani, K., & Snellen, I. A. G. (2019). petitRADTRANS: A Python radiative transfer package for exoplanet characterization and retrieval. *Astronomy & Astrophysics*, 627, A67. https://doi.org/10.1051/0004-6361/201935470

Polyansky, O. L., Kyuberis, A. A., Zobov, N. F., Tennyson, J., Yurchenko, S. N., & Lodi, L. (2018). ExoMol molecular line lists XXX: A complete high-accuracy line list for water. *Monthly Notices of the RAS*, 480, 2597–2608. https://doi.org/10.1093/mnras/sty1877

Rothman, L. S., Gordon, I. E., Barber, R. J., Dothe, H., Gamache, R. R., Goldman, A., Perevalov, V. I., Tashkun, S. A., & Tennyson, J. (2010). HITEMP, the high-temperature molecular spectroscopic database. *Journal of Quantitative Spectroscopy and Radiative Transfer*, 111, 2139–2150. https://doi.org/10.1016/j.jqsrt.2010.05.001

Stolker, T., Quanz, S. P., Todorov, K. O., Kühn, J., Mollière, P., Meyer, M. R., Currie, T., Daemgen, S., & Lavie, B. (2020). MIRACLES: atmospheric characterization of directly imaged planets and substellar companions at 4-5 µm. I. Photometric analysis of β Pic b, HIP 65426 b, PZ Tel B, and HD 206893 B. *Astronomy & Astrophysics*, 635, A182. https://doi.org/10.1051/0004-6361/201937159

Tennyson, J., & Yurchenko, S. N. (2012). ExoMol: Molecular line lists for exoplanet and other atmospheres. *Monthly Notices of the RAS*, 425(1), 21–33. https://doi.org/10.1111/j.1365-2966.2012.21440.x

Zhang, M., Chachan, Y., Kempton, E. M.-R., & Knutson, H. A. (2019). Forward Modeling and Retrievals with PLATON, a Fast Open-source Tool. *Publications of the Astronomical Society of the Pacific*, 131(997), 034501. https://doi.org/10.1088/1538-3873/aaf5ad