spectralradex

A package for RADEX and spectral modelling


Keywords
astronomy, astrophysics, python, radex, radiative-transfer
License
MIT
Install
pip install spectralradex==1.1.3

Documentation

SpectralRadex

A python library that serves two purposes:

  • Run RADEX directly from python
  • Create model spectra from RADEX outputs

A number of libraries exist for the first purpose. However, most either launch the RADEX compiled binary as a subprocess or wrap the original code. In the former case, the creating of subprocesses can interfere with many Python multiprocessing methods. In the latter, running multiple models simultanously can be problematic due to the use of F77 common blocks in RADEX.

SpectralRadex uses F2PY to compile a version of RADEX written in modern Fortran, most importantly dropping the use of common blocks. As a result, running a RADEX model creates no subprocesses and can be parallelized.

Documentation

Please check the documentation on our readthedocs page for installation instructions, detailed documentation of the library and usage examples.

Installation

We recommend the simple approach of using pypi:

pip install spectralradex

However, if you wish to install manually, clone the repo and from the main directory run the following

python3 setup.py install

optionally, specify a path for the installation using

python3 setup.py install --prefix=/path/to/my/install

making sure that the install path is part of your PYTHONPATH environmental variable. You'll need to add the .egg directory eg. path/to/my/install/lib/python3.7/site-packages/spectralradex-0.0.2-py3.7-linux-x86_64.egg

Spectral Modelling

The library also includes functions for producing model spectra from the RADEX results. RADEX provides the optical depth at line centre and the excitation temperature of each molecular transition and these are used to calculate the line profile assuming gaussian line profiles in velocity. This has been benchmarked against CASSIS and provides a useful way to perform this modelling through python.

Spectral Modelling Formalism

Radex solves the radiative transfer problem without assuming LTE and then provides various line properties. Two of those properties are key: 1. The excitation temperature of each line 2. The optical depth at line centre

The first is the excitation temperature of an LTE model that would give the same amount of emission. Which means we can use it and the optical depth to get the brightness temperature as a function of velocity.

The brightness temperature is:

Where $T_{ex}$ is the excitation temperature and $T_{BG}$ is the background temperature, likely 2.73 K. So RADEX provides the value of $T_{ex}$ such that this equation gives the same value as the RADEX model. It also provides us with the optical depth at line centre, $\tau_0$ so we simply need to calculate $tau_v$ assuming a gaussian line profile:

Finally, we need to consider what to do with overlapping lines. We follow Hsieh et al 2015 and use an opacity weighted radiation temperature:

We can multiply $T_B$ by the filling factor to get the main beam temperature.