radis / radis

šŸŒ± A fast line-by-line code for high-resolution infrared molecular spectra
http://radis.github.io/
GNU Lesser General Public License v3.0
214 stars 126 forks source link

NO2 isotope bug #703

Open foff1nho opened 1 week ago

foff1nho commented 1 week ago

šŸ› Describe the bug

There is an error in the handling of the isotopes of NO2. Error 1: In the molparam.txt file: The data format should be:

id iso isoname abundance     Q_296K      gj    molar_mass
#   H2O (1)
1  1  161  .997317E+00    1.7464E+02    1     18.010565
1  2  181  1.99983E-03    1.7511E+02    1     20.014811
1  3  171  3.71884E-04    1.0479E+03    6     19.014780
1  4  162  3.10693E-04    8.5901E+02    6     19.016740

But for NO2 is written as:

#   NO2 (10)
10 1  646  .991616E+00    1.3578E+04    3     45.992904
10 1  656  3.64564E-03    9.2929E+03    2     46.989938

Note the second row of the second column for NO2, the isotope should be 2 rather than 1.

Error 2: In the molparam.py file:

Only one of the isotopes of NO2 is present, error is on line 62:

    (10, 1): "(14N)(16O)2",

the correct version should be:

    (10, 1): "(14N)(16O)2",
    (10, 2): "(15N)(16O)2",

Finally, after implementing these changes this result in a further error on line 357 of molparam.py:

        else:
            out = self.df.loc[(M, isotope), key]
            assert len(out) == 1
            return out.iloc[0]

The assert statement does not work anymore as self.df.loc always returns a float64. In keeping with the original intention, I fixed this with the following:

        else:
            out = self.df.loc[(M, isotope), key]
            assert isinstance(out, float)
            return out

šŸ’” Possible solutions

As described above

šŸŽ² Radis version

0.15.2

šŸ’» Operating system

MacOS

minouHub commented 1 week ago

Thanks for reporting this bug. Actually, the file molparam.txt could be further updated with the new HITRAN version here: https://hitran.org/media/molparam.txt. Notably, the partition function at 296 K are also changed a bit but I'm not sure this is used anyway. @erwanp do you know if only the molar mass and abundance are used?

Concerning the assert statement assert isinstance(out, float), I guess this works because it verifies that there is only a single entry that matches the isotopologue request.

@foff1nho do you want to create a PR on this?