relhum
Calculates relative humidity given temperature, mixing ratio, and pressure.
Prototype
function relhum ( t : numeric, w : numeric, p : numeric ) return_val [dimsizes(t)] : numeric
Arguments
tA multi-dimensional array equal to the temperature in K.
wA multi-dimensional array equal to the mixing ratio in kg/kg. Must be the same size as t.
pA multi-dimensional array equal to the pressure in Pa. Must be the same size as t.
Return value
A multi-dimensional array of the same sizes as t. The output will be double if any of the input is double, and float otherwise.
Description
Calculates relative humidity given temperature, mixing ratio, and pressure, using a table look-up procedure. The approximations used can result in values greater than 100%. However, the code will set all these values to 100%. The results at low temperatures and very dry conditions are the most susceptible to this behavior.
The returned values are similar to the results obtained using the algorithm in:
Murray (1967), On the computation of saturation vapor pressure, J. Applied Met., pp 203-204
Examples
Example 1
Wallace and Hobbs (Atmospheric Science: An introductory Survey, Academic Press [p73]) state that at p=1000 [hPa], t=18 [C] and q=6 [g/kg] the relative humidity is approximately 45.6%.
p = 1000.*100. ; hPa ==> Pa t = 18.+273.15 ; C ==> K q = 6./1000. ; g/kg ==> kg/kg rh = relhum (t, q, p) ; rh = 46.4 %Example 2
Consider a sounding with the following values:
begin
p =(/ 1008., \ ; hPA (mb)
1000.,950.,900.,850.,800.,750.,700.,650.,600., \
550.,500.,450.,400.,350.,300.,250.,200., \
175.,150.,125.,100., 80., 70., 60., 50., \
40., 30., 25., 20. /)
t =(/ 29.3, \ ; C
28.1,23.5,20.9,18.4,15.9,13.1,10.1, 6.7, 3.1, \
-0.5,-4.5,-9.0,-14.8,-21.5,-29.7,-40.0,-52.4, \
-59.2,-66.5,-74.1,-78.5,-76.0,-71.6,-66.7,-61.3, \
-56.3,-51.7,-50.7,-47.5 /)
q =(/ 20.38, \ ; KG/KG
19.03,16.14,13.71,11.56,9.80,8.33,6.75,6.06,5.07, \
3.88, 3.29, 2.39, 1.70,1.00,0.60,0.20,0.00,0.00, \
0.00, 0.00, 0.00, 0.00,0.00,0.00,0.00,0.00,0.00, \
0.00, 0.00 /)
tk = t+273.15
pPA = p*100.
tkv = tk*(1.+q*0.61)
rh = relhum(tk, w, pPa)
end
Example 3
Let t, w and p be four-dimensional of size (ntim,nlvl,nlat,nlon). The returned value (rh) will be the same size. Every grid point will use the local pressure values.
rh = relhum (t, w, p)Example 4
Let t and w be four-dimensional of size (ntim,nlvl,nlat,nlon). Let p be a one-dimensional of size (nlvl) in units of Pascals. Use conform to expand p to the same dimensions as t and w. Placing the conform directly into the call to relhum has the advantage that the temporary array created lasts only as long as the function.
rh = relhum (t, w, conform(t,p,1))Example 5
Let t and w be four-dimensional of size (ntim,nlvl,nlat,nlon). Derive p using various model output quantities.
p0 = 1000. ps = a->PS ; 3D (time,lat,lon) variable [sfc pressure] hyam = a->hyam ; needed for interpolation hybm = a->hybm pres = new ( dimsizes(t), typeof(t) ) do n=0,nlvl-1 pres(:,n,:,:) = p0*hyam(n) + hybm(n)*ps end do rh = relhum (t, q, pres) ; rel humidity delete (pres)