radis.misc.config module

Summary

Functions to parse the ~/radis.json Configuration file

Notes

Create a ~/radis.json file in your HOME that contains all machine-specific information (e.g: path to databanks). See DBFORMAT for expected format

Routine Listing


DBFORMAT = '\n--------------------------\n\n[MY-HITEMP-CO2]                  #  your databank name: use this in calc_spectrum()\n                                 #  or SpectrumFactory.load_databank()\ninfo = HITEMP 2010 databank      #  whatever you want\npath =                           #  no "", multipath allowed\n       D:\\Databases\\HITEMP-CO2\\hitemp_07\n       D:\\Databases\\HITEMP-CO2\\hitemp_08\n       D:\\Databases\\HITEMP-CO2\\hitemp_09\nformat = hitran                  #  \'hitran\' (HITRAN/HITEMP), \'cdsd-hitemp\', \'cdsd-4000\'\n                                 # databank text file format. More info in\n                                 # SpectrumFactory.load_databank function.\nparfuncfmt:                      #  \'cdsd\', \'hapi\', etc.\n                                 # format to read tabulated partition function\n                                 # file. If `hapi`, then HAPI (HITRAN Python\n                                 # interface) is used to retrieve them (valid if\n                                 # your databank is HITRAN data). HAPI is embedded\n                                 # into RADIS. Check the version.\n# Optional\n# ----------\nparfunc:                         #  path to tabulated partition function to use.\n                                 # If `parfuncfmt` is `hapi` then `parfunc`\n                                 # should be the link to the hapi.py file. If\n                                 # not given, then the hapi.py embedded in RADIS\n                                 # is used (check version)\nlevels_iso1                      #  path to energy levels (needed for non-eq\n                                 # calculations). Default None\nlevels_iso2                      # etc\nlevels_iso4                      # etc\nlevelsfmt:                       #  \'cdsd\', etc.\n                                 # how to read the previous file. Default None.\nlevelsZPE:                       #  zero-point-energy (cm-1): offset for all level\n                                 # energies. Default 0 (if not given)\n\n--------------------------'[source]

Typical expected format of a ~/.radis entry:

--------------------------

[MY-HITEMP-CO2]                  #  your databank name: use this in calc_spectrum()
                                 #  or SpectrumFactory.load_databank()
info = HITEMP 2010 databank      #  whatever you want
path =                           #  no "", multipath allowed
       D:\Databases\HITEMP-CO2\hitemp_07
       D:\Databases\HITEMP-CO2\hitemp_08
       D:\Databases\HITEMP-CO2\hitemp_09
format = hitran                  #  'hitran' (HITRAN/HITEMP), 'cdsd-hitemp', 'cdsd-4000'
                                 # databank text file format. List of all
                                 # formats in :py:data:`~radis.lbl.loader.KNOWN_DBFORMAT`
                                 # More info in
                                 # :py:meth:`~radis.lbl.loader.DatabankLoader.load_databank` function.
parfuncfmt:                      #  'cdsd', 'hapi', etc.
                                 # format to read tabulated partition function
                                 # file. If `hapi`, then HAPI (HITRAN Python
                                 # interface) is used to retrieve them (valid if
                                 # your databank is HITRAN data). HAPI is embedded
                                 # into RADIS. Check the version.
                                 # List of all formats in :py:data:`~radis.lbl.loader.KNOWN_LVLFORMAT`
# Optional
# ----------
parfunc:                         #  path to tabulated partition function to use.
                                 # If `parfuncfmt` is `hapi` then `parfunc`
                                 # should be the link to the hapi.py file. If
                                 # not given, then the hapi.py embedded in RADIS
                                 # is used (check version)
levels_iso1                      #  path to energy levels (needed for non-eq
                                 # calculations). Default None
levels_iso2                      # etc
levels_iso4                      # etc
levelsfmt:                       #  'cdsd', etc.
                                 # how to read the previous file. Default None.
