Chemical Equilibrium Retrievals

This tutorial covers how to run thermochemical equilibrium retrievals with POSEIDON. We recommend you first go through the “Chemical Equilibrium Transmission Spectra” tutorial (for background on the assumption of chemical equilibrium) and the “Atmospheric Retrievals with POSEIDON” tutorial (for an introduction to retrievals).

Warning:

Chemical equilibrium is a strong assumption. Before proceeding with real data, it is worth checking whether the planet you are modelling is theoretically expected the be in equilibrium over the pressure range probed by your observations. Even if the planet is probably in equilibrium (e.g. an ultra-hot Jupiter), we always recommend running a free retrieval for comparison.

With that caveat out of the way, let’s begin the thrilling saga of equilibrium retrievals.

Case Study: A JWST Hot Jupiter Transmission Spectrum

The day has finally arrived. You hold in your hands the first complete near-infrared transmission spectrum of the hot Jupiter WASP-62b.

You chose WASP-62b because there is evidence from the Hubble and Spitzer space telescopes that it has a clear atmosphere (Alam et al., 2021). And now the incredible observing capabilities of JWST will reveal WASP-62b’s atmosphere like never before.

First, you specify the system properties.

[1]:
from POSEIDON.core import create_star, create_planet
from POSEIDON.constants import R_Sun, R_J

#***** Define stellar properties *****#

R_s = 1.23*R_Sun     # Stellar radius (m)
T_s = 6230.0         # Stellar effective temperature (K)
Met_s = 0.04         # Stellar metallicity [log10(Fe/H_star / Fe/H_solar)]
log_g_s = 4.45       # Stellar log surface gravity (log10(cm/s^2) by convention)

# Create the stellar object
star = create_star(R_s, T_s, log_g_s, Met_s)

#***** Define planet properties *****#

planet_name = 'WASP-62b'  # Planet name used for plots, output files etc.

R_p = 1.32*R_J     # Planetary radius (m)
g_p = 7.3978       # Gravitational field of planet (m/s^2)
T_eq = 1394        # Equilibrium temperature (K)

# Create the planet object
planet = create_planet(planet_name, R_p, gravity = g_p, T_eq = T_eq)

Your JWST observations come from two different instrument modes: NIRISS SOSS (0.6-2.8 μm) and NIRSpec G395H (2.8-5.2 μm). You observed one transit with each mode to obtain a wide wavelength range that covers the absorption features of the major oxygen-bearing and carbon-bearing molecules expected in hot Jupiter atmospheres (\(\rm{H}_2 \rm{O}\), \(\rm{CO}\), \(\rm{CO}_2\), and \(\rm{CH}_4\)).

The data has been split into four files:

  • NIRISS SOSS Order 2.

  • NIRISS SOSS Order 1.

  • NIRSpec G395H Detector NRS1.

  • NIRSpec G395H Detector NRS2.

You load the data to finally gaze upon WASP-62b’s transmission spectrum.

[2]:
from POSEIDON.core import load_data, wl_grid_constant_R
from POSEIDON.visuals import plot_data

#***** Wavelength grid *****#

wl_min = 0.6     # Minimum wavelength (um)
wl_max = 5.3     # Maximum wavelength (um)
R = 10000        # Spectral resolution of grid

wl = wl_grid_constant_R(wl_min, wl_max, R)

#***** Specify data location and instruments  *****#

data_dir = '../../../POSEIDON/reference_data/observations/WASP-62b'

instruments = ['JWST_NIRISS_SOSS_Ord2', 'JWST_NIRISS_SOSS_Ord1',        # NIRISS SOSS Order 2 and Order 1
               'JWST_NIRSpec_G395H_NRS1', 'JWST_NIRSpec_G395H_NRS2']    # NIRSpec G395H detectors NRS1 and NRS2

datasets = [planet_name + '_Eq_Chem_NIRISS_SOSS_Ord2.dat',
            planet_name + '_Eq_Chem_NIRISS_SOSS_Ord1.dat',
            planet_name + '_Eq_Chem_NIRSpec_G395H_NRS1.dat',
            planet_name + '_Eq_Chem_NIRSpec_G395H_NRS2.dat']

# Load dataset, pre-load instrument PSF and transmission function
data = load_data(data_dir, datasets, instruments, wl)

