def rh2mr(p, t, rh, Tconvert=None): """(w1,w2) = rh2mr(p,t,rh,Tconvert) determine H2O mixing ratio (w, g/kg) given reference pressure (mbar), temperature (t,K), and relative humidity (rh,%) Two mixing ratios are returned: w1 is with RH defined as the ratio of water vapor partial pressure to saturation vapor pressure and w2 is with RH defined as the ratio of water vapor mixing ratio to saturation mixing ratio. if input, Tconvert is used as the temperature point to switch from using saturation vapor pressure over water to over ice. DCT 3/5/00 """ # saturation pressure if (Tconvert is None): esat = satvap(t) # Goff Gratch formulation, over water wsat = satmix(p, t) # Goff Gratch formulation, over water else: esat = satvap(t, Tconvert) # Goff Gratch formulation, over water/ice wsat = satmix(p, t, Tconvert) # Goff Gratch formulation, over water/ice # H2O partial pressure e = rh / 100.0 * esat # H2O mixing ratio w1 = e2mr(p, e) # using WMO definition of relative humidity w2 = rh / 100.0 * wsat return (w1, w2)
def rh2mr(p,t,rh,Tconvert=None): """(w1,w2) = rh2mr(p,t,rh,Tconvert) determine H2O mixing ratio (w, g/kg) given reference pressure (mbar), temperature (t,K), and relative humidity (rh,%) Two mixing ratios are returned: w1 is with RH defined as the ratio of water vapor partial pressure to saturation vapor pressure and w2 is with RH defined as the ratio of water vapor mixing ratio to saturation mixing ratio. if input, Tconvert is used as the temperature point to switch from using saturation vapor pressure over water to over ice. DCT 3/5/00 """ # saturation pressure if (Tconvert is None): esat = satvap(t) # Goff Gratch formulation, over water wsat = satmix(p,t) # Goff Gratch formulation, over water else: esat = satvap(t,Tconvert) # Goff Gratch formulation, over water/ice wsat = satmix(p,t,Tconvert) # Goff Gratch formulation, over water/ice # H2O partial pressure e = rh/100.0*esat # H2O mixing ratio w1 = e2mr(p,e) # using WMO definition of relative humidity w2 = rh/100.0*wsat return(w1,w2)
def e2rh(p,t,e,Tconvert=None): """(rh1,rh2) = e2rh(p,t,e,Tconvert) determine relative humidity (e,mbar) given pressure (p,mbar), temperature (t,K), and H2O partial pressure (e,mbar) Two RHs are returned: rh1 is with RH defined as the ratio of water vapor partial pressure to saturation vapor pressure and rh2 is with RH defined as the ratio of water vapor mixing ratio to saturation mixing ratio. if input, Tconvert is used as the temperature point to switch from using saturation vapor pressure over water to over ice. DCT 3/6/00 """ # saturation pressure if ( Tconvert is None ): esat = satvap(t) # Goff Gratch formulation, over water wsat = satmix(p,t) # Goff Gratch formulation, over water else: esat = satvap(t,Tconvert) # Goff Gratch formulation, over water/ice wsat = satmix(p,t,Tconvert) # Goff Gratch formulation, over water/ice # w/ RH defined as ratio of pressures rh1 = 100.0*e/esat # w/ RH defined as a ratio of mass mixing ratios w = e2mr(p,e) rh2 = 100.0*w/wsat return(rh1,rh2)
def e2rh(p, t, e, Tconvert=None): """(rh1,rh2) = e2rh(p,t,e,Tconvert) determine relative humidity (e,mbar) given pressure (p,mbar), temperature (t,K), and H2O partial pressure (e,mbar) Two RHs are returned: rh1 is with RH defined as the ratio of water vapor partial pressure to saturation vapor pressure and rh2 is with RH defined as the ratio of water vapor mixing ratio to saturation mixing ratio. if input, Tconvert is used as the temperature point to switch from using saturation vapor pressure over water to over ice. DCT 3/6/00 """ # saturation pressure if (Tconvert is None): esat = satvap(t) # Goff Gratch formulation, over water wsat = satmix(p, t) # Goff Gratch formulation, over water else: esat = satvap(t, Tconvert) # Goff Gratch formulation, over water/ice wsat = satmix(p, t, Tconvert) # Goff Gratch formulation, over water/ice # w/ RH defined as ratio of pressures rh1 = 100.0 * e / esat # w/ RH defined as a ratio of mass mixing ratios w = e2mr(p, e) rh2 = 100.0 * w / wsat return (rh1, rh2)
def satmix(p,T,Tconvert=None): """wsat = satmix(p,T,Tconvert) compute saturation mixing ratio [g/kg] given reference pressure, p [mbar] and temperature, T [K]. If Tconvert input, the calculation uses the saturation vapor pressure over ice (opposed to over water) for temperatures less than Tconvert [K]. DCT, updated 3/5/00 """ # saturation pressure if (Tconvert is None): esat = satvap(T) else: esat = satvap(T,Tconvert) # saturation mixing ratio wsat = e2mr(p,esat) return wsat
def dp2mr(p, t, dp, Tconvert=None): """w = dp2mr(p,t,dp,Tconvert) compute water vapor mixing ratio (g/kg) given total pressure p (mb), air temperature t (K), and dew point temperature (K). if input, Tconvert is used as the AIR temperature to switch from using saturation vapor pressure over water to over ice. dct 3/5/2000 """ if (Tconvert is not None): e = dp2e(t, dp, Tconvert) else: e = dp2e(t, dp) # water vapor mixing ratio w = e2mr(p, e) return w
def dp2mr(p,t,dp,Tconvert=None): """w = dp2mr(p,t,dp,Tconvert) compute water vapor mixing ratio (g/kg) given total pressure p (mb), air temperature t (K), and dew point temperature (K). if input, Tconvert is used as the AIR temperature to switch from using saturation vapor pressure over water to over ice. dct 3/5/2000 """ if ( Tconvert is not None ): e = dp2e(t,dp,Tconvert) else: e = dp2e(t,dp) # water vapor mixing ratio w = e2mr(p,e) return w
def dp2rh(p, t, dp, Tconvert=None): """(rh1,rh2) = dp2rh(p,t,dp,Tconvert) compute relative humidity (%) given total pressure p (mb), air temperature t (K), and dew point temperature (K). if input, Tconvert is used as the AIR temperature to switch from using saturation vapor pressure over water to over ice. Two relative humidities are returned: rh1 is with RH defined as the ratio of water vapor partial pressure to saturation vapor pressure and rh2 is with RH defined as the ratio of water vapor mixing ratio to saturation mixing ratio. dct 3/6/2000 """ # vapor pressures computed at dew point temperature over water and ice e = eswat_goffgratch(dp) # Goff Gratch formulation, over water # saturation pressure and mixing ratios computed at air temperaure if (Tconvert is None): esat = satvap(t) wsat = satmix(p, t) else: esat = satvap(t, Tconvert) wsat = satmix(p, t, Tconvert) eice = esice_goffgratch(dp) # Goff Gratch formulation, over ice ind = num.where(t <= Tconvert) e[ind] = eice[ind] # over ice for air temperatures <= Tconvert # water vapor mixing ratio w = e2mr(p, e) # corresponding RH (as a ratio of pressures) rh1 = 100.0 * e / esat # WMO definition of RH gives a second mixing ratio and RH rh2 = 100.0 * w / wsat return (rh1, rh2)
from mr2e import mr2e from mr2rh import mr2rh from dp2e import dp2e from dp2rh import dp2rh from dp2mr import dp2mr p = num.array((1000.0, )) t = num.array((260.0, )) e = num.array((1.0, )) print(p[0]) print(t[0]) print(e[0]) Tconvert = 273.15 rh = e2rh(p, t, e, Tconvert) print(rh[0][0]) mr = e2mr(p, e) print(mr[0]) dp = e2dp(e, t, Tconvert) print(dp[0]) mr = rh2mr(p, t, rh[0], Tconvert) print(mr[0][0]) dp = rh2dp(p, t, rh[0], Tconvert) print(dp[0][0]) e = rh2e(p, t, rh[0], Tconvert) print(e[0][0]) dp = mr2dp(p, t, mr[0], Tconvert) print(dp[0]) e = mr2e(p, mr[0]) print(e[0]) rh = mr2rh(p, t, mr[0], Tconvert) print(rh[0][0])
from mr2e import mr2e from mr2rh import mr2rh from dp2e import dp2e from dp2rh import dp2rh from dp2mr import dp2mr p = num.array((1000.0,)) t = num.array((260.0,)) e = num.array((1.0,)) print(p[0]) print(t[0]) print(e[0]) Tconvert = 273.15 rh = e2rh(p,t,e,Tconvert) print(rh[0][0]) mr = e2mr(p,e) print(mr[0]) dp = e2dp(e,t,Tconvert) print(dp[0]) mr = rh2mr(p,t,rh[0],Tconvert) print(mr[0][0]) dp = rh2dp(p,t,rh[0],Tconvert) print(dp[0][0]) e = rh2e(p,t,rh[0],Tconvert) print(e[0][0]) dp = mr2dp(p,t,mr[0],Tconvert) print(dp[0]) e = mr2e(p,mr[0]) print(e[0]) rh = mr2rh(p,t,mr[0],Tconvert) print(rh[0][0])