Changeset 3671 for trunk/UTIL


Ignore:
Timestamp:
Mar 5, 2025, 5:54:17 PM (4 months ago)
Author:
afalco
Message:

corrk: updated scripts to match API of dace and exo_k.
Added missing atoms in exomol species.
AF

Location:
trunk/UTIL/corrk_exo_k
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/UTIL/corrk_exo_k/Exomol_species.dat

    r3605 r3671  
     1K/               39K                      39K__Kurucz-Allard-K             K//39K/Kurucz-Allard-K                          0        1        0
     2Na/              23Na                     23Na__Kurucz-Allard-Na           Na//23Na/Kurucz-Allard-Na                       0        1        0
    13MgH/             24Mg-1H                  24Mg-1H__Yadin                   MgH//24Mg-1H/Yadin                              0        1        0
    24MgH/             24Mg-1H                  24Mg-1H__UGAMOP                  MgH//24Mg-1H/UGAMOP                             0        1        0
  • TabularUnified trunk/UTIL/corrk_exo_k/dace_to_corrk.py

    r3633 r3671  
    33import matplotlib.pyplot as plt
    44import astropy.units as u
     5import astropy.constants as cst
    56import glob
    67from chemistry import isotopologue_to_species, species_name_to_common_isotopologue_name
    78
    89### choose spectral resolution for corrk
    9 R=20000
     10R=10000
    1011wnedges=xk.wavenumber_grid_R(10000/100, 10000/.3, R)
    1112print("Spectral resolution asked: wn=", wnedges.min(), wnedges.max(), ", R =", R)
    1213
    1314### set data paths
    14 dace_path = "datadir/dace/"
     15# dace_path = "datadir/cold/"
     16dace_path = "datadir/hot/"
    1517corrk_dir = "datadir/corrk_data/"
    1618dir_out = corrk_dir+f"/R{R}_from_dace/"
     
    2628
    2729### select (output) molecules and their corresponding (input) isotopologues
     30### set value to 'None' to get common isotopologue
    2831molecules = {
    29     # "CO":  "12C-16O",
    30     # "CO2":  "12C-16O2",
     32    "CO":  "12C-16O",
     33    "CO2":  None,
    3134    # "H2O":  "1H2-16O",
    3235    # # "C2H2":"12C2-1H2",
    3336    # # "C2H4":"12C2-1H4",
    34     "CH4": "12C-1H4",
     37    # "CH4": "12C-1H4",
    3538    # "TiO": "48Ti-16O",
    3639    # "VO": "51V-16O",
     
    6164    tmp_ktab=xk.hires_to_ktable(path=mol_corrk, helios=True, wnedges=wnedges, mol=molecule, order=order) # test conversion from a whole folder to tmp
    6265
    63     tmp_ktab.kdata = tmp_ktab.kdata * 10 * xk.Molar_mass().fetch(molecule) / xk.N_A
     66    tmp_ktab.kdata = tmp_ktab.kdata * 10 * xk.Molar_mass().fetch(molecule) / cst.N_A
    6467    # cm^2/g * 10000/1000 * kg/mol / (molecule/mol) -> m^2/molecule
    6568    tmp_ktab.kdata_unit = "m^2/molecule"
  • TabularUnified trunk/UTIL/corrk_exo_k/download_dace.py

    r3605 r3671  
    11from dace import *
    22
     3# output_dir = "datadir/hot"
     4# temperature_range=[50,3000]
     5# pressure_range=[-8,5]
     6
     7output_dir = "datadir/cold"
    38temperature_range=[50,300]
    4 pressure_range=[1e-8,1e2]
     9pressure_range=[-8,2]
    510
    611### select linelist for each molecule
     
    914
    1015molecules = {
    11 # "C2H2": default_linelist,
    12 # "C2H4": default_linelist,
     16"C2H2": default_linelist,
     17"C2H4": default_linelist,
    1318"CH4":  default_linelist,
     19"CO":   default_linelist,
    1420# "CO2":  default_linelist,
    15 # "CO":   default_linelist,
    1621# "H2O":  default_linelist,
    1722# "H2S":  default_linelist,
     
    3338}
    3439for mol in molecules:
    35     download_molecule(molecule=mol,temperature_range=temperature_range,pressure_range=pressure_range, line_list=molecules[mol], output_dir="datadir/dace")
     40    download_molecule(molecule=mol,temperature_range=temperature_range,pressure_range=pressure_range, line_list=molecules[mol], output_dir=output_dir)
    3641
    3742
  • TabularUnified trunk/UTIL/corrk_exo_k/lmdz_corrk_using_exo_k.py

    r3633 r3671  
    11import exo_k as xk
    22import numpy as np
     3import matplotlib.pyplot as plt
    34
    45### folder with corrk data for each molecule (see 'xsec_to_corrk.py' to convert cross-sections to correlated-k tables)
     
    4243
    4344VI_grid = np.array([ 1670.,  2080.,  2220.,  2450.,  2750.,  2920.,  3200.,  3750., 4000.,  4180.,  4260.,  4460.,  4700.,  5000.,  5400.,  5730., 5930.,  6300.,  6700.,  7700.,  8200.,  8750.,  9250., 35000.])
     45res=f"{len(IR_grid)-1}x{len(VI_grid)-1}"
     46print(res)
    4447
    4548wnedges = np.unique(np.concatenate([IR_grid,VI_grid]))
     
    6265xk.Settings().set_case_sensitive(True)
    6366
    64 kdata = xk.Kdatabase(gases)
    65 for gas in kdata.ktables:
    66     # convert Xtables to Ktables
    67     if type(kdata.ktables[gas]) is xk.Xtable:
    68         kdata.ktables[gas] = xk.Ktable(wnedges=wnedges, xtable=kdata.ktables[gas])
     67### select pressure, temperature, and mixing ratio to plot
     68p=1
     69t=300
     70x=1e-4
     71
     72fig, ax = plt.subplots()
     73kdata = xk.Kdatabase(molecules=None)
     74ktables = []
     75for gas in gases:
     76    try:
     77        ktable = xk.Ktable(mol=gas)
     78    except:
     79        ktable = xk.Ktable(wnedges=wnedges, xtable=xk.Xtable(mol=gas))
     80    ktable.plot_spectrum(ax=ax,p=p,t=t,x=x,g=1,label=gas)
     81    ktable.bin_down(wnedges)
     82    ktables.append(ktable)
     83kdata.add_ktables(*ktables)
    6984
    7085mix_var_gas=kdata.create_mix_ktable5d(vgas_comp=vgas,bg_comp=bg_gas,x_array=x_array)
Note: See TracChangeset for help on using the changeset viewer.