Back to main page


HII-CHI-mistry-UV is a python program that calculates, for gaseous nebulae ionised by massive stars, 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, from a set of UV and optical emission-line intensities consistently with the direct method.
The methodology and the results are described in Pérez-Montero & Amorín (2017).


Each compressed file contains the python file of the code, the libraries of the models and a file with instructions. -


HII-CHI-mistry-UV has been written in python 2.7, but from version 3.2 it is compatible with python 3. It requires the library numpy. It also requires the files of the emission line fluxes predicted by the models, assuming different input conditions.

All default models are stored in the folder Library_uv and were calculated with Cloudy v.17 and a POPSTAR SED with an age of 1Myr and using an IMF of Chabrier. There are also files to use BPASSv. 2.1 atmospheres with an IMF of slope x = -1.35, an upper mass limit of 300 solar masses at an age of 1 Myr, assuming an electron density of 500 cm-3. Nevertheless, the user can also use her/his own models instead.
The code also requires files to constrain the models under different assumptions when no all possible emission-line fluxes are given. These are stored in the folder Constrains and represent the models with constrained values of O/H as a function of log U, and the models with constrained values of O/H as a function of C/O. As for libraries, these templates can also be edited.

To run the program, just type for version 4.2 in the terminal prompt

> python HCm-UV_v4.2.py

The program will ask for the input file. 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_v4.2.py input.dat 100).


It must be written in text format. the first row must declare the labels for the introduced emission-line fluxes and errors. The next rows include the fluxes in arbitrary units of the emission lines and their errors using the following labels:

'ID': identification name
'Lya_1216' and 'eLya_1216': Lya HI 1216 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 no information exists about a certain line or its error, it must typed as zero. Notice that contrary to
HII-CHI-mistry for the optical the lines do not have to be relative to Hbeta flux.


If the input file is correctly introduced, the program will ask for the preferred template files for the constrains )SF or EELG), and interpolation of the models and it will calculate the required quantities and their corresponding errors.
The information will be displayed in the screen for each object/row, along with the ratio of completeness of the task. It will be also added an index saying what grid was used, where

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

In addition the results will be saved on a file whose name is the name of the input file + "_hcm-uv-output.dat". The header of this file will contain all information about the chosen models. The first column will denote the assigned ID for each row and the next columns of this file will be the input emission lines and their errors. Finally, it will add the following seven columns:

grid index
error of 12+log(O/H)
log(C/O) (-10 if grid 3 is used)
error of log(N/O)
log U
error of log(U) (tak

Enrique Pérez-Montero. IAA-CSIC
Last update: 2022, June

This program has been made thanks to the financial support from Spanish AYA project Estallidos