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 rh2e(p, t, rh, Tconvert=None): """(e1,e2) = rh2e(p,t,rh,Tconvert) determine H2O partial pressure (e,mbar) given pressure (p,mbar), temperature (t,K), and relative humidity (rh,%) Two H2O partial pressures are returned: e1 is with RH defined as the ratio of water vapor partial pressure to saturation vapor pressure and e2 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 """ # ratio of water mass to dry air mass eps = 0.621970585 # 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 w/ RH defined as ratio of pressures e1 = rh / 100.0 * esat # H2O partial pressure w/ RH defined as ratio of mixing ratios e2 = (rh / 100.0 * esat / (p - esat) * p) / (rh / 100.0 * esat / (p - esat) + 1.0) return (e1, e2)
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 mr2rh(p,t,w,Tconvert=None): """(rh1,rh2) = mr2rh(p,t,w,Tconvert) determine relative humidity (%) given reference pressure (mbar), temperature (t,K), and water vapor mass mixing ratio (w,g/kg) 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/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 = mr2e(p,w) # RH using ratios of gas pressures rh1 = 100.0*e/esat # RH using WMO definition of relative humidity rh2 = 100.0*w/wsat return (rh1,rh2)
def mr2rh(p, t, w, Tconvert=None): """(rh1,rh2) = mr2rh(p,t,w,Tconvert) determine relative humidity (%) given reference pressure (mbar), temperature (t,K), and water vapor mass mixing ratio (w,g/kg) 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/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 = mr2e(p, w) # RH using ratios of gas pressures rh1 = 100.0 * e / esat # RH using WMO definition of relative humidity 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 rh2e(p,t,rh,Tconvert=None): """(e1,e2) = rh2e(p,t,rh,Tconvert) determine H2O partial pressure (e,mbar) given pressure (p,mbar), temperature (t,K), and relative humidity (rh,%) Two H2O partial pressures are returned: e1 is with RH defined as the ratio of water vapor partial pressure to saturation vapor pressure and e2 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 """ # ratio of water mass to dry air mass eps = 0.621970585 # 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 w/ RH defined as ratio of pressures e1 = rh/100.0*esat # H2O partial pressure w/ RH defined as ratio of mixing ratios e2 = (rh/100.0*esat/(p-esat)*p)/(rh/100.0*esat/(p-esat)+1.0); return(e1,e2)
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 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)