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.
Please check the documentation on our readthedocs page for installation instructions, detailed documentation of the library and usage examples.
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
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.
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
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