def thetal(press, Temp, rt): """ input: press in kPa (1d vector or scalar) temp in K (1d vector or scalar mixing ratio in kg/kg (1d vector or scalar) # emanuel p. 121 4.5.15 """ isscalar = test_scalar(press, Temp, rt) press = np.atleast_1d(press) Temp = np.atleast_1d(Temp) rt = np.atleast_1d(rt) rl = np.empty_like(rt) rsat = rs_tp(Temp, press) CPn = tc.RD + rt * tc.RV chi = CPn / (tc.CPD + rt * tc.CPV) gamma = (rt * tc.RV) / CPn saturated = rt > rsat rl[saturated] = rt[saturated] - rsat[saturated] unsaturated = np.logical_not(saturated) rl[unsaturated] = 0 LV = L_t(Temp) theta = Temp * (tc.P0 / press)**chi term1 = (1. - rl / (tc.EPS + rt))**chi term2 = (1 - rl / rt)**(-gamma) term3 = -LV * rl / (CPn * Temp) term3 = np.exp(term3) theThetal = theta * term1 * term2 * term3 if isscalar: theThetal = theThetal[0] return theThetal
def tro_trtp(t, rt, pressKpa): """in: t=temperature (K),pressKpa= pressure (kPa) rt=mixing ratio (kg/kg) out:tro=density temperature (K) (vector) """ isscalar = test_scalar(t, rt, pressKpa) if not isscalar: t = np.atleast_1d(t) rt = np.atleast_1d(rt) rv = np.empty_like(rt) pressKpa = np.atleast_1d(pressKpa) rs = rs_tp(t, pressKpa) out = np.empty(rs.shape, dtype=np.float) saturated = (rt >= rs) unsaturated = np.logical_not(saturated) rl = np.zeros(out.shape, dtype=np.float) rl[saturated] = rt[saturated] - rs[saturated] rl[unsaturated] = 0 rv[saturated] = rs[saturated] rv[unsaturated] = rt[unsaturated] out[saturated] = t[saturated] * (1. + 0.611 * rs[saturated] - rl[saturated]) out[unsaturated] = t[unsaturated] * (1. + 0.611 * rt[unsaturated]) out = t * (1 + rv / tc.EPS) / (1. + rt) if isscalar: out = out[0] return out
def tro_trtp(t,rt,pressKpa): """in: t=temperature (K),pressKpa= pressure (kPa) rt=mixing ratio (kg/kg) out:tro=density temperature (K) (vector) """ isscalar = test_scalar(t,rt,pressKpa) if not isscalar: t=np.atleast_1d(t) rt=np.atleast_1d(rt) rv=np.empty_like(rt) pressKpa=np.atleast_1d(pressKpa) rs=rs_tp(t,pressKpa) out=np.empty(rs.shape,dtype=np.float) saturated = (rt>=rs) unsaturated=np.logical_not(saturated) rl=np.zeros(out.shape,dtype=np.float) rl[saturated]=rt[saturated] - rs[saturated] rl[unsaturated]=0 rv[saturated]=rs[saturated] rv[unsaturated]=rt[unsaturated] out[saturated]=t[saturated]*(1.+0.611*rs[saturated]-rl[saturated]) out[unsaturated]=t[unsaturated]*(1.+ 0.611*rt[unsaturated]) out=t*(1 + rv/tc.EPS)/(1. + rt) if isscalar: out=out[0] return out
def thetal(press,Temp,rt): """ input: press in kPa (1d vector or scalar) temp in K (1d vector or scalar mixing ratio in kg/kg (1d vector or scalar) # emanuel p. 121 4.5.15 """ isscalar = test_scalar(press,Temp,rt) press=np.atleast_1d(press) Temp=np.atleast_1d(Temp) rt = np.atleast_1d(rt) rl=np.empty_like(rt) rsat=rs_tp(Temp,press) CPn=tc.RD + rt*tc.RV chi=CPn/(tc.CPD + rt*tc.CPV) gamma=(rt*tc.RV)/CPn saturated=rt > rsat rl[saturated]=rt[saturated] - rsat[saturated] unsaturated=np.logical_not(saturated) rl[unsaturated]=0 LV=L_t(Temp) theta=Temp*(tc.P0/press)**chi term1=(1. - rl/(tc.EPS + rt))**chi term2=(1 - rl/rt)**(-gamma) term3= -LV*rl/(CPn*Temp) term3=np.exp(term3) theThetal=theta*term1*term2*term3 if isscalar: theThetal = theThetal[0] return theThetal
def alt_thetal(press, Temp, qt): """ quicker approximate version of thetal input: press in kPa (1d vector or scalar) temp in K (1d vector or scalar mixing ratio in kg/kg (1d vector or scalar) """ isscalar = test_scalar(press, Temp, qt) press = np.atleast_1d(press) Temp = np.atleast_1d(Temp) qt = np.atleast_1d(qt) ql = np.empty_like(qt) qsat = qs_tp(Temp, press) ql = qt - qsat ql[ql < 0] = 0.0 theta = Temp * (100.0 / press) ** 0.288 L = 2.5e6 cpd = 1004.0 the_thetal = theta - (theta / Temp) * (L / cpd) * ql if isscalar: the_thetal = the_thetal[0] return the_thetal