def build_test_databases(verbose=True): ''' Build test databases and add them in ~/.radis. Generate the file if it doesnt exist In particular: - HITRAN-CO2-TEST: CO2, HITRAN 2016, 4165-4200 nm - HITRAN-CO-TEST: CO, HITRAN 2016, 2000-2300 cm-1 These test databases are used to run the different test routines. They can obviously be used by Users to run simulations, but we suggest Users to download their own line databases files and add them to ~/.radis so they have more control on it ''' # Get list of databases try: dbnames = getDatabankList() except FileNotFoundError: dbnames = [] # %% Add test databases def add_to_parser(config, name, dic): for k, v in dic.items(): config[name][k] = v if verbose: print("Adding '{0}' database in ~/.radis".format(name)) for dbname, dbentries in TEST_DATABASES.items(): if dbname in dbnames: # Check entries are correct # for k diff = diffDatabankEntries(getDatabankEntries(dbname), dbentries, verbose=False) if diff is not None: raise ValueError('{0}'.format(diff)+\ '\nIn ~/.radis\n----------\n{0}'.format(getDatabankEntries(dbname))+\ '\n\nExpected\n---------\n{0}\n\n'.format(dbentries)+\ 'Test Database {0} doesnt match expected '.format(dbname)+\ 'entries for key `{0}`. See comparison above. '.format(diff)+\ 'To regenerate test databases just delete the {0} '.format(dbname)+\ 'entry in your ~/.radis') else: # add them (create ~/.radis file if doesnt exist yet) addDatabankEntries(dbname, dbentries) return
def setup_test_line_databases(verbose=True): """Build :py:data:`~radis.test.utils.TEST_DATABASES` and add them in ~/.radis. Generate the file if it doesnt exist In particular: - HITRAN-CO2-TEST: CO2, HITRAN 2016, 4165-4200 nm - HITRAN-CO-TEST: CO, HITRAN 2016, 2000-2300 cm-1 - HITEMP-CO2-TEST: CO2, HITEMP-2010, 2283.7-2285.1 cm-1, 3 isotopes - HITEMP-CO2-HAMIL-TEST: same as previous, with (some) energy levels computed from Tashkun effective Hamiltonian. These test databases are used to run the different test routines. They can obviously be used by Users to run simulations, but we suggest Users to download their own line databases files and add them to ~/.radis so they have more control on it Examples -------- Initialize the Line databases:: from radis import setup_test_line_databases setup_test_line_databases() Plot a CO2 spectrum at high temperature:: from radis import calc_spectrum calc_spectrum(2284, 2285, Tgas=2000, pressure=1, molecule='CO2', isotope=1 databank='HITEMP-CO2-TEST').plot() Note that 'HITEMP-CO2-TEST' is defined on 2283.7-2285.1 cm-1 only, as can be shown by reading the Database information: from radis.misc.config import printDatabankEntries printDatabankEntries('HITEMP-CO2-TEST') >>> HITEMP-CO2-TEST >>> ------- >>> info : HITEMP-2010, CO2, 3 main isotope (CO2-626, 636, 628), 2283.7-2285.1 cm-1 >>> path : ['/USER/PATH/TO\\radis\\radis\\test\\files\\cdsd_hitemp_09_fragment.txt'] >>> format : cdsd-hitemp >>> parfuncfmt : hapi >>> levelsfmt : radis See Also -------- :ref:`Configuration file <label_lbl_config_file>`, :py:func:`~radis.misc.config.getDatabankList`, :py:func:`~radis.misc.config.printDatabankEntries` """ # TODO: generate large band databases for the main species (let's say CO2, # H2O and CH4) and main isotopes by fetching the HITRAN 2016 database. # Get list of databases try: dbnames = getDatabankList() except FileNotFoundError: dbnames = [] # %% Add test databases def add_to_parser(config, name, dic): for k, v in dic.items(): config[name][k] = v if verbose: print("Adding '{0}' database in ~/.radis".format(name)) for dbname, dbentries in TEST_DATABASES.items(): if dbname in dbnames: # Check entries are correct # for k diff = diffDatabankEntries(getDatabankEntries(dbname), dbentries, verbose=False) if diff is not None: raise ValueError( "{0}".format(diff) + "\nIn ~/.radis\n----------\n{0}".format( getDatabankEntries(dbname)) + "\n\nExpected\n---------\n{0}\n\n".format(dbentries) + "Test Database {0} doesnt match expected ".format(dbname) + "entries for key `{0}`. See comparison above. ".format( diff) + "To regenerate test databases just delete the {0} ".format( dbname) + "entry in your ~/.radis") else: # add them (create ~/.radis file if doesnt exist yet) addDatabankEntries(dbname, dbentries) return
def setup_test_line_databases(verbose=True): ''' Build :py:data:`~radis.test.utils.TEST_DATABASES` and add them in ~/.radis. Generate the file if it doesnt exist In particular: - HITRAN-CO2-TEST: CO2, HITRAN 2016, 4165-4200 nm - HITRAN-CO-TEST: CO, HITRAN 2016, 2000-2300 cm-1 - HITEMP-CO2-TEST: CO2, HITEMP-2010, 2283.7-2285.1 cm-1, 3 isotopes These test databases are used to run the different test routines. They can obviously be used by Users to run simulations, but we suggest Users to download their own line databases files and add them to ~/.radis so they have more control on it See Also -------- :ref:`Configuration file <label_lbl_config_file>` ''' # TODO: generate large band databases for the main species (let's say CO2, # H2O and CH4) and main isotopes by fetching the HITRAN 2016 database. # Get list of databases try: dbnames = getDatabankList() except FileNotFoundError: dbnames = [] # %% Add test databases def add_to_parser(config, name, dic): for k, v in dic.items(): config[name][k] = v if verbose: print("Adding '{0}' database in ~/.radis".format(name)) for dbname, dbentries in TEST_DATABASES.items(): if dbname in dbnames: # Check entries are correct # for k diff = diffDatabankEntries(getDatabankEntries(dbname), dbentries, verbose=False) if diff is not None: raise ValueError( '{0}'.format(diff) + '\nIn ~/.radis\n----------\n{0}'.format( getDatabankEntries(dbname)) + '\n\nExpected\n---------\n{0}\n\n'.format(dbentries) + 'Test Database {0} doesnt match expected '.format(dbname) + 'entries for key `{0}`. See comparison above. '.format( diff) + 'To regenerate test databases just delete the {0} '.format( dbname) + 'entry in your ~/.radis') else: # add them (create ~/.radis file if doesnt exist yet) addDatabankEntries(dbname, dbentries) return