- Timestamp:
- Feb 19, 2025, 2:27:45 PM (4 months ago)
- Location:
- trunk/UTIL/corrk_exo_k
- Files:
-
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/corrk_exo_k/bin_corrk.py
r3605 r3633 7 7 R=100 8 8 wnedges=xk.wavenumber_grid_R(10000/100, 10000/.3, R) 9 print(" wnedges range: ", wnedges.min(), wnedges.max())9 print("Spectral resolution asked: wn=", wnedges.min(), wnedges.max(), ", R =", R) 10 10 11 11 ### folder where corrk will be saved … … 66 66 67 67 tmp_ktab=xk.Ktable(mol=mol, remove_zeros=True) 68 print(f"Initial spectral resolution = {tmp_ktab.Nw}") 68 69 69 if logpgrid is None : # use first molecule to set p and t grid70 if logpgrid is None or tgrid is None: # use first molecule to set p and t grid 70 71 logpgrid = tmp_ktab.logpgrid 71 72 tgrid = tmp_ktab.tgrid 72 73 73 print(f"Remapping: {mol}")74 tmp_ktab.remap_logPT(logp_array=logpgrid, t_array=tgrid)75 74 print(f"Binning: {mol}") 76 75 tmp_ktab.bin_down(wnedges) 76 77 if (tmp_ktab.logpgrid != logpgrid).any() or (tmp_ktab.tgrid != tgrid).any(): 78 print("Initial P grid:", tmp_ktab.pgrid) 79 print("Initial T grid:", tmp_ktab.tgrid) 80 print(f"Remapping {mol}") 81 print("New P grid:", np.power(logpgrid,10)) 82 print("New T grid:", tgrid) 83 tmp_ktab.remap_logPT(logp_array=logpgrid, t_array=tgrid) 84 85 print(tmp_ktab) 77 86 print(f"Writing: {mol}") 78 87 tmp_ktab.write_hdf5(dir_out+mol+f"_R{R}.corrk.h5") -
trunk/UTIL/corrk_exo_k/dace_to_corrk.py
r3605 r3633 7 7 8 8 ### choose spectral resolution for corrk 9 R= 5009 R=20000 10 10 wnedges=xk.wavenumber_grid_R(10000/100, 10000/.3, R) 11 print( wnedges.min(), wnedges.max())11 print("Spectral resolution asked: wn=", wnedges.min(), wnedges.max(), ", R =", R) 12 12 13 13 ### set data paths … … 15 15 corrk_dir = "datadir/corrk_data/" 16 16 dir_out = corrk_dir+f"/R{R}_from_dace/" 17 ref=xk.Ktable(filename=corrk_dir + '/R500_from_R15000/CH4_R500.corrk.h5', mol="CH4") 17 18 ### you can set your desired p and t grid here (otherwise, first molecule is used) 19 logpgrid = None 20 tgrid = None 21 # ref=xk.Ktable(filename=corrk_dir + '/R500_from_R15000/CH4_R500.corrk.h5', mol="CH4") 22 # logpgrid = ref.logpgrid 23 # tgrid = ref.tgrid 24 25 18 26 19 27 ### select (output) molecules and their corresponding (input) isotopologues 20 28 molecules = { 21 "CO": "12C-16O", 22 "C2H2":"12C2-1H2", 23 "C2H4":"12C2-1H4", 29 # "CO": "12C-16O", 30 # "CO2": "12C-16O2", 31 # "H2O": "1H2-16O", 32 # # "C2H2":"12C2-1H2", 33 # # "C2H4":"12C2-1H4", 24 34 "CH4": "12C-1H4", 35 # "TiO": "48Ti-16O", 36 # "VO": "51V-16O", 25 37 } 26 38 27 xk.Settings().set_mks(True)39 # xk.Settings().set_mks(True) 28 40 xk.Settings().set_log_interp(False) 29 41 xk.Settings().set_case_sensitive(True) 30 42 31 def dace_to_corrk(molecule=None, isotopologue=None, order=17 ):43 def dace_to_corrk(molecule=None, isotopologue=None, order=17, logpgrid=logpgrid, tgrid=tgrid): 32 44 if molecule is None: 33 45 molecule=isotopologue_to_species(isotopologue) … … 43 55 return 44 56 45 tmp=xk.hires_to_ktable(path=mol_corrk, helios=True, wnedges=wnedges, mol=molecule, order=order) # test conversion from a whole folder to tmp 57 print(f"Reading: {mol}") 58 hr = xk.Hires_spectrum(glob.glob(mol_corrk+"/*.bin")[0], helios=True) 59 print(f"Initial spectral resolution = {hr.Nw}") 46 60 47 tmp.kdata = tmp.kdata * 10 * xk.Molar_mass().fetch(molecule) / xk.N_A 61 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 62 63 tmp_ktab.kdata = tmp_ktab.kdata * 10 * xk.Molar_mass().fetch(molecule) / xk.N_A 48 64 # cm^2/g * 10000/1000 * kg/mol / (molecule/mol) -> m^2/molecule 49 tmp.kdata_unit = "m^2/molecule" 50 tmp.remap_logPT(ref.logpgrid, ref.tgrid) 51 tmp.remove_zeros() 65 tmp_ktab.kdata_unit = "m^2/molecule" 66 tmp_ktab.remove_zeros() 52 67 53 print(tmp) 54 tmp.write_hdf5(dir_out+f"{molecule}_corrk_dace_{R}.h5") 68 69 if logpgrid is None or tgrid is None: # use first molecule to set p and t grid 70 logpgrid = tmp_ktab.logpgrid 71 tgrid = tmp_ktab.tgrid 72 73 if (tmp_ktab.logpgrid != logpgrid).any() or (tmp_ktab.tgrid != tgrid).any(): 74 print("Initial P grid:", tmp_ktab.pgrid) 75 print("Initial T grid:", tmp_ktab.tgrid) 76 print(f"Remapping {mol}") 77 print("New P grid:", np.power(logpgrid,10)) 78 print("New T grid:", tgrid) 79 tmp_ktab.remap_logPT(logp_array=logpgrid, t_array=tgrid) 80 81 print(tmp_ktab) 82 print(f"Writing: {mol}") 83 tmp_ktab.write_hdf5(dir_out+f"{molecule}_corrk_dace_{R}.h5") 55 84 56 85 # %matplotlib notebook … … 58 87 t_plot=300 59 88 fig,ax=plt.subplots(figsize=(9,6.5)) 60 tmp .plot_spectrum(ax,p=p_plot,t=t_plot,g=1.,yscale='log',xscale='log',label='g=1')89 tmp_ktab.plot_spectrum(ax,p=p_plot,t=t_plot,g=1.,yscale='log',xscale='log',label='g=1') 61 90 fig.tight_layout() 62 91 plt.savefig(dir_out+f"corrk_dace_R{R}_{molecule}_p{p_plot}_t{t_plot}.pdf") -
trunk/UTIL/corrk_exo_k/lmdz_corrk_using_exo_k.py
r3632 r3633 4 4 ### folder with corrk data for each molecule (see 'xsec_to_corrk.py' to convert cross-sections to correlated-k tables) 5 5 xk.Settings().set_search_path("datadir/exomol/taurex_R15000/") 6 # xk.Settings().set_search_path("datadir/corrk_data/R20000_from_dace/") 6 7 7 8 corrk_dir = "datadir/corrk_data/" -
trunk/UTIL/corrk_exo_k/xsec_to_corrk.py
r3605 r3633 7 7 R=500 8 8 wnedges=xk.wavenumber_grid_R(10000/100, 10000/.3, R) 9 print(" wnedges range: ", wnedges.min(), wnedges.max())9 print("Spectral resolution asked: wn=", wnedges.min(), wnedges.max(), ", R =", R) 10 10 11 11 ### folder where corrk will be saved … … 63 63 print(f"Reading: {mol}") 64 64 65 tmp_ktab=xk.Ktable(wnedges=wnedges, xtable=xk.Xtable(pattern, mol=mol, remove_zeros=True)) 65 xtable=xk.Xtable(pattern, mol=mol, remove_zeros=True) 66 print(f"Initial spectral resolution = {xtable.Nw}") 66 67 67 if logpgrid is None: # use first molecule to set p and t grid 68 tmp_ktab=xk.Ktable(wnedges=wnedges, xtable=xtable) 69 70 # print(f"Binning: {mol}") 71 # tmp_ktab.bin_down(wnedges) 72 73 74 if logpgrid is None or tgrid is None: # use first molecule to set p and t grid 68 75 logpgrid = tmp_ktab.logpgrid 69 76 tgrid = tmp_ktab.tgrid 70 77 71 print(f"Remapping: {mol}") 72 tmp_ktab.remap_logPT(logp_array=logpgrid, t_array=tgrid) 78 if (tmp_ktab.logpgrid != logpgrid).any() or (tmp_ktab.tgrid != tgrid).any(): 79 print("Initial P grid:", tmp_ktab.pgrid) 80 print("Initial T grid:", tmp_ktab.tgrid) 81 print(f"Remapping {mol}") 82 print("New P grid:", np.power(logpgrid,10)) 83 print("New T grid:", tgrid) 84 tmp_ktab.remap_logPT(logp_array=logpgrid, t_array=tgrid) 85 86 print(tmp_ktab) 73 87 print(f"Writing: {mol}") 74 88 tmp_ktab.write_hdf5(dir_out+mol+f"_R{R}.corrk.h5")
Note: See TracChangeset
for help on using the changeset viewer.