# Plot our data
fig_data = plot_data(data, planet_name,
                     data_colour_list = ['deepskyblue', 'lime', 'orange', 'crimson'],
                     data_labels = ['NIRISS SOSS Ord2', 'NIRISS SOSS Ord1',
                                    'NIRSpec G395H NRS1', 'NIRSpec G395H NRS2'],
                     data_marker_list = ['o', 'o', 'o', 'o'],
                     legend_location = 'lower right')
../../_images/content_notebooks_retrieval_equilibrium_5_0.png

Wow, what an incredible spectrum! JWST is truly a wonder.

Note:

This dataset is simulated JWST data. Any similarity to real exoplanet spectra is entirely coincidental.

If anyone ever actually observes WASP-62b with JWST, this tutorial will be updated (and you’ll have my eternal gratitude, since WASP-62b is fantastic science target). You might want to examine the next retrieval tutorial (“Supporting a JWST Proposal with POSEIDON”) if you feel inspired to try observing this planet ;)

Create an Equilibrium Retrieval Model

For initial exploration, you decide to try an equilibrium chemistry retrieval. This should give you a first estimate of the metallicity and \(\rm{C/O}\) ratio of WASP-62b’s atmosphere, which can be useful quantities to understand the formation and migration history of the planet.

Tip:

The retrieval below is a subset equilibrium chemistry retrieval in which only \(\rm{H}_2 \rm{O}\), \(\rm{CO}\), \(\rm{CO}_2\), and \(\rm{CH}_4\) are included for demonstration purposes and computational speed. You can include all the chemical species in the equilibrium grid by setting param_species = ['all'].

See the “Chemical Equilibrium Transmission Spectra” tutorial for more details on the difference between subset and full equilibrium models.

[3]:
from POSEIDON.core import define_model
import numpy as np

#***** Define model *****#

model_name = 'eq_chemistry'

bulk_species = ['H2', 'He']                    # H2 + He comprises the bulk atmosphere
param_species = ['H2O', 'CH4', 'CO', 'CO2']    # Equilibrium model with *only* H2O, CH4, CO, and CO2

# Create the model object
model = define_model(model_name, bulk_species, param_species,
                     PT_profile = 'isotherm', X_profile = 'chem_eq',    # 'X_profile' is the key to create an equilibrium model
                     cloud_model = 'cloud-free')

One of the nice aspects of equilibrium retrievals is the atmospheric composition is only described by two free parameters: the metallicity and carbon-to-oxygen ratio. This low number of free parameters makes equilibrium retrievals relatively fast.

[4]:
print("Free parameters : " + str(model['param_names']))
Free parameters : ['R_p_ref' 'T' 'C_to_O' 'log_Met']

Setting Up Priors

[5]:
from POSEIDON.core import set_priors

#***** Set priors for retrieval *****#

# Initialise prior type dictionary
prior_types = {}

# Specify whether priors are linear, Gaussian, etc.
prior_types['T'] = 'uniform'
prior_types['R_p_ref'] = 'uniform'
prior_types['C_to_O'] = 'uniform'
prior_types['log_Met'] = 'uniform'

# Initialise prior range dictionary
prior_ranges = {}

# Specify prior ranges for each free parameter
prior_ranges['T'] = [400, 1600]
prior_ranges['R_p_ref'] = [0.85*R_p, 1.15*R_p]
prior_ranges['C_to_O'] = [0.2, 1.2]             # Full grid runs from 0.2 to 2
prior_ranges['log_Met'] = [-1,3]                # Full grid runs from -1 to 4

# Create prior object for retrieval
priors = set_priors(planet, star, model, data, prior_types, prior_ranges)

Pre-Load Opacities

[6]:
from POSEIDON.core import read_opacities

#***** Read opacity data *****#

opacity_treatment = 'opacity_sampling'

# First, specify limits of the fine temperature and pressure grids for the
# pre-interpolation of cross sections. These fine grids should cover a
# wide range of possible temperatures and pressures for the model atmosphere.

# Define fine temperature grid (K)
T_fine_min = 400     # 400 K lower limit suffices for a typical hot Jupiter
T_fine_max = 1600    # 2000 K upper limit suffices for a typical hot Jupiter
T_fine_step = 10     # 10 K steps are a good tradeoff between accuracy and RAM

T_fine = np.arange(T_fine_min, (T_fine_max + T_fine_step), T_fine_step)

# Define fine pressure grid (log10(P/bar))
log_P_fine_min = -6.0   # 1 ubar is the lowest pressure in the opacity database
log_P_fine_max = 2.0    # 100 bar is the highest pressure in the opacity database
log_P_fine_step = 0.2   # 0.2 dex steps are a good tradeoff between accuracy and RAM

