dj = alpha * Lok lamb = 1.5988 / (1.5988 + n_dens * (n2vmr * zn2 + o2vmr * zo2 + ovmr * zo)) MM = (n2vmr * 28 + o2vmr * 32 + ovmr * 16) / (n2vmr + o2vmr + ovmr ) # Molecular mass ## Boundary condition #eps125 = all_coeffs_nlte[(atm, cco2, 'hr_nlte')][n_alts_trlo] tip = 'varfit5_nlte' acoeff_cco2 = tot_coeff_co2[(tip, 'acoeff', cco2)] bcoeff_cco2 = tot_coeff_co2[(tip, 'bcoeff', cco2)] asurf_cco2 = tot_coeff_co2[(tip, 'asurf', cco2)] bsurf_cco2 = tot_coeff_co2[(tip, 'bsurf', cco2)] hr_calc = npl.hr_from_ab(acoeff_cco2, bcoeff_cco2, asurf_cco2, bsurf_cco2, temp, surf_temp) eps125 = hr_calc[n_alts_trlo - 1] cose_upper_atm[(atm, cco2, 'L_esc')] = Lok #cose_upper_atm[(atm, cco2, 'L_esc_int2')] = Lok_int2 # finest integration grid cose_upper_atm[( atm, cco2, 'L_esc_wutop')] = Lok_wutop # adding a utop equal to the last uok cose_upper_atm[( atm, cco2, 'L_esc_all_wutop' )] = Lok_all_wutop # adding a utop equal to the last uok cose_upper_atm[( atm, cco2, 'L_esc_all' )] = Lok_all # using the mean of the escape functions for all atmospheres cose_upper_atm[(atm, cco2,
print('Coeffs from interpolation!') calc_coeffs = dict() for nam in ['acoeff', 'bcoeff', 'asurf', 'bsurf', 'alpha']: int_fun = interp_coeffs[(nam, 'int_fun')] sc = interp_coeffs[(nam, 'signc')] coeff = npl.coeff_from_interp(int_fun, sc, co2vmr) calc_coeffs[nam] = coeff if np.max(np.abs( (coeff - coeffs_NLTE[nam][cco2 - 1, ...]) / coeff)) > 1.e-10: print('AAAAAAAAAAAAAAAAAAAAAAARGH', nam) print(coeff, coeffs_NLTE[nam][cco2 - 1, ...]) hr_calc = npl.hr_from_ab(calc_coeffs['acoeff'], calc_coeffs['bcoeff'], calc_coeffs['asurf'], calc_coeffs['bsurf'], temp, surf_temp) #alpha_ = 10.*np.ones(n_alts_trhi-n_alts_trlo+1) hr_calc = npl.recformula(calc_coeffs['alpha'], L_esc, lamb, hr_calc, co2vmr, MM, temp, n_alts_trlo=n_alts_trlo, n_alts_trhi=n_top) hr_ref = all_coeffs_nlte[(atm, cco2, 'hr_nlte')] hr_ref[:n_alts_lte] = all_coeffs_nlte[(atm, cco2, 'hr_lte')][:n_alts_lte]
temp = atm_pt[(atm, 'temp')] surf_temp = atm_pt[(atm, 'surf_temp')] coeffs = dict() for conam in ['acoeff', 'bcoeff', 'asurf', 'bsurf']: if 'surf' in conam: coeffs[conam] = regrcoef[(conam, 'c')] + regrcoef[(conam, 'm')] * sa else: coeffs[conam] = regrcoef[(conam, 'c')] + regrcoef[(conam, 'm')] * dp hr_new = npl.hr_from_ab(coeffs['acoeff'], coeffs['bcoeff'], coeffs['asurf'], coeffs['bsurf'], temp, surf_temp, max_alts=51) tip = 'varfit5_nlte' acoeff = tot_coeff_co2[(tip, 'acoeff', cco2)] bcoeff = tot_coeff_co2[(tip, 'bcoeff', cco2)] asurf = tot_coeff_co2[(tip, 'asurf', cco2)] bsurf = tot_coeff_co2[(tip, 'bsurf', cco2)] hr_vf5 = npl.hr_from_ab(acoeff, bcoeff, asurf, bsurf, temp,
figs = [] figs2 = [] a0s = [] a1s = [] for cco2 in range(1, 8): fig2, ax2 = plt.subplots() for atm, col in zip(allatms, npl.color_set(6)): temp = atm_pt[(atm, 'temp')] surf_temp = atm_pt[(atm, 'surf_temp')] acoeff, bcoeff, asurf, bsurf = npl.coeffs_from_eofreg( cco2, temp, surf_temp, method='1eof', regrcoef=regrcoef) hr_new = npl.hr_from_ab(acoeff, bcoeff, asurf, bsurf, temp, surf_temp, max_alts=66) hra, hrb = npl.hr_from_ab_decomposed(acoeff, bcoeff, asurf, bsurf, temp, surf_temp, max_alts=66) hr_nlte_corr = nlte_corr[(cco2, 'c')] + nlte_corr[ (cco2, 'm1')] * hra[alt1:alt2] + nlte_corr[ (cco2, 'm2')] * hrb[alt1:alt2] hr_new[alt1:alt2] = hr_new[alt1:alt2] + hr_nlte_corr
# i coeff specifici per ogni cco2: acoeff_cco2 = tot_coeff_co2[(tip, 'acoeff', cco2)] bcoeff_cco2 = tot_coeff_co2[(tip, 'bcoeff', cco2)] asurf_cco2 = tot_coeff_co2[(tip, 'asurf', cco2)] bsurf_cco2 = tot_coeff_co2[(tip, 'bsurf', cco2)] for atm in allatms: temp = atm_pt[(atm, 'temp')] surf_temp = atm_pt[(atm, 'surf_temp')] tit = 'co2: {} - atm: {}'.format(cco2, atm) xlab = 'CR (K/day)' ylab = 'Alt (km)' hr_ref = all_coeffs[(atm, cco2, 'hr_ref')][:n_alts] hr_calc_step5 = npl.hr_from_ab(acoeff, bcoeff, asurf, bsurf, temp, surf_temp)[:n_alts] hr_calc_step4 = npl.hr_from_ab(acoeff_cco2, bcoeff_cco2, asurf_cco2, bsurf_cco2, temp, surf_temp)[:n_alts] hrs = [hr_ref, hr_calc_step4, hr_calc_step5] labels = ['ref', 'step 4', 'step 5'] fig, a0, a1 = npl.manuel_plot(alts, hrs, labels, xlabel=xlab, ylabel=ylab, title=tit, xlimdiff=(-2.5, 2.5)) figs.append(fig)
for conam in ['acoeff', 'bcoeff', 'asurf', 'bsurf']: if 'surf' in conam: coeffs[conam] = regrcoef[(cco2, conam, 'c')] + regrcoef[ (cco2, conam, 'm')] * sa else: coeffs[conam] = regrcoef[(cco2, conam, 'c')] + regrcoef[ (cco2, conam, 'm')] * dp coeffs[(conam, 'v2')] = regrcoef[(cco2, conam, 'c1')] + regrcoef[ (cco2, conam, 'm1')] * dp + regrcoef[ (cco2, conam, 'm2')] * dp1 hr_new = npl.hr_from_ab(coeffs['acoeff'], coeffs['bcoeff'], coeffs['asurf'], coeffs['bsurf'], temp, surf_temp, max_alts=66) hr_new_v2 = npl.hr_from_ab(coeffs[('acoeff', 'v2')], coeffs[('bcoeff', 'v2')], coeffs['asurf'], coeffs['bsurf'], temp, surf_temp, max_alts=66) tip = 'varfit5' acoeff = tot_coeff_co2[(tip, 'acoeff', cco2)] bcoeff = tot_coeff_co2[(tip, 'bcoeff', cco2)] asurf = tot_coeff_co2[(tip, 'asurf', cco2)]