Routines for running slab models

This module provides several routines to run 0D and 1D (radial) ProDiMo slab model. More robust and efficient implementation can be found in ProDiMo Fortran package, which also includes multiple species. The QTpy directory provided in the python zip (available here: https://hitran.org/files/TIPS/TIPS2021/) should be separately downloaded and the path should be provided for running the slab routines. The HITRAN line data files (the .par files) should also be downloaded (https://hitran.org/lbl/). If you have ProDiMo FORTRAN package installed, these files are also available in the ‘data/HITRAN2020/’ directory.

Also check the example notebook.

The following example runs 0D and 1D slab model. The run_0D_slab() function runs 0D ProDiMo slab. The run_1D_radial_slab() function runs 1D radial ProDiMo slab.

# the prodimopy modules for running
import prodimopy.run_slab as runs

runs.run_0D_slab(1e17,250,2.0,'CO2',44,'/path/to/prodimo/data/HITRAN2020/CO2.par',1e5,'/path/to/directory/containing/QTpy','CO2_0D.fits.gz',isotopolog=[1],wave_mol=[4,30],wave_spec=[4.9,28])
runs.run_1D_radial_slab([1e17,1e16,1e15],[250,200,150],[0.1,0.2,1.0],190,2.0,'CO2',44,'/path/to/prodimo/data/HITRAN2020/CO2.par',1e5,'/path/to/directory/containing/QTpy','CO2_0D.fits.gz',width='infer',Rin_limit=0.07,Rout_limit=600,isotopolog=[1],wave_mol=[4,30],wave_spec=[4.9,28]):
prodimopy.run_slab.read_partition_sums(custom_partition_sum_file)[source]
prodimopy.run_slab.parse_paired_rules(selection, Nspecies, arg_name='selection', expected_types=(<class 'int'>, <class 'float'>))[source]

Normalizes flexible paired inputs (ranges or string pairs) into a strict format: [ [ [val1, val2], … ], [ [val1, val2], … ], … ] of length Nspecies.

prodimopy.run_slab.run_0D_slab(Ng, Tg, vturb, line_selection_file='', molecule='', cdn_scale_fac=[1], mol_mass=None, HITRANfile='', ESelection=None, bandSelection=None, hitran_min_strength=1e-99, custom_partition_sum_file='', isotopolog=[1], waveSelection=[4, 30], wave_spec=[4.9, 28], R_grid=100000.0, output='both', output_filename='default.out', mode='both', convolve_R=None, verbose=True)[source]

Simulates 0D slab models for molecular emission/absorption spectra.

This is a Python implementation of 0D slab models based on the FORTRAN version in ProDiMo (https://prodimo.iwf.oeaw.ac.at/). It runs models with or without line overlap. For running large grids of models, run_0D_slab_grid() or the Fortran version is recommended as they support OpenMP for better performance.

Parameters:
  • Ng (float) – Gas column density in cm^{-2}.

  • Tg (float) – Gas temperature in Kelvin (K).

  • vturb (float) – Turbulent velocity of the gas in km/s.

  • line_selection_file (str, optional) – Path to a pre-defined line selection rules file. If provided, overrides arguments: molecule, mass, HITRANfile, ESelection, bandSelection, hitran_min_strength, custom_partition_sum_file, isotopolog, and waveSelection. Default is ‘’.

  • molecule (str or list of str, optional) – Molecule name(s) (e.g., ‘CO2’ or [‘CO2’, ‘C2H2’, ‘HCN’]). Default is ‘’.

  • cdn_scale_fac (list of float, optional) – Scaling factors for the column density of each molecule. Useful for applying isotopologue abundance ratios. If the same size as number of species in line_selection_file, it overrides values from line_selection_file. Default is [1].

  • mol_mass (float or list of float, optional) – Molecular mass(es) in atomic mass units (amu). Required if line_selection_file is not provided. Default is None.

  • HITRANfile (str or list of str, optional) – Path(s) to the HITRAN ‘.par’ file(s) containing the line data. Default is ‘’.

  • ESelection (list or None, optional) – Upper energy level limits for line selection. Can be a single range (e.g., [0, 4000]) or a nested list of ranges per species. Default is None.

  • bandSelection (list or None, optional) – Upper and lower level band quantum number notations (strings) to select. e.g., [‘0 0 1 0 A*’, ‘0 0 0 0 A*’]. Default is None.

  • hitran_min_strength (float or list of float, optional) – Minimum line strength threshold to read from the HITRAN file. Default is 1e-99.

  • custom_partition_sum_file (str or list of str, optional) – Path(s) to file(s) containing custom partition sums (two columns: temperature, partition sums). Default is ‘’.

  • isotopolog (list of int, optional) – List containing HITRAN isotopologue IDs for the selected species. Default is [1].

  • waveSelection (list, optional) – Wavelength limits in microns to restrict the lines selected from the HITRAN file. Default is [4, 30].

  • wave_spec (list, optional) – Wavelength limits in microns for calculating the final output spectra. Default is [4.9, 28].

  • R_grid (float, optional) – Resolving power of the high-resolution grid on which the spectra is initially calculated. A minimum of 1e5 is recommended. Default is 1e5.

  • output ({'file', 'return', 'both'}, optional) – Defines how the output is handled. ‘file’ writes to disk, ‘return’ outputs the slab object to the Python environment, and ‘both’ does both. Default is ‘both’.

  • output_filename (str, optional) – Filename and path for the output file if output writes to disk. Default is ‘default.out’.

  • mode ({'overlap', 'line_by_line', 'both'}, optional) – Calculates the spectra considering line overlap, strictly line-by-line, or both. Default is ‘both’.

  • convolve_R (float or None, optional) – Spectral resolving power to which the final output spectra should be convolved (e.g., 3500 for JWST/MIRI). If None, no convolution is applied. Default is None.

  • verbose (bool, optional) – If True, prints progress logs during calculation. Default is True.

Returns:

slab – The calculated slab object containing the spectra and optical depth data. Returns an empty tuple () if output is set to ‘file’.

Return type:

object or tuple

Raises:
  • TypeError – If output_filename or custom_partition_sum_file are of incorrect types.

  • ValueError – If the lengths of species-specific lists (masses, HITRAN files, scaling factors, etc.) do not match the number of molecules provided.

prodimopy.run_slab.run_0D_slab_grid(Ng, Tg, vturb, line_selection_file='', molecule='', mol_mass=None, HITRANfile='', ESelection=None, bandSelection=None, hitran_min_strength=1e-99, cdn_scale_fac=[1], custom_partition_sum_file='', isotopolog=[1], waveSelection=[4, 30], wave_spec=[4.9, 28], R_grid=100000.0, output='both', output_directory='.', output_filename_prefix='default', mode='both', convolve_R=None, write_index_file=True, number_of_cores=1, verbose=True)[source]

This is a python implementation of 0D slab models, based on the FORTRAN version of 0D slab models in ProDiMo (https://prodimo.iwf.oeaw.ac.at/) This runs models with/without line overlap. More robust and efficient code is available on Fortran, please check the above website (especially for running large grids of models). The Fortran code also supports OMP and supports including multiple species.

Nglist or numpy.ndarray

Gas column density (cm-2)

Tg: list or numpy.ndarray

Gas temperature (K)

vturblist or numpy.ndarray

Turbulent velocity of the gas (km/s)

line_selection_filestr, optional

Path to a pre-defined line selection rules file. If provided, overrides arguments: molecule, mass, HITRANfile, ESelection, bandSelection, hitran_min_strength, custom_partition_sum_file, isotopolog, and waveSelection. Default is ‘’.

moleculestring or list of strings, optional

Molecule name, e.g. ‘CO2’ or [‘CO2’,’C2H2’,’HCN’]

mol_massfloat or list of floats, optional

Molecular mass(es) in atomic mass units (amu)

HITRANfilestring or list of strings, optional

Path(s) to the HITRAN ‘.par’ file(s) containing the line data downloaded from HITRAN

ESelectionlist or None, optional

Upper energy level limits for line selection.

bandSelectionlist or None, optional

Upper and lower level band quantum number notations (strings) to select.

hitran_min_strengthfloat or list of float, optional

Minimum line strength threshold to read from the HITRAN file, based on Woitke+2018, Eq. 2. Default is 1e-99.

cdn_scale_faclist of float, optional

Scaling factors for the column density of each molecule. Useful for applying isotopologue abundance ratios. If the same size as number of species in line_selection_file, it overrides values from line_selection_file. Default is [1].

custom_partition_sum_filestring or list of strings, optional

Path pointing to file containing custom partition sum

isotopologlist, optional

List containing isotopologue numbers (HITRAN format)

waveSelectionlist, optional

Wavelength limits in microns to select the lines from the HITRAN file

wave_speclist, optional

Wavelength limits in microns for calculating the spectra

R_gridfloat, optional

High resolution grid on which the spectra has to be calculated initially

outputstring, optional

‘file’ to write output to file, ‘return’ to return a slab type, ‘both’ for both

output_directorystring, optional

Directory path where the output files should be written

output_filename_prefixstring, optional

Filename prefix for the output file without file extension

modestring, optional

‘overlap’ or ‘line_by_line’ or ‘both’

convolve_Rfloat, optional

Spectral resolving power to which the spectra has to be convolved

write_index_fileboolean, optional

Write an index file containing the index number of each file

number_of_coresint or string, optional

Number of cores to use to parallelize the grid run.

verboseboolean, optional

Whether or not to print progress log

prodimopy.run_slab.run_0D_point(Ng, Tg, vturb, molecule, mol_mass, cdn_scale_fac, N_sp_lines, nu0, Aul, E_u, E_l, gu, gl, isotopolog, nu_grid, mode, custom_partition_sum_int=[None])[source]

This runs a RT on a single point with/without line overlap. All variables use SI unit

Ngfloat

Gas column density (m-2)

Tg: float

Gas temperature (K)

vturbfloat

Turbulent velocity of the gas (m/s)

moleculestring or list of strings

Molecule name, e.g. ‘CO2’ or [‘CO2’,’C2H2’,’HCN’]

mol_massfloat or list of floats

Molecular mass(es) in atomic mass units (amu)

cdn_scale_faclist

Column density scaling factor

N_sp_lineslist

List of number of lines of each molecule

nu0numpy array

Line frequencies (Hz)

Aulnumpy array

Einstein A coefficient

E_unumpy array

Upper energy level

E_lnumpy array

Lower energy level

gunumpy array

Statistical weight / degeneracy of upper level

glnumpy array

Statistical weight / degeneracy of lower level

isotopologlist

List containing isotopologue numbers (HITRAN format)

nu_gridnumpy array

Array containing spectral grid for the final spectra

modestring

‘line_by_line’ or ‘overlap’ or ‘both’

custom_partition_sum_filestring

Path pointing to file containing custom partition sum (2 columns: temperature, partition sums)

prodimopy.run_slab.convert_to_slab_format(nu_grid, I_nu_line, tau_ret, I_nu, tau_lbl, R_grid, Ng, Tg, cdn_scale_fac, vturb, pop_l, pop_u, mol_data, molecule, N_sp_lines, mode)[source]

Writes output file containing the output of the 0D slab model

prodimopy.run_slab.run_1D_radial_slab(Ng, Tg, R, d, vturb, R_grid, output_filename, molecule, mol_mass, HITRANfile, cdn_scale_fac=[1], custom_partition_sum_file='', width='area_given', Rin_limit=0, Rout_limit=1e+99, isotopolog=[1], wave_mol=[4, 30], wave_spec=[4.9, 28], verbose=False)[source]

This is a python implementation of 1D radial slab models, based on the FORTRAN version of 1D slab models in ProDiMo (https://prodimo.iwf.oeaw.ac.at/) This runs models with line overlap. More robust and efficient code (including vertical slab model) is available in Fortran, please check the above website (especially for running large grids of models). The Fortran code also supports OMP and supports including multiple species.

Ngnumpy array or list

Gas column density (cm-2)

Tgnumpy array or list

Gas temperature (K)

Rnumpy array or list

Radius (AU)

dfloat

Distance of the disk (parsec)

vturbfloat

Turbulent velocity of the gas (km/s)

R_gridfloat

High resolution grid on which the spectra has to be calculated initially Recommend minimum of 1e5

output_filenamestring

Filename(+path) for the fits output file Use the extension ‘.fits.gz’

moleculestring

Molecule name, e.g. ‘CO2’

moleculestring or list of strings

Molecule name, e.g. ‘CO2’ or [‘CO2’,’C2H2’,’HCN’]

mol_massfloat or list of floats

Molecular mass(es) in atomic mass units (amu)

HITRANfilestring or listt of strings

Path(s) to the HITRAN ‘.par’ file(s) containing the line data downloaded from HITRAN

cdn_scale_faclist of floats

Column density of the molecules are scaled by these factors (useful for including isotopologue ratios)

custom_partition_sum_filestring

Path pointing to file containing custom partition sum (2 columns: temperature, partition sums)

widthstring or list or float

‘area_given’ - the provided radii array is used as the emitting area equivalent radius ‘infer’ - Assumes the provided radius as radial distance from the star and calculates the width of individual rings of slab grids list - List containing emitting area equivalent radii float - Constant emitting area equivalent radius, used for all grid points

Rin_limitfloat

Inner radius limit of the disk (AU)

Rout_limitfloat

Outer radius limit of the disk (AU)

isotopologlist

List containing isotopologue numbers (HITRAN format)

wave_mollist

Wavelength limits in microns to select the lines from the HITRAN file

wave_speclist

Wavelength limits in microns for calculating the spectra

prodimopy.run_slab.growth_function(tau)[source]

This function returns the growth function, or the flux growth for the given line optical depth(s)

taunumpy array or list

line optical depth

prodimopy.run_slab.get_dust_opacity_provider(dust_sizes, wavelengths, Q_abs_table)[source]

Factory that returns a pre-configured interpolation function.

class prodimopy.run_slab.slab_model_1D[source]

Bases: object

class:: slab_model_1D Class to run 1D forward slab models

unit_conversions()[source]
reset_units()[source]
init_grid()[source]
read_Qmatrix()[source]
init_dust()[source]
solve_dust_settle(r_au=1.0, M_star=1.0, grain_density=3000)[source]

r_au: Distance from star in AU M_star: Stellar mass in Solar Masses grain_density: kg/m^3 (e.g., 3000 for silicates)

init_gas()[source]
calculate_source(igrid)[source]
calculate_dust_source(igrid)[source]

Calculates source function and tau for dust only.

calculate_spectrum(I_background=None)[source]

Calculates the emergent intensity I_nu from the 1D slab. I_background: Optional array of size (NLAMBDA) for radiation

entering from the bottom (e.g., stellar/disk midplane).

calculate_dust_continuum(I_background=None)[source]
run_model()[source]
convolve(R=1, lambda_0=1, lambda_n=1)[source]
convolve_custom(values, R=1, lambda_0=1, lambda_n=1)[source]
from_prodimo(model_path, r, species=[], LineSelectionFile='LineSelection.in', MieFile='', lambda_0=4.9, lambda_n=28, R_grid=100000.0)[source]