log_P_fine = np.arange(log_P_fine_min, (log_P_fine_max + log_P_fine_step),
                       log_P_fine_step)

# Now we can pre-interpolate the sampled opacities (may take up to a minute)
opac = read_opacities(model, wl, opacity_treatment, T_fine, log_P_fine)
Reading in cross sections in opacity sampling mode...
H2-H2 done
H2-He done
H2-CH4 done
CO2-H2 done
CO2-CO2 done
CO2-CH4 done
H2O done
CH4 done
CO done
CO2 done
Opacity pre-interpolation complete.

Run Retrieval

Finally, you are ready to retrieve WASP-62b’s JWST transmission spectrum.

This POSEIDON retrieval should take about an hour on 1 core for a typical laptop.

Tip:

Retrievals run faster on multiple cores. When running the cells in this Jupyter notebook, only a single core will be used. You can run a multi-core retrieval on 4 cores by converting this Jupyter notebook into a python script, then calling mpirun on the .py file:

mpirun -n 4 python -u YOUR_RETRIEVAL_SCRIPT.py
[7]:
from POSEIDON.retrieval import run_retrieval

#***** Specify fixed atmospheric settings for retrieval *****#

# Atmospheric pressure grid
P_min = 1.0e-7    # 0.1 ubar
P_max = 100       # 100 bar
N_layers = 100    # 100 layers

# Let's space the layers uniformly in log-pressure
P = np.logspace(np.log10(P_max), np.log10(P_min), N_layers)

# Specify the reference pressure
P_ref = 10.0   # Retrieved R_p_ref parameter will be the radius at 10 bar

#***** Run atmospheric retrieval *****#

run_retrieval(planet, star, model, opac, data, priors, wl, P, P_ref, R = R,
              spectrum_type = 'transmission', chem_grid = 'fastchem',       # Important! This specifies the equilibrium chemistry grid to load
              sampling_algorithm = 'MultiNest',
              N_live = 400, verbose = True)
Reading in database for equilibrium chemistry model...
POSEIDON now running 'eq_chemistry'
 *****************************************************
 MultiNest v3.10
 Copyright Farhan Feroz & Mike Hobson
 Release Jul 2015

 no. of live points =  400
 dimensionality =    4
 *****************************************************
 Starting MultiNest
 generating live points
 live points generated, starting sampling
Acceptance Rate:                        0.991189
Replacements:                                450
Total Samples:                               454
Nested Sampling ln(Z):            **************
Acceptance Rate:                        0.967118
Replacements:                                500
Total Samples:                               517
Nested Sampling ln(Z):            **************
Acceptance Rate:                        0.945017
Replacements:                                550
Total Samples:                               582
Nested Sampling ln(Z):            -947032.054286
Acceptance Rate:                        0.921659
Replacements:                                600
Total Samples:                               651
Nested Sampling ln(Z):            -737860.351608
Acceptance Rate:                        0.880759
Replacements:                                650
Total Samples:                               738
Nested Sampling ln(Z):            -551744.905547
Acceptance Rate:                        0.848485
Replacements:                                700
Total Samples:                               825
Nested Sampling ln(Z):            -432313.799481
Acceptance Rate:                        0.789474
Replacements:                                750
Total Samples:                               950
Nested Sampling ln(Z):            -335683.009388
Acceptance Rate:                        0.769231
Replacements:                                800
Total Samples:                              1040
Nested Sampling ln(Z):            -259455.323217
Acceptance Rate:                        0.758929
Replacements:                                850
Total Samples:                              1120
Nested Sampling ln(Z):            -207526.286147
Acceptance Rate:                        0.751880
Replacements:                                900
Total Samples:                              1197
Nested Sampling ln(Z):            -164457.498513
Acceptance Rate:                        0.746269
Replacements:                                950
Total Samples:                              1273
Nested Sampling ln(Z):            -122138.811719
Acceptance Rate:                        0.739645
Replacements:                               1000
Total Samples:                              1352
Nested Sampling ln(Z):             -95561.176052
Acceptance Rate:                        0.734780
Replacements:                               1050
Total Samples:                              1429
Nested Sampling ln(Z):             -73311.627407
Acceptance Rate:                        0.719424
Replacements:                               1100
Total Samples:                              1529
Nested Sampling ln(Z):             -57394.779095
Acceptance Rate:                        0.715174
Replacements:                               1150
Total Samples:                              1608
Nested Sampling ln(Z):             -44044.081809
Acceptance Rate:                        0.711744
Replacements:                               1200
Total Samples:                              1686
Nested Sampling ln(Z):             -36882.108223
Acceptance Rate:                        0.710227
Replacements:                               1250
Total Samples:                              1760
Nested Sampling ln(Z):             -30607.932887
Acceptance Rate:                        0.708447
Replacements:                               1300
Total Samples:                              1835
Nested Sampling ln(Z):             -24448.298723
Acceptance Rate:                        0.700571
Replacements:                               1350
Total Samples:                              1927
Nested Sampling ln(Z):             -20132.801991
Acceptance Rate:                        0.697211
Replacements:                               1400
Total Samples:                              2008
Nested Sampling ln(Z):             -16594.442303
Acceptance Rate:                        0.694112
Replacements:                               1450
Total Samples:                              2089
Nested Sampling ln(Z):             -14431.750321
Acceptance Rate:                        0.686499
Replacements:                               1500
Total Samples:                              2185
Nested Sampling ln(Z):             -12828.869299
Acceptance Rate:                        0.681618
Replacements:                               1550
Total Samples:                              2274
Nested Sampling ln(Z):             -11673.424878
Acceptance Rate:                        0.679983
Replacements:                               1600
Total Samples:                              2353
Nested Sampling ln(Z):             -10696.112972
Acceptance Rate:                        0.676230
Replacements:                               1650
Total Samples:                              2440
Nested Sampling ln(Z):              -9824.142591
Acceptance Rate:                        0.674068
Replacements:                               1700
Total Samples:                              2522
Nested Sampling ln(Z):              -8899.099826
Acceptance Rate:                        0.669216
Replacements:                               1750
Total Samples:                              2615
Nested Sampling ln(Z):              -8171.400624
Acceptance Rate:                        0.666173
Replacements:                               1800
Total Samples:                              2702
Nested Sampling ln(Z):              -7433.909369
Acceptance Rate:                        0.662845
Replacements:                               1850
Total Samples:                              2791
Nested Sampling ln(Z):              -6831.607699
Acceptance Rate:                        0.656985
Replacements:                               1900
Total Samples:                              2892
Nested Sampling ln(Z):              -6160.540113
Acceptance Rate:                        0.653924
Replacements:                               1950
Total Samples:                              2982
Nested Sampling ln(Z):              -5390.835041
Acceptance Rate:                        0.650407
Replacements:                               2000
Total Samples:                              3075
Nested Sampling ln(Z):              -4501.167042
Acceptance Rate:                        0.645669
Replacements:                               2050
Total Samples:                              3175
Nested Sampling ln(Z):              -3796.019625
Acceptance Rate:                        0.645161
Replacements:                               2100
Total Samples:                              3255
Nested Sampling ln(Z):              -3193.442209
Acceptance Rate:                        0.644678
Replacements:                               2150
Total Samples:                              3335
Nested Sampling ln(Z):              -2495.266621
Acceptance Rate:                        0.641774
Replacements:                               2200
Total Samples:                              3428
Nested Sampling ln(Z):              -1974.456556
Acceptance Rate:                        0.642857
Replacements:                               2250
Total Samples:                              3500
Nested Sampling ln(Z):              -1546.848277
Acceptance Rate:                        0.641204
Replacements:                               2300
Total Samples:                              3587
Nested Sampling ln(Z):              -1152.264258
Acceptance Rate:                        0.638240
Replacements:                               2350
Total Samples:                              3682
Nested Sampling ln(Z):               -773.972978
Acceptance Rate:                        0.634585
Replacements:                               2400
Total Samples:                              3782
Nested Sampling ln(Z):               -521.309050
Acceptance Rate:                        0.633075
Replacements:                               2450
Total Samples:                              3870
Nested Sampling ln(Z):               -235.115874
Acceptance Rate:                        0.630199
Replacements:                               2500
Total Samples:                              3967
Nested Sampling ln(Z):                -13.942566
Acceptance Rate:                        0.629941
Replacements:                               2550
Total Samples:                              4048
Nested Sampling ln(Z):                154.327750
Acceptance Rate:                        0.628171
Replacements:                               2600
Total Samples:                              4139
Nested Sampling ln(Z):                335.156230
Acceptance Rate:                        0.626626
Replacements:                               2650
Total Samples:                              4229
Nested Sampling ln(Z):                476.117535
Acceptance Rate:                        0.622407
Replacements:                               2700
Total Samples:                              4338
Nested Sampling ln(Z):                624.680746
Acceptance Rate:                        0.620207
Replacements:                               2750
Total Samples:                              4434
Nested Sampling ln(Z):                739.831574
Acceptance Rate:                        0.617284
Replacements:                               2800
Total Samples:                              4536
Nested Sampling ln(Z):                813.269600
Acceptance Rate:                        0.614622
Replacements:                               2850
Total Samples:                              4637
Nested Sampling ln(Z):                880.000405
Acceptance Rate:                        0.612460
Replacements:                               2900
Total Samples:                              4735
Nested Sampling ln(Z):                952.095680
Acceptance Rate:                        0.611399
Replacements:                               2950
Total Samples:                              4825
Nested Sampling ln(Z):               1027.888540
Acceptance Rate:                        0.607287
Replacements:                               3000
Total Samples:                              4940
Nested Sampling ln(Z):               1115.589101
Acceptance Rate:                        0.604919
Replacements:                               3050
Total Samples:                              5042
Nested Sampling ln(Z):               1186.161714
Acceptance Rate:                        0.601475
Replacements:                               3100
Total Samples:                              5154
Nested Sampling ln(Z):               1236.622530
Acceptance Rate:                        0.597836
Replacements:                               3150
Total Samples:                              5269
Nested Sampling ln(Z):               1295.202724
Acceptance Rate:                        0.596792
Replacements:                               3200
Total Samples:                              5362
Nested Sampling ln(Z):               1332.152305
Acceptance Rate:                        0.595456
Replacements:                               3250
Total Samples:                              5458
Nested Sampling ln(Z):               1383.551314
Acceptance Rate:                        0.592885
Replacements:                               3300
Total Samples:                              5566
Nested Sampling ln(Z):               1429.605473
Acceptance Rate:                        0.590933
Replacements:                               3350
Total Samples:                              5669
Nested Sampling ln(Z):               1466.093662
Acceptance Rate:                        0.589153
Replacements:                               3400
Total Samples:                              5771
Nested Sampling ln(Z):               1493.599799
Acceptance Rate:                        0.588536
Replacements:                               3450
Total Samples:                              5862
Nested Sampling ln(Z):               1534.247392
Acceptance Rate:                        0.587741
Replacements:                               3500
Total Samples:                              5955
Nested Sampling ln(Z):               1558.195438
Acceptance Rate:                        0.586292
Replacements:                               3550
Total Samples:                              6055
Nested Sampling ln(Z):               1586.120727
Acceptance Rate:                        0.586033
Replacements:                               3600
Total Samples:                              6143
Nested Sampling ln(Z):               1608.362513
Acceptance Rate:                        0.584000
Replacements:                               3650
Total Samples:                              6250
Nested Sampling ln(Z):               1628.266349
Acceptance Rate:                        0.582310
Replacements:                               3700
Total Samples:                              6354
Nested Sampling ln(Z):               1649.362967
Acceptance Rate:                        0.579867
Replacements:                               3750
Total Samples:                              6467
Nested Sampling ln(Z):               1667.162716
Acceptance Rate:                        0.576631
Replacements:                               3800
Total Samples:                              6590
Nested Sampling ln(Z):               1685.472442
Acceptance Rate:                        0.574541
Replacements:                               3850
Total Samples:                              6701
Nested Sampling ln(Z):               1701.444299
Acceptance Rate:                        0.572603
Replacements:                               3900
Total Samples:                              6811
Nested Sampling ln(Z):               1716.179561
Acceptance Rate:                        0.570974
Replacements:                               3950
Total Samples:                              6918
Nested Sampling ln(Z):               1726.141443
Acceptance Rate:                        0.568666
Replacements:                               4000
Total Samples:                              7034
Nested Sampling ln(Z):               1735.989871
Acceptance Rate:                        0.566989
Replacements:                               4050
Total Samples:                              7143
Nested Sampling ln(Z):               1747.246396
Acceptance Rate:                        0.566533
Replacements:                               4100
Total Samples:                              7237
Nested Sampling ln(Z):               1754.853656
Acceptance Rate:                        0.566244
Replacements:                               4150
Total Samples:                              7329
Nested Sampling ln(Z):               1762.371927
Acceptance Rate:                        0.563758
Replacements:                               4200
Total Samples:                              7450
Nested Sampling ln(Z):               1771.148643
Acceptance Rate:                        0.562988
Replacements:                               4250
Total Samples:                              7549
Nested Sampling ln(Z):               1779.657820
Acceptance Rate:                        0.560845
Replacements:                               4300
Total Samples:                              7667
Nested Sampling ln(Z):               1786.380907
Acceptance Rate:                        0.558982
Replacements:                               4350
Total Samples:                              7782
Nested Sampling ln(Z):               1792.536747
Acceptance Rate:                        0.554995
Replacements:                               4400
Total Samples:                              7928
Nested Sampling ln(Z):               1799.352599
Acceptance Rate:                        0.554517
Replacements:                               4450
Total Samples:                              8025
Nested Sampling ln(Z):               1806.176911
Acceptance Rate:                        0.552690
Replacements:                               4500
Total Samples:                              8142
Nested Sampling ln(Z):               1811.207976
Acceptance Rate:                        0.552319
Replacements:                               4550
Total Samples:                              8238
Nested Sampling ln(Z):               1817.012074
Acceptance Rate:                        0.549451
Replacements:                               4600
Total Samples:                              8372
Nested Sampling ln(Z):               1822.341511
Acceptance Rate:                        0.546994
Replacements:                               4650
Total Samples:                              8501
Nested Sampling ln(Z):               1825.853451
Acceptance Rate:                        0.544928
Replacements:                               4700
Total Samples:                              8625
Nested Sampling ln(Z):               1829.359390
Acceptance Rate:                        0.542609
Replacements:                               4750
Total Samples:                              8754
Nested Sampling ln(Z):               1833.037149
Acceptance Rate:                        0.541333
Replacements:                               4800
Total Samples:                              8867
Nested Sampling ln(Z):               1836.326995
Acceptance Rate:                        0.540089
Replacements:                               4850
Total Samples:                              8980
Nested Sampling ln(Z):               1839.315611
Acceptance Rate:                        0.538817
Replacements:                               4900
Total Samples:                              9094
Nested Sampling ln(Z):               1842.472093
Acceptance Rate:                        0.537751
Replacements:                               4950
Total Samples:                              9205
Nested Sampling ln(Z):               1845.226204
Acceptance Rate:                        0.536999
Replacements:                               5000
Total Samples:                              9311
Nested Sampling ln(Z):               1847.511920
Acceptance Rate:                        0.534844
Replacements:                               5050
Total Samples:                              9442
Nested Sampling ln(Z):               1850.013218
Acceptance Rate:                        0.534031
Replacements:                               5100
Total Samples:                              9550
Nested Sampling ln(Z):               1852.496920
Acceptance Rate:                        0.531585
Replacements:                               5150
Total Samples:                              9688
Nested Sampling ln(Z):               1855.228760
Acceptance Rate:                        0.530558
Replacements:                               5200
Total Samples:                              9801
Nested Sampling ln(Z):               1857.563635
Acceptance Rate:                        0.529021
Replacements:                               5250
Total Samples:                              9924
Nested Sampling ln(Z):               1859.583692
Acceptance Rate:                        0.528046
Replacements:                               5300
Total Samples:                             10037
Nested Sampling ln(Z):               1861.279293
Acceptance Rate:                        0.526419
Replacements:                               5350
Total Samples:                             10163
Nested Sampling ln(Z):               1862.712430
Acceptance Rate:                        0.525855
Replacements:                               5400
Total Samples:                             10269
Nested Sampling ln(Z):               1864.073176
Acceptance Rate:                        0.526163
Replacements:                               5450
Total Samples:                             10358
Nested Sampling ln(Z):               1865.267345
Acceptance Rate:                        0.524509
Replacements:                               5500
Total Samples:                             10486
Nested Sampling ln(Z):               1866.454242
Acceptance Rate:                        0.522353
Replacements:                               5550
Total Samples:                             10625
Nested Sampling ln(Z):               1867.570208
Acceptance Rate:                        0.520736
Replacements:                               5600
Total Samples:                             10754
Nested Sampling ln(Z):               1868.599050
Acceptance Rate:                        0.520114
Replacements:                               5650
Total Samples:                             10863
Nested Sampling ln(Z):               1869.540064
Acceptance Rate:                        0.518842
Replacements:                               5700
Total Samples:                             10986
Nested Sampling ln(Z):               1870.613505
Acceptance Rate:                        0.516947
Replacements:                               5750
Total Samples:                             11123
Nested Sampling ln(Z):               1871.729104
Acceptance Rate:                        0.514778
Replacements:                               5800
Total Samples:                             11267
Nested Sampling ln(Z):               1872.630160
Acceptance Rate:                        0.512439
Replacements:                               5850
Total Samples:                             11416
Nested Sampling ln(Z):               1873.351910
Acceptance Rate:                        0.511177
Replacements:                               5900
Total Samples:                             11542
Nested Sampling ln(Z):               1874.042900
Acceptance Rate:                        0.507939
Replacements:                               5950
Total Samples:                             11714
Nested Sampling ln(Z):               1874.699299
Acceptance Rate:                        0.506928
Replacements:                               6000
Total Samples:                             11836
Nested Sampling ln(Z):               1875.339041
Acceptance Rate:                        0.504713
Replacements:                               6050
Total Samples:                             11987
Nested Sampling ln(Z):               1875.978949
Acceptance Rate:                        0.503134
Replacements:                               6100
Total Samples:                             12124
Nested Sampling ln(Z):               1876.626059
Acceptance Rate:                        0.501018
Replacements:                               6150
Total Samples:                             12275
Nested Sampling ln(Z):               1877.169505
Acceptance Rate:                        0.499356
Replacements:                               6200
Total Samples:                             12416
Nested Sampling ln(Z):               1877.649846
Acceptance Rate:                        0.497691
Replacements:                               6250
Total Samples:                             12558
Nested Sampling ln(Z):               1878.120684
Acceptance Rate:                        0.496024
Replacements:                               6300
Total Samples:                             12701
Nested Sampling ln(Z):               1878.558885
Acceptance Rate:                        0.493281
Replacements:                               6350
Total Samples:                             12873
Nested Sampling ln(Z):               1878.969635
Acceptance Rate:                        0.492611
Replacements:                               6400
Total Samples:                             12992
Nested Sampling ln(Z):               1879.344056
Acceptance Rate:                        0.489861
Replacements:                               6450
Total Samples:                             13167
Nested Sampling ln(Z):               1879.693396
Acceptance Rate:                        0.486746
Replacements:                               6500
Total Samples:                             13354
Nested Sampling ln(Z):               1880.022330
Acceptance Rate:                        0.486808
Replacements:                               6550
Total Samples:                             13455
Nested Sampling ln(Z):               1880.318949
Acceptance Rate:                        0.485473
Replacements:                               6600
Total Samples:                             13595
Nested Sampling ln(Z):               1880.589178
Acceptance Rate:                        0.483742
Replacements:                               6650
Total Samples:                             13747
Nested Sampling ln(Z):               1880.828083
Acceptance Rate:                        0.482570
Replacements:                               6700
Total Samples:                             13884
Nested Sampling ln(Z):               1881.057763
Acceptance Rate:                        0.481764
Replacements:                               6750
Total Samples:                             14011
Nested Sampling ln(Z):               1881.275465
Acceptance Rate:                        0.480769
Replacements:                               6800
Total Samples:                             14144
Nested Sampling ln(Z):               1881.490492
Acceptance Rate:                        0.479826
Replacements:                               6850
Total Samples:                             14276
Nested Sampling ln(Z):               1881.688572
Acceptance Rate:                        0.478934
Replacements:                               6900
Total Samples:                             14407
Nested Sampling ln(Z):               1881.873011
Acceptance Rate:                        0.478156
Replacements:                               6950
Total Samples:                             14535
Nested Sampling ln(Z):               1882.043696
Acceptance Rate:                        0.477522
Replacements:                               7000
Total Samples:                             14659
Nested Sampling ln(Z):               1882.201248
Acceptance Rate:                        0.476448
Replacements:                               7050
Total Samples:                             14797
Nested Sampling ln(Z):               1882.348703
Acceptance Rate:                        0.475616
Replacements:                               7100
Total Samples:                             14928
Nested Sampling ln(Z):               1882.484072
Acceptance Rate:                        0.474673
Replacements:                               7150
Total Samples:                             15063
Nested Sampling ln(Z):               1882.608546
Acceptance Rate:                        0.473155
Replacements:                               7200
Total Samples:                             15217
Nested Sampling ln(Z):               1882.725214
Acceptance Rate:                        0.472436
Replacements:                               7250
Total Samples:                             15346
Nested Sampling ln(Z):               1882.835392
Acceptance Rate:                        0.470725
Replacements:                               7300
Total Samples:                             15508
Nested Sampling ln(Z):               1882.937880
Acceptance Rate:                        0.467914
Replacements:                               7350
Total Samples:                             15708
Nested Sampling ln(Z):               1883.032645
Acceptance Rate:                        0.465672
Replacements:                               7400
Total Samples:                             15891
Nested Sampling ln(Z):               1883.118208
Acceptance Rate:                        0.464261
Replacements:                               7450
Total Samples:                             16047
Nested Sampling ln(Z):               1883.196853
Acceptance Rate:                        0.462136
Replacements:                               7500
Total Samples:                             16229
Nested Sampling ln(Z):               1883.268809
Acceptance Rate:                        0.461266
Replacements:                               7550
Total Samples:                             16368
Nested Sampling ln(Z):               1883.335554
Acceptance Rate:                        0.460494
Replacements:                               7600
Total Samples:                             16504
Nested Sampling ln(Z):               1883.396604
Acceptance Rate:                        0.457864
Replacements:                               7650
Total Samples:                             16708
Nested Sampling ln(Z):               1883.452903
Acceptance Rate:                        0.456811
Replacements:                               7700
Total Samples:                             16856
Nested Sampling ln(Z):               1883.504068
Acceptance Rate:                        0.455748
Replacements:                               7750
Total Samples:                             17005
Nested Sampling ln(Z):               1883.551079
Acceptance Rate:                        0.453858
Replacements:                               7800
Total Samples:                             17186
Nested Sampling ln(Z):               1883.594066
Acceptance Rate:                        0.451020
Replacements:                               7850
Total Samples:                             17405
Nested Sampling ln(Z):               1883.633920
Acceptance Rate:                        0.450040
Replacements:                               7900
Total Samples:                             17554
Nested Sampling ln(Z):               1883.669980
Acceptance Rate:                        0.448317
Replacements:                               7950
Total Samples:                             17733
Nested Sampling ln(Z):               1883.702448
Acceptance Rate:                        0.445931
Replacements:                               8000
Total Samples:                             17940
Nested Sampling ln(Z):               1883.731730
Acceptance Rate:                        0.444629
Replacements:                               8050
Total Samples:                             18105
Nested Sampling ln(Z):               1883.758273
Acceptance Rate:                        0.442861
Replacements:                               8080
Total Samples:                             18245
Nested Sampling ln(Z):               1883.772882
POSEIDON retrieval finished in 0.61 hours
 ln(ev)=   1884.0046619665761      +/-  0.20099542855702071
 Total Likelihood Evaluations:        18245
 Sampling finished. Exiting MultiNest
Now generating 1000 sampled spectra and P-T profiles from the posterior distribution...
This process will take approximately 2.0 minutes
All done! Output files can be found in ./POSEIDON_output/WASP-62b/retrievals/results/

Plot Retrieval Results

[13]:
from POSEIDON.utility import read_retrieved_spectrum, plot_collection
from POSEIDON.visuals import plot_spectra_retrieved
from POSEIDON.corner import generate_cornerplot

#***** Plot retrieved transmission spectrum *****#

# Read retrieved spectrum confidence regions
wl, spec_low2, spec_low1, spec_median, \
spec_high1, spec_high2 = read_retrieved_spectrum(planet_name, model_name)

# Create composite spectra objects for plotting
spectra_median = plot_collection(spec_median, wl, collection = [])
spectra_low1 = plot_collection(spec_low1, wl, collection = [])
spectra_low2 = plot_collection(spec_low2, wl, collection = [])
spectra_high1 = plot_collection(spec_high1, wl, collection = [])
spectra_high2 = plot_collection(spec_high2, wl, collection = [])

# Produce figure
fig_spec = plot_spectra_retrieved(spectra_median, spectra_low2, spectra_low1,
                                  spectra_high1, spectra_high2, planet_name,
                                  data, R_to_bin = 200,
                                  data_colour_list = ['deepskyblue', 'lime', 'orange', 'crimson'],
                                  data_labels = ['NIRISS SOSS Ord2', 'NIRISS SOSS Ord1',
                                                 'NIRSpec G395H NRS1', 'NIRSpec G395H NRS2'],
                                  data_marker_list = ['o', 'o', 'o', 'o'],
                                  legend_location = 'upper right',
                                  legend_box = False,
                                  y_min = 1.26e-2, y_max = 1.54e-2,
                                  plt_label = 'Equilibrium Retrieval')

#***** Make corner plot *****

fig_corner = generate_cornerplot(planet, model,
                                 true_vals = [R_p/R_J, T_eq, 0.55, 0.0])   # Overplot the true values used to make the synthetic data
Generating corner plot ...
../../_images/content_notebooks_retrieval_equilibrium_20_1.png
../../_images/content_notebooks_retrieval_equilibrium_20_2.png

And there you have it, precise constraints on the \(\rm{C/O}\) ratio and metallicity of WASP-62b’s atmosphere.