;*********************************************************** ;rh_to_mxrat.pro converts relative humidity to mixing ratio ; ; INPUT ; rh = relative humidity in % ; temp = temperature in Celcius ; press = pressure in hPa=mb ; ; OUTPUT ; mxrat = mixing ratio in g/kg ;*********************************************************** pro rh_to_mxrat,temp,rh,press,mxrat ; Pressure in mb press_mb=press ;mb ; Temperature in celcius temp_c=temp ;Celcius ; Calculate saturation vapor pressure (es) ; Source: Bolton, D., The computation of equivalent potential temperature, ; Monthly Weather Review, 108, 1046-1053, 1980. equation (10) ; Psat=6.112 * EXP(17.67 * Temp / (Temp+243.5)) ; Temp=Celcius ; Psat=hPa=mb es=6.112*exp((17.67*temp_c)/(temp_c+243.5)) ;mb ; Calculate vapor pressure ; rh=(e/es)*100% where rh is relative humidity ; e is vapor pressure ; es is saturation vapor pressure ; Thus, e=rh*es/100% e=rh*es/100.0 ;mb ; Calculate mixing ratio ; mxrat=(0.622*e)/(p-e) where e is vapor pressure ; p is pressure ; mxrat is mixing ratio mxrat=(0.622*e)/(press_mb-e) ;kg water vapor / kg dry air ; Convert mixing ratio from kg/kg to g/kg mxrat=mxrat*1000.0 return end