def estimate_tau0(T0, atm):
T0_fit = np.array([600,1000])
tau0_fit = np.array([5,0.1])
x = 1000.0/T0_fit
y = 1.0*np.log10(tau0_fit)
coeff_low = np.polyfit(x,y,1)
T0_fit = np.array([1000,1600])
tau0_fit = np.array([0.1,1e-4])
x = 1000.0/T0_fit
y = 1.0*np.log10(tau0_fit)
coeff_high = np.polyfit(x,y,1)
atm_fit = 1.0*np.array([1, 10, 20])
mtp_fit = 1.0*np.array([1, 0.1, 0.02])
x = np.sqrt(atm_fit)
y = np.log10(mtp_fit)
coeff_p = np.polyfit(x,y,1)
if T0 < 1000:
tau_1atm = (10 ** np.polyval(coeff_low, 1000.0/T0))
else:
tau_1atm = (10 ** np.polyval(coeff_high, 1000.0/T0))
mtp = 10 ** np.polyval(coeff_p, np.sqrt(atm))
tau = tau_1atm * mtp
#print 'tau = '+str(tau)
tau_level = 10 ** (np.floor(np.log10(tau)))
#print 'tau_level = '+str(tau_level)
tau_rounded = tau_level * np.round(tau/tau_level * 1.0)/1.0
#print 'tau_rounded = '+str(tau_rounded)
#print tau_level
#print str(tau_rounded)
#print tau_rounded
tau_rounded = max(1e-2, tau_rounded)
return float(str(tau_rounded))
评论列表
文章目录