levelsZPE:                       #  zero-point-energy (cm-1): offset for all level
                                 # energies. Default 0 (if not given)

--------------------------

For more information refer to the documentation: Configuration file :

Type:

str

DBFORMATJSON = '\n--------------------------\n\n{\n"database": {                       # database key, stores all databases\n    "MY-HITEMP-CO2": {              # your databank name: use this in calc_spectrum()\n                                    # or SpectrumFactory.load_databank()\n    "info": "HITEMP 2010 databank", # whatever you want\n    "path":                         # no "", multipath allowed\n       ["D:\\Databases\\HITEMP-CO2\\hitemp_07",\n        "D:\\Databases\\HITEMP-CO2\\hitemp_08",\n        "D:\\Databases\\HITEMP-CO2\\hitemp_09"],\n    "format": "hitran",             # \'hitran\' (HITRAN/HITEMP), \'cdsd-hitemp\', \'cdsd-4000\'\n                                    # databank text file format. More info in\n                                    # SpectrumFactory.load_databank function.\n    "parfuncfmt":                   # \'cdsd\', \'hapi\', etc.\n                                    # format to read tabulated partition function\n                                    # file. If `hapi`, then HAPI (HITRAN Python\n                                    # interface) is used to retrieve them (valid if\n                                    # your databank is HITRAN data). HAPI is embedded\n                                    # into RADIS. Check the version.\n    # Optional\n    # ----------\n    "parfunc":                      # path to tabulated partition function to use.\n                                    # If `parfuncfmt` is `hapi` then `parfunc`\n                                    # should be the link to the hapi.py file. If\n                                    # not given, then the hapi.py embedded in RADIS\n                                    # is used (check version)\n    "levels_iso1":                  # path to energy levels (needed for non-eq\n                                    # calculations). Default None\n    "levels_iso2":                  # etc\n    "levels_iso4":                  # etc\n    "levelsfmt":                    # \'cdsd\', etc.\n                                    # how to read the previous file. Default None.\n    "levelsZPE":                    # zero-point-energy (cm-1): offset for all level\n    }                               # energies. Default 0 (if not given)\n  }\n}\n\n--------------------------'[source]

Typical expected format of a ~/radis.json entry in “database” key:

--------------------------

"MY-HITEMP-CO2": {              # your databank name: use this in calc_spectrum()
                                # or SpectrumFactory.load_databank()
"info": "HITEMP 2010 databank", # whatever you want
"path":[                        # no "", multipath allowed
    "D:\Databases\HITEMP-CO2\hitemp_07"
    "D:\Databases\HITEMP-CO2\hitemp_08"
    "D:\Databases\HITEMP-CO2\hitemp_09"
],
"format": "hitran",             # 'hitran' (HITRAN/HITEMP), 'cdsd-hitemp', 'cdsd-4000'
                                # databank text file format. List of all
                                # formats in :py:data:`~radis.lbl.loader.KNOWN_DBFORMAT`
                                # More info in
                                # :py:meth:`~radis.lbl.loader.DatabankLoader.load_databank` function.
"parfuncfmt":                   # 'cdsd', 'hapi', etc.
                                # format to read tabulated partition function
                                # file. If `hapi`, then HAPI (HITRAN Python
                                # interface) is used to retrieve them (valid if
                                # your databank is HITRAN data). HAPI is embedded
                                # into RADIS. Check the version.
                                # List of all formats in :py:data:`~radis.lbl.loader.KNOWN_LVLFORMAT`
# Optional
# ----------
"parfunc":                      # path to tabulated partition function to use.
                                # If `parfuncfmt` is `hapi` then `parfunc`
                                # should be the link to the hapi.py file. If
                                # not given, then the hapi.py embedded in RADIS
                                # is used (check version)
"levels_iso1":                  # path to energy levels (needed for non-eq
                                # calculations). Default None
"levels_iso2":                  # etc
"levels_iso4":                  # etc
"levelsfmt":                    # 'cdsd', etc.
                                # how to read the previous file. Default None.
"levelsZPE":                    # zero-point-energy (cm-1): offset for all level
}                               # energies. Default 0 (if not given)

