-
Notifications
You must be signed in to change notification settings - Fork 3
Examples
Carlos E. Romero-Mirza edited this page Dec 10, 2024
·
16 revisions
- 2 Components H2O with Keplerian Broadening
- H2O with Power-law Temperature Gradient
- H2O with Varying Resolving Power
- Bayesian Retrieval of H2O
Here we model a simple 1-component H2O slab, with excitation temperature of 800 K, 0.5 au
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)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!