Radex Wrapper Functions¶
-
spectralradex.radex.
run
(parameters, output_file=None)¶ Run a single RADEX model using a dictionary to set parameters.
Parameters: - parameters (dict) – A dictionary containing the RADEX inputs that the user wishes to set,
all other parameters will use the default values. See
get_default_parameters()
for a list of possible parameters andrun_params()
for descriptions. - output_file (str) – If not
None
, the RADEX results are stored to this file in csv format/
- parameters (dict) – A dictionary containing the RADEX inputs that the user wishes to set,
all other parameters will use the default values. See
-
spectralradex.radex.
run_params
(molfile, tkin, cdmol, nh=0.0, nh2=0.0, op_ratio=3.0, ne=0.0, nhe=0.0, nhx=0.0, linewidth=1.0, fmin=0.0, fmax=500.0, tbg=2.73, geometry=1, output_file=None)¶ Run a single RADEX model from individual parameters
Parameters: - molfile (float) – Either a full path or a relative path beginning with “.” to a datafile in the Lamda database format. Alternatively, the filename of a datafile from list_data_files().
- tkin – Temperature of the Gas in Kelvin
- cdmol – Column density of the emitting species in cm \(^{-2}\)
- nh (float, optional) – Number density of H atoms
- nh2 (float, optional) – Total number density of H2 molecules, set this to o-H2 + p-H2 if using ortho and para H2 as collisional partners.
- op_ratio (float, optional) – Ortho to para ratio for H2. Defaults to statistical limit of 3 and used to set o-H2 and p-H2 densities from nh2.
- ne (float, optional) – Number density of electron.
- nhe (float, optional) – Number density of He atoms.
- nhx – Number density of H+ ions.
- linewidth (float, optional) – FWHM of the line in km s \(^{-1}\).
- fmin (float, optional) – Minimum frequency below which a line is not included in the results.
- fmax (float, optional) – Maximum frequency above which a line is not included in the results.
- tbg (float, optional) – Background temperature, defaults to CMB temperature 2.73 K.
- geometry (int, optional) – Choice of geometry of emitting object. 1 for sphere, 2 for LVG, 3 for slab.
-
spectralradex.radex.
run_grid
(parameters, target_value='FLUX (K*km/s)', pool=None)¶ Runs a grid of RADEX models using all combinations of any iterable items in the parameters dictionary whilst keeping other parameters constant. Returns a dataframe of results and can be parallelized with the
pool
parameter.Parameters: - parameters – A dictionary of parameters as provided by
get_default_parameters()
orget_example_grid_parameters()
. Parameters should take a single value when they are constant over the grid and contain and interable if they are to be varied. - molfile (str) – Either a full path or a relative path beginning with “.” to a datafile in the Lamda database format. Alternatively, the filename of a datafile from list_data_files().
- target_value (str,optional) – RADEX output column to be returned. Select one of ‘T_R (K)’, ‘FLUX (K*km/s)’, ‘FLUX (erg/cm2/s)’
- pool (Pool, optional) – a Pool object with
map()
,close()
, andjoin()
methods such as multiprocessing.Pool or schwimmbad.MPIPool. If supplied, the grid will be calculated in parallel.
- parameters – A dictionary of parameters as provided by
-
spectralradex.radex.
get_default_parameters
()¶ Get the default RADEX parameters as a dictionary, this largely serves as an example for the input required for
run()
.molfile should be a collsional datafile in the LAMDA database format. If using a local file, a full path or a relative path beginning with “.” is required. Otherwise, one of the files listed by
list_data_files()
can be supplied without a path.method is 1 (uniform sphere), 2 (LVG), or 3 (slab)
-
spectralradex.radex.
get_example_grid_parameters
()¶ Returns a dictionary of parameters for RADEX with iterables which can be used with
run_grid()
.
-
spectralradex.radex.
get_transition_table
(molfile)¶ Reads a collisional data file and returns a pandas DataFrame for the molecule with one row per transition containing the Einstein coefficients, upper level energy and frequency.
Parameters: molfile (str) – Either the full path to a collisional datafile or the filename of one supplied with SpectralRadex
-
spectralradex.radex.
get_collisional_partners
(molfile)¶ Reads a collisional data file and returns a dictionary containing the number of collisional partners and their names. The partner names match the input keys for
run()
Parameters: molfile (str) – Either the full path to a collisional datafile or the filename of one supplied with SpectralRadex
-
spectralradex.radex.
thermal_h2_op_ratio
(tkin)¶ If your data file has collisions with p-h2 and o-h2, you may want to use the thermal ratio to split your total H2 density. You can check that value for any given temperature with this function. Returns the ortho:para ratio as a float
Parameters: tkin (float) – Gas kinetic temperature
-
spectralradex.radex.
list_data_files
()¶ SpectralRadex is packaged with a selection of LAMDA collisional datafiles. This function prints the list of available files. You can provide the full path to another file in the parameter dictionary to use one not packaged with SpectralRadex.