--------------------------

For more information refer to the documentation: Configuration file :

Type:

str

addDatabankEntries(dbname, dict_entries, verbose=True, configpath='/home/docs/radis.json')[source]

Add database dbname with entries from dict_entries.

If database already exists in ~/radis.json, raises an error

Examples

addDatabankEntries("HITEMP2010-CO2",
    {
        "info": "HITEMP2020 CO2 lines with TIPS-2017 for partition functions (equilibrium) and RADIS for rovibrational energies (nonequilibrium) ",
        "path": ["PATH/TO/HITEMP/CO2/*.par"],
        "format": "hitran",
        "parfuncfmt": "hapi",
        "levelsfmt": "radis",
    })
addDatabankEntries_configformat(dbname, dict_entries, verbose=True)[source]

Add database dbname with entries from dict_entries.

If database already exists in ~/.radis, raises an error

Examples

addDatabankEntries("HITEMP2010-CO2",
    {
        "info": "HITEMP2020 CO2 lines with TIPS-2017 for partition functions (equilibrium) and RADIS for rovibrational energies (nonequilibrium) ",
        "path": ["PATH/TO/HITEMP/CO2/*.par"],
        "format": "hitran",
        "parfuncfmt": "hapi",
        "levelsfmt": "radis",
    })
convertRadisToJSON(config_path_json, config_path_old='/home/docs/.radis')[source]

Converts the ~/.radis file into json formatted file ~/radis.json

Example

original ~/.radis file format:

[HITRAN-CO2-TEST]
info = HITRAN 2016 database, CO2, 1 main isotope (CO2-626), bandhead: 2380-2398 cm-1 (4165-4200 nm)
path = PATH_TO\radis\radis\test\files\hitran_co2_626_bandhead_4165_4200nm.par
format = hitran
parfuncfmt = hapi
levelsfmt = radis

{ “database”: {

“HITRAN-CO2-TEST”: {

“info”: “HITRAN 2016 database, CO2, 1 main isotope (CO2-626), bandhead: 2380-2398 cm-1 (4165-4200 nm)”, “path”: “PATH_TO\radis\radis\test\files\hitran_co2_626_bandhead_4165_4200nm.par”, “format”: “hitran”, “parfuncfmt”: “hapi”, “levelsfmt”: “radis”

}

}

}

createConfigFile(config_path, verbose=True)[source]
diffDatabankEntries(dict_entries1, dict_entries2, verbose=True)[source]

Compare two Databank entries under dict format (i.e: output of getDatabankEntries)

Returns None if no differences are found, or the first different key

getDatabankEntries(dbname, get_extra_keys=[], configpath='/home/docs/radis.json')[source]

Read ~/radis.json config file and returns a dictionary of entries.

Parameters:
  • dbname (str) – database name in ~/radis.json config file

  • get_extra_keys (list) – read additional parameters on top of the usual Databank format keys :

Notes

Databank format:

"MY-HITEMP-CO2": {              # your databank name: use this in calc_spectrum()
                                # or SpectrumFactory.load_databank()
"info": "HITEMP 2010 databank"  # whatever you want
"path": [                       # no "", multipath allowed
    "D:\Databases\HITEMP-CO2\hitemp_07",
    "D:\Databases\HITEMP-CO2\hitemp_08",
    "D:\Databases\HITEMP-CO2\hitemp_09"
],
"format": "hitemp"              # 'hitran' (HITRAN / HITEMP), 'cdsd-hitemp', 'cdsd-4000'
                                # Databank text file format. More info in
                                # SpectrumFactory.load_databank function.

# Optional:

"parfunc":                      # path or 'USE_HAPI'
                                # path to tabulated partition functions. If
                                # `USE_HAPI`, then HAPI (HITRAN Python
                                interface) [1]_ is used to retrieve them (valid
                                if your databank is HITRAN data). HAPI
                                is embedded into RADIS. Check the version.

