HII-CHI-mistry-IR 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 nitrogen-to-oxygen ratio as log(N/O) and the ionisation parameter as log U, consistently with the direct method. From version 3.1, the code can also supply a solution for sulphur abundance. This is done from the bayesian-like comparison between large grids of photoionization models and observed emission-line intensities in infrared spectral ranges. The methodology and the results are described in Fernández-Ontiveros et al (2021) for star-forming regions, and in Pérez-Díaz et al (2022) for the Narrow -Line Region in AGN.


The most recent version for HII-CHI-mistry-IR is version 3.2. 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-IR has been originally written in python v. 2.7, but from version 3 is only compatible with python 3. It requires the library numpy.

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_IR 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). 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 N/O as a function of O/H.

To run the program, just type (for v3.2, in other versions use the name of the corresponding python script:
python HCm-IR_v3.2.py
Alternatively 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-IR_v3.1.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 and the stopping criterion. 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 if the variable 'interactive' is set to 'False' in the script 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
HI_4m and eHI_4m: HI 4.05 microns and its error
ArIII_7m and eArIII_7m: [ArIII] 6.98 microns and its error
HI_7m and eHI_7m: HI 7.46 microns and its error
ArIV_8m and eArIV_8m: [ArIV] 7.90 microns and its error
ArIII_9m and eArIII_9m: [ArIII] 8.99 microns and its error
SIV_10m and eSIV_10m: [SIV] 10.5 microns and its error
HI_12m and eHI_12m: HI 12.4 microns and its error
NeII_12m and eNeII_12m: [NeII] 12.8 microns and its error
ArV_13m and eArV_13m: [ArV] 13.1 microns and its error
NeV_14m and eNeV_14m: [NeV] 14.9 microns and its error
NeIII_15m and eNeIII_15m: [NeIII] 15.5 microns and its error
SIII_18m and eSIII_18m: [SIII] 18.7 microns and its error
NeV_24m and eNeV_24m: [NeV] 24.3 microns and its error
OIV_25m and eOIeV_25m: [OIV] 25.9 microns and its error
SIII_33m and eSIII_33m: [SIII] 33.7 microns and its error
OIII_52m and eOIII_52m: [OIII] 52 microns and its error
NIII_57m and eNIII_57m: [NIII] 57 microns and its error
OIII_88m and eOIII_88m: [OIII] 88 microns and its error
NII_122m and eNII_122m: [NII] 122 microns and its error
'NII_205m' and 'eNII_205m': [NII] 205 microns 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 an auroral-to-nebular line is introduced, so in the IR version is not used)
2: the log U limited grid is used
3: the log U and N/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 nine columns with the solutions corresponding to the following information:

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

A value '9999' will be include in these derived quantities in case the code finds an error in the inserted input lines.

History and Downloads

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