Skip to content

Examples

Carlos E. Romero-Mirza edited this page Dec 10, 2024 · 16 revisions

iris Examples


Table of Contents

Introductory

  1. 1 Component H2O
  2. 2 Components H2O
  3. 3 Components H2O and CO2 with Thermal Broadening

Advanced

  1. 2 Components H2O with Keplerian Broadening
  2. H2O with Power-law Temperature Gradient
  3. H2O with Varying Resolving Power
  4. Bayesian Retrieval of H2O

1 Component H2O

Here we model a simple 1-component H2O slab, with excitation temperature of 800 K, 0.5 au $^2$ emitting area, and column density of $10^{18}$ cm $^{-2}$.

path_to_moldata = './'  # path where we want to save the HITRAN data

# Let's get the data for H2O 
setup.setup_linelists('H2O', 'H2O', 1, path_to_moldata)

# Define a fine wavelength grid (in micron) to evaluate opacities
fine_wgrid = np.arange(11.5,18.5,1e-5)
# Define a wavelength grid (in micron) to downsample the model
obs_wgrid = np.arange(12.0,18.0,0.002)
# The instrument resolving power
R = 3200

# Initialize slab
slab = iris.slab(molecules=['H2O'], wlow=11.0, whigh=19.0, path_to_moldata=path_to_moldata)

# Distance to source
distance = 120 # pc

# NOTE that we define an ARRAY for the temperature, column density, and area FOR EACH SPECIES.
# So if we wanted to add multiple components for a species just add more points to each array.

# Excitation temperatures for each molecule in K
T_ex =  np.array([np.array([800.0])])
# column densities in cm^-2
N_mol = np.array([np.array([1e18])])
# emitting areas in au^2
A_au =  np.array([np.array([0.5])])

# intrinsic line widths in km/s (line FWHM)
dV =  np.array([np.array([2.0])])

def compiled_slab(distance, T_ex, N_mol, A_au, dV, fine_wgrid, wavelength, R):

    slab.setup_disk(distance, T_ex, N_mol, A_au, dV) # initialize object
    slab.setup_grid(fine_wgrid, wavelength, R) # set up wavelength and model parameters
    slab.simulate() # make model

    return slab.downsampled_flux, slab.flux_model

'''Just-in-time compilation'''
compiled_slab_jit = jax.jit(compiled_slab)
downsampled_model, full_model = compiled_slab_jit(distance, T_ex, N_mol, A_au, dV, fine_wgrid, obs_wgrid, R)

2 Components H2O

For this we can re-use most of the code from Example 1, we just need to change the parameter matrices to model 2 components. In fact, we do not need to re-initialize the slab object or re-compile the code at all, since we are still using the same slab object.

We will model 2 components with temperatures 1000 and 500 K, $N_{mol}$ of $10^{18}$ and $10^{17}$ cm $^{-2}$, and emitting areas of 0.5 and 5.0 au $^{2}$

Note that in principle we could define different line widths for each component.

# Excitation temperatures for each molecule in K
T_ex =  np.array([np.array([1000.0, 500.0])])
# column densities in cm^-2
N_mol = np.array([np.array([1e18, 1e17])])
# emitting areas in au^2
A_au =  np.array([np.array([0.5, 5.0])])

# intrinsic line widths in km/s (line FWHM)
dV =  np.array([np.array([2.0, 2.0])])

downsampled_model, full_model = compiled_slab_jit(distance, T_ex, N_mol, A_au, dV, fine_wgrid, obs_wgrid, R)

3 Components H2O and CO2 with Thermal Broadening

2 Components H2O with Keplerian Broadening

H2O with Power-law Temperature Gradient

H2O with Varying Resolving Power

Bayesian Retrieval of H2O

Clone this wiki locally