"parfuncfmt":                   # 'cdsd'
                                # format to read tabulated partition function
                                # file. If `USE_HAPI` is given as `parfunc`
                                # parameter then this line should not be used.

"levels_iso1":                  # path to energy levels (needed for non-eq)
                                # calculations.
"levels_iso2":                  # etc
"levels_iso4":                  # etc

"levelsfmt":                    # 'cdsd'
}                               # how to read the previous file.

References

getDatabankEntries_configformat(dbname, get_extra_keys=[])[source]

Read ~/.radis config file and returns a dictionary of entries.

Parameters:
  • dbname (str) – database name in ~/.radis config file

  • get_extra_keys (list) – read additional parameters on top of the usual Databank format keys :

Notes

Databank format:

[MY-HITEMP-CO2]                  #  your databank name: use this in calc_spectrum()
                                 #  or SpectrumFactory.load_databank()
info = HITEMP 2010 databank      # whatever you want
path =                           # no "", multipath allowed
       D:\Databases\HITEMP-CO2\hitemp_07
       D:\Databases\HITEMP-CO2\hitemp_08
       D:\Databases\HITEMP-CO2\hitemp_09
format = hitemp                  # 'hitran' (HITRAN / HITEMP), 'cdsd-hitemp', 'cdsd-4000'
                                 # Databank text file format. More info in
                                 # SpectrumFactory.load_databank function.

# Optional:

parfunc                          # path or 'USE_HAPI'
                                 # path to tabulated partition functions. If
                                 # `USE_HAPI`, then HAPI (HITRAN Python
                                 interface) [1]_ is used to retrieve them (valid
                                 if your databank is HITRAN data). HAPI
                                 is embedded into RADIS. Check the version.

parfuncfmt:                      # 'cdsd'
                                 # format to read tabulated partition function
                                 # file. If `USE_HAPI` is given as `parfunc`
                                 # parameter then this line should not be used.

levels_iso1                      # path to energy levels (needed for non-eq)
                                 # calculations.
levels_iso2                      # etc
levels_iso4                      # etc

levelsfmt                        # 'cdsd'
                                 # how to read the previous file.

References

getDatabankList(configpath='/home/docs/radis.json')[source]

Get all databanks available in :ref:`~/radis.json

getDatabankList_configformat()[source]

Get all databanks available in ~/.radis.

get_config(configpath='/home/docs/radis.json')[source]

Read the default RADIS config.json file configpath (default CONFIG_PATH_JSON and override it with the entries of the user config file ~/.radis (CONFIG_PATH_DEFAULT

get_user_config(configpath='/home/docs/radis.json')[source]

Read config file and returns it.

get_user_config_configformat()[source]

Read config file and returns it.

Config file name is hardcoded: ~/.radis

init_radis_json(config_path_json, config_path_old='/home/docs/.radis')[source]

Checks whether config_path_json (usually json) exists.

If not then we use convertRadisToJSON() to convert radis into json

printDatabankEntries(dbname, crop=200, configpath='/home/docs/radis.json')[source]

Print databank info.

Parameters:
  • dbname (str) – database name in ~/radis.json

  • crop (int) – if > 0, cutoff entries larger than that

printDatabankEntries_configformat(dbname, crop=200)[source]

Print databank info.

Parameters:
  • dbname (str) – database name in ~/.radis

  • crop (int) – if > 0, cutoff entries larger than that

printDatabankList(configpath='/home/docs/radis.json')[source]

Print all databanks available in ~/radis.json

printDatabankList_configformat()[source]

Print all databanks available in ~/.radis