def calcTvDiff(press, thetae0, interpTenv, interpTdEnv): """ Calculates the virtual temperature difference between the thetae0 moist adiabat and a given sounding at some pressure. Parameters - - - - - - press: pressure (Pa) thetae0: equivalent potential temperature of the adiabat (K) interpTenv: interpolator for environmental temperature (deg C) interpTdEnv: interpolator for environmental dew point temperature (deg C) Returns - - - - - - TvDiff: the virtual temperature difference at pressure press between the thetae0 moist adiabat and the given sounding (K). """ c = constants() Tcloud=findTmoist(thetae0,press) wvcloud=wsat(Tcloud,press) Tvcloud=Tcloud*(1. + c.eps*wvcloud) Tenv=interpTenv(press*1.e-2) + c.Tc Tdenv=interpTdEnv(press*1.e-2) + c.Tc wvenv=wsat(Tdenv,press) Tvenv=Tenv*(1. + c.eps*wvenv) return Tvcloud - Tvenv
def calcAdiabat(press0, thetae0, topPress): """ Calculates the temperature-pressure coordinates of a moist adiabat. Parameters - - - - - - press0: the initial pressure (Pa) thetae0: the equivalent potential temperature (K) of the adiabat topPress: the final pressure (Pa) Returns - - - - - - (pressVals, tempVals): pressVals (Pa) and tempVals (K) are 50 x 1 arrays and are the coordinates of the thetae0 adiabat Tests - - - - - >>> p,T = calcAdiabat(800*100, 300, 1000*100) >>> p.shape (50,) >>> T.shape (50,) """ pressVals = np.linspace(press0, topPress, 50) tempVals = np.zeros(pressVals.size) for i in range(pressVals.size): tempVals[i] = findTmoist(thetae0, pressVals[i]) return pressVals, tempVals