HII-CHI-mistry-UV is a python program that calculates, for gaseous nebulae ionized by massive stars or active galactic nuclei, the oxygen abundance in terms of 12+log(O/H), the carbon-to-oxygen ratio as log(C/O) and the ionisation parameter as log U, consistently with the direct method. This is done from the bayesian-like comparison between large grids of photoionization models and observed emission-line intensities in the ultraviolet and optical spectral ranges. The methodology and the results are described in Pérez-Montero & Amorín (2017) for star-forming galaxies and in Pérez-Montero et al (2023b) for the Narrow -Line Region in AGN.


The most recent version for HII-CHI-mistry-UV is version 5.1. The link leads to a compressed tar.gz file containing the python file of the code, the libraries of the models and the constrains, and a file with instructions. Previous versions of the program can be obtained in the History and Downloads section. They can also be found in GitHub.

How to run it

HII-CHI-mistry-UV has been originally written in python v. 2.7, but from version 5 is only compatible with python 3. It requires the library numpy (versions previous to v2.0 use the library asciidata).

The program also requires the files of the emission line intensities predicted by the models, calculated assuming different sets of input conditions. All were calculated with Cloudy v.17. These libraries are stored in the folder Library_UV and include models for star-forming galaxies using spectral energy distributions from POPSTAR and from BPASS v.2.1.

For the NLR in AGNs, the libraries include results from models calculated using a double composite power-law with parameter alpha(UV) = -1.0 and for two possible values of alpha(OX) = -0.8 and -1.2, or assuming different criteria for the stopping of calculations in the models (2% or 98% fraction of free electrons), or the presence or absence of dust. Nevertheless, in addition the codee also admits grids of models defined by the user.

The code also requires files to constrain the model grids when a limited set of emission-lines are given as input. These are stored in the folder Constrains and can also be edited by the user. These files represent the set of models, limiting the values of log U at each Z , and limiting also the values of C/O as a function of O/H.

To run the program, just type (for v5.1, in other versions use the name of the corresponding python script:
python HCm-UV_v5.1.py
Alternatively, from version 3.2 it is possible to specify in the prompt the input file and the number of iterations for the Monte Carlo simulation (e.g. python HCm-UV_v5.0.py input.dat 100).Once the input file has been specified in the prompt or by direct question, the code will ask about what SED of models is going to be used:
(1) Young POPSTAR massive cluster
(2) BPASS cluster models atmospheres with binaries
(3) double composite power-law AGN.

If AGN is selected, the code will also ask for the value of alpha(OX). considered in the models, the stopping criterion and the presence of dust. Later, once selected the model SED, the program will ask for the template files used to constrain the models and for the possible use of a interpolated high-resolution grid (0: non-interpolated or 1: interpolated). This will increase the resolution of the grid in O/H, C/O and log U in a factor 10, but it will slow down the calculation. The code can also be ran in non-interactive mode is the corresponding variable 'interactive' is set to 'False' in the script of the code.

The input file

It is a separated file written in text format with the information organised as a table whose first row contains the labels for the different columns, corresponding to the identification of each row and the emission line fluxes and their errors. The table can contain columns for other quantities, but the code will only read the following labels:

ID for the identification name of the row
Lya_1216 and eLya_1216: Ly alpha HI 1216 and its error
NV_1239 and eNV_1239: nV] 1239 and its error
CIV_1549 and eCIV_1549: CIV]    1549 and its error
HeII_1640 and eHeII_1640: HeII    1640 and its error
OIII_1665 and eOIII_1665: OIII]  1665 and its error
CIII_1909 and eCIII_1909: CIII   1909 and its error
Hb_4861 and eHb_4861: Hb HI  4861 and its error
OIII_5007 and eOIII_5007: [OIII] 5007 and its error

all of them reddening corrected. It is not mandatory to introduce all lines but, if a line is included in the file and no information exists about it or its error, it must be typed as zero. Notice that contrary to HII-CHI-mistry for the optical the lines do not have to be relative to Hß flux.


If the input file is correct, the program will ask for the chosen SED and the use of interpolations and it will begin to calculate the wanted quantities and their corresponding errors.
The information will be displayed on the screen for each object, along with the ratio of completeness of the task. It will be also added an index indicating if a specific constrain has been used, where

1: the complete grid is used (only if [OIII] 5007/1665 > 0)
2: the log U limited grid is used (when [OIII] 1665/5007 = 0)
3: the log U and C/O limited grid is used (if, besides, CIII]/OIII] cannot be obtained).

At the end, the program will create a file called using the name of the input file + "_hcm-output.dat with the information of the used models, the identification of each row, the input emission line fluxes and their errors, and seven columns with the solutions corresponding to the following information:

grid index
error of 12+log(O/H)
log(C/O) (-10 if grid 3 is used)
error of log(C/O)
log U
error of log(U) (take with care if constrains 2 or 3 are used)

If the code finds an error, a value 9999 will be included for any of these derived quantities.

History and Downloads

Here we list the different versions of the program with links to download them.