<p>Here is an implementation that I wrote in R (with documentation in the header). In addition to laboriously working through a few textbooks and online references, I have compared the results to a <a href="https://www.google.com/#q=psychrometric+chart">psychrometric chart</a>. </p>

<p>As you have likely noticed, it is a challenge to keep these terms and units straight - I wish I had @casey`s answer then! </p>

<pre><code>##' Convert specific humidity to relative humidity
##'
##' converting specific humidity into relative humidity
##' NCEP surface flux data does not have RH
##' from Bolton 1980 The computation of Equivalent Potential Temperature 
##' \url{http://www.eol.ucar.edu/projects/ceop/dm/documents/refdata_report/eqns.html}
##' @title qair2rh
##' @param qair specific humidity, dimensionless (e.g. kg/kg) ratio of water mass / total air mass
##' @param temp degrees C
##' @param press pressure in mb
##' @return rh relative humidity, ratio of actual water mixing ratio to saturation mixing ratio
##' @export
##' @author David LeBauer
qair2rh &lt;- function(qair, temp, press = 1013.25){
    es &lt;-  6.112 * exp((17.67 * temp)/(temp + 243.5))
    e &lt;- qair * press / (0.378 * qair + 0.622)
    rh &lt;- e / es
    rh[rh &gt; 1] &lt;- 1
    rh[rh &lt; 0] &lt;- 0
    return(rh)
}
</code></pre>

<p>Similar variable conversion functions can be found in the <a href="https://github.com/PecanProject/pecan/blob/master/modules/data.atmosphere/R/metutils.R"><code>metutils.R</code></a> file in the PEcAn data.atmosphere library. </p>

CC BY-SA 3.0
2016-08-16T12:36:18.050Z
is this formula the same as the one by @casey? Because I get slightly different results.
Herman Toothrot
CC BY-SA 3.0
2016-08-16T19:07:24.403Z
@user4050 rounding error: coefficient here is 6.112 vs 6.11 above
David LeBauer
CC BY-SA 3.0
2016-08-18T15:45:11.637Z
Thanks! And how exactly did you get e from 6.112*exp((17.67*Td)/(Td + 243.5)) that it's in the page you linked?
Herman Toothrot
CC BY-SA 3.0
2016-08-21T05:21:02.170Z
@user4050 I didn't; e = qair * press / (0.378 * qair + 0.622)
David LeBauer
CC BY-SA 3.0
2014-08-19T14:57:38.447Z
2014-08-19T14:57:38.447Z
David LeBauer
<p>I can't do, or won't do the math, but here is how I get around it. 
Look up the saturation line at the temperature and pressure that I am concerned with on pseudo-adiabatic diagram. Then multiply the relative humidity times  the saturation rate at that temperature. It's not precise, since there are many factors that vary, and you are approximating from a paper chart, but it's a good enough estimate for my work. Hope this is helpful for those of us at the simple end of the concept. </p>

CC BY-SA 3.0
2016-01-26T15:09:16.603Z
2016-01-26T15:09:16.603Z
PluvAl
<p>Relative humidity is just <span class="math-container">$e/e_s$</span>, the ratio of the vapor pressure to saturation vapor pressure or <span class="math-container">$w/w_s$</span>, the ratio of mass mixing ratios of water vapor at actual and saturation values.  If you have specific humidity, which is the mass mixing ratio of water vapor in air, defined as:</p>
<p><span class="math-container">$$ q \equiv \dfrac{m_v}{m_v + m_d} = \dfrac{w}{w+1} \approx w$$</span></p>
<p>Relative humidity can be expressed as the ratio of water vapor mixing ratio to saturation water vapor mixing ratio, <span class="math-container">$w/w_s$</span>, where:</p>
<p><span class="math-container">$$ w_s \equiv \dfrac{m_{vs}}{m_d} = \dfrac{e_s R_d}{R_v(p-e_s)} \approx 0.622\dfrac{e_s}{p}$$</span></p>
<p>and from Clausius-Clapeyron:</p>
<p><span class="math-container">$$ e_s(T) = e_{s0}\exp\left[\left(\dfrac{L_v(T)}{R_v}\right)\left(\dfrac{1}{T_0} -\dfrac{1}{T} \right)\right] \approx 611\exp\left(\dfrac{17.67(T-T_0)}{T-29.65}\right)$$</span></p>
<p>Once you have calculated <span class="math-container">$w$</span> and <span class="math-container">$w_s$</span> you can obtain the relative humidity as:</p>
<p><span class="math-container">$$ RH = 100\dfrac{w}{w_s} \approx 0.263pq\left[\exp\left(\dfrac{17.67(T-T_0)}{T-29.65}\right)\right]^{-1} $$</span></p>
<p>You could also calculate <span class="math-container">$RH = 100(e/e_s)$</span>, but I think since you are starting with <span class="math-container">$q$</span> it isn't as straightforward as doing it this way.</p>
<hr />
<p>Variables used:<br />
<sub>
<span class="math-container">$q$</span> specific humidity or the mass mixing ratio of water vapor to total air (dimensionless)<br />
<span class="math-container">$m_v$</span> specific mass of water vapor (kg)<br />
<span class="math-container">$m_{vs}$</span> specific mass of water vapor at equilibrium (kg)<br />
<span class="math-container">$m_d$</span> specific mass of dry air (kg)<br />
<span class="math-container">$w$</span> mass mixing ratio of water vapor to dry air (dimensionless)<br />
<span class="math-container">$w_s$</span> mass mixing ratio of water vapor to dry air at equilibrium (dimensionless)<br />
<span class="math-container">$e_s(T)$</span> saturation vapor pressure (Pa)<br />
<span class="math-container">$e_{s0}$</span> saturation vapor pressure at <span class="math-container">$T_0$</span> (Pa)<br />
<span class="math-container">$R_d$</span> specific gas constant for dry air (J kg<span class="math-container">$^{-1}$</span> K<span class="math-container">$^{-1}$</span>)<br />
<span class="math-container">$R_v$</span> specific gas constant for water vapor (J kg<span class="math-container">$^{-1}$</span> K<span class="math-container">$^{-1}$</span>)<br />
<span class="math-container">$p$</span> pressure (Pa)<br />
<span class="math-container">$L_v(T)$</span> specific enthalpy of vaporization (J kg<span class="math-container">$^{-1}$</span>)<br />
<span class="math-container">$T$</span> temperature (K)<br />
<span class="math-container">$T_0$</span> reference temperature (typically 273.16 K) (K)<br />
</sub></p>

CC BY-SA 3.0
2015-12-03T14:31:52.273Z
@stacey the 611 value in the equation is in units of Pascals, if you are using 6.11 then you are using hPa or mbar units.  Either is correct but you need to be aware of units.  611 Pa = 6.11 hPa = 6.11 mbar.  Likewise in the second equation you are giving `p` in hPa if you are off by a factor of 100.  I specified in the post that `p` was in `Pa`, so if you use hPa you need to adjust by factor of 100.
casey
CC BY-SA 3.0
2015-12-03T15:21:52.803Z
@stacey do dimensional analysis on the units in the equation noting that 611 is Pa and 6.11 is hPa and then you'll see the scaling factor of 100 is just a Pa to hPa conversion factor, not some arbitrary number.  Note that the exponential is dimensionless so the units of $e_s(T)$ are the units of $e_{s0}$.  If you want $e_s(T)$ in hPa, use $e_{s0} $ = 6.11 hPa.
casey
CC BY-SA 3.0
2015-12-03T15:29:51.147Z
Also note in the second equation the units of 0.263 is Pa$^{-1}$, so if you are putting in `p` in units of hPa you end up with a value of RH in units of "hPa Pa$^{-1}$" which shows you why you end up 100 times off.  Lastly, if you are still having problems with this, join chat and we can continue this discussion there.
casey
CC BY-SA 3.0
2015-12-03T15:31:16.663Z
Comments are not for extended discussion; this conversation has been [moved to chat](http://chat.stackexchange.com/rooms/32459/discussion-on-answer-by-casey-how-do-i-convert-specific-humidity-to-relative-hum).
casey
CC BY-SA 3.0
2016-08-16T10:46:05.020Z
@casey where do you get the 0.263pq?
Herman Toothrot
CC BY-SA 3.0
2016-08-16T11:26:25.350Z
@user4050 it's a result of substituting the approximations for w and ws in the final equation. You end up with 100(1/(.622*611)) as constant factors after the substitution which is just 0.263. The p and q are likewise from the approximations substitutions.
casey
CC BY-SA 3.0
2016-08-16T12:37:19.410Z
@casey, thanks, that makes more sense. However the two formulas here give me slightly different results. Is there one which is more accurate?
Herman Toothrot
CC BY-SA 3.0
2016-08-16T13:43:28.643Z
@user4050 as soon as you venture past the approximation sign $\approx$ you lose accuracy.  Most accurate would be to determine $w$ and $w_s$ exactly and calculate the left hand side.  The right hand side is less accurate since it uses approximations but can be easier to use because it is in terms of temperature, pressure and specific humidity rather than mass mixing ratios of air and water vapor.
casey
CC BY-SA 4.0
2014-08-12T04:43:07.833Z
2021-12-15T21:34:10.133Z
2021-12-15T21:34:10.133Z
casey
<p>How do I convert specific humidity to relative humidity? What variables are needed (e.g. air temperature, pressure, etc.)?</p>

<meteorology><humidity>
How do I convert specific humidity to relative humidity?
naught101
# How do I convert specific humidity to relative humidity?

(Asked by: username_0 on 2014-08-12)

How do I convert specific humidity to relative humidity? What variables are needed (e.g. air temperature, pressure, etc.)?

**Tags:** meteorology, humidity


---

## 3 answers

### Answer by username_4 on 2014-08-12. Score: 30 | Accepted answer

Relative humidity is just $e/e\_s$, the ratio of the vapor pressure to saturation vapor pressure or $w/w\_s$, the ratio of mass mixing ratios of water vapor at actual and saturation values. If you have specific humidity, which is the mass mixing ratio of water vapor in air, defined as:

$$ q \equiv \dfrac{m\_v}{m\_v + m\_d} = \dfrac{w}{w+1} \approx w$$

Relative humidity can be expressed as the ratio of water vapor mixing ratio to saturation water vapor mixing ratio, $w/w\_s$, where:

$$ w\_s \equiv \dfrac{m\_{vs}}{m\_d} = \dfrac{e\_s R\_d}{R\_v(p-e\_s)} \approx 0.622\dfrac{e\_s}{p}$$

and from Clausius-Clapeyron:

$$ e\_s(T) = e\_{s0}\exp\left[\left(\dfrac{L\_v(T)}{R\_v}\right)\left(\dfrac{1}{T\_0} -\dfrac{1}{T} \right)\right] \approx 611\exp\left(\dfrac{17.67(T-T\_0)}{T-29.65}\right)$$

Once you have calculated $w$ and $w\_s$ you can obtain the relative humidity as:

$$ RH = 100\dfrac{w}{w\_s} \approx 0.263pq\left[\exp\left(\dfrac{17.67(T-T\_0)}{T-29.65}\right)\right]^{-1} $$

You could also calculate $RH = 100(e/e\_s)$, but I think since you are starting with $q$ it isn't as straightforward as doing it this way.

---

Variables used:  
$q$ specific humidity or the mass mixing ratio of water vapor to total air (dimensionless)  
$m\_v$ specific mass of water vapor (kg)  
$m\_{vs}$ specific mass of water vapor at equilibrium (kg)  
$m\_d$ specific mass of dry air (kg)  
$w$ mass mixing ratio of water vapor to dry air (dimensionless)  
$w\_s$ mass mixing ratio of water vapor to dry air at equilibrium (dimensionless)  
$e\_s(T)$ saturation vapor pressure (Pa)  
$e\_{s0}$ saturation vapor pressure at $T\_0$ (Pa)  
$R\_d$ specific gas constant for dry air (J kg$^{-1}$ K$^{-1}$)  
$R\_v$ specific gas constant for water vapor (J kg$^{-1}$ K$^{-1}$)  
$p$ pressure (Pa)  
$L\_v(T)$ specific enthalpy of vaporization (J kg$^{-1}$)  
$T$ temperature (K)  
$T\_0$ reference temperature (typically 273.16 K) (K)

> **Comments:**
> **username_4**: @stacey the 611 value in the equation is in units of Pascals, if you are using 6.11 then you are using hPa or mbar units.  Either is correct but you need to be aware of units.  611 Pa = 6.11 hPa = 6.11 mbar.  Likewise in the second equation you are giving `p` in hPa if you are off by a factor of 100.  I specified in the post that `p` was in `Pa`, so if you use hPa you need to adjust by factor of 100.  
> **username_4**: @stacey do dimensional analysis on the units in the equation noting that 611 is Pa and 6.11 is hPa and then you'll see the scaling factor of 100 is just a Pa to hPa conversion factor, not some arbitrary number.  Note that the exponential is dimensionless so the units of $e_s(T)$ are the units of $e_{s0}$.  If you want $e_s(T)$ in hPa, use $e_{s0} $ = 6.11 hPa.  
> **username_4**: Also note in the second equation the units of 0.263 is Pa$^{-1}$, so if you are putting in `p` in units of hPa you end up with a value of RH in units of "hPa Pa$^{-1}$" which shows you why you end up 100 times off.  Lastly, if you are still having problems with this, join chat and we can continue this discussion there.  
> **username_4**: Comments are not for extended discussion; this conversation has been [moved to chat](http://chat.stackexchange.com/rooms/32459/discussion-on-answer-by-username_4-how-do-i-convert-specific-humidity-to-relative-hum).  
> **username_2**: @username_4 where do you get the 0.263pq?  
> **username_4**: @user4050 it's a result of substituting the approximations for w and ws in the final equation. You end up with 100(1/(.622*611)) as constant factors after the substitution which is just 0.263. The p and q are likewise from the approximations substitutions.  
> **username_2**: @username_4, thanks, that makes more sense. However the two formulas here give me slightly different results. Is there one which is more accurate?  
> **username_4**: @user4050 as soon as you venture past the approximation sign $\approx$ you lose accuracy.  Most accurate would be to determine $w$ and $w_s$ exactly and calculate the left hand side.  The right hand side is less accurate since it uses approximations but can be easier to use because it is in terms of temperature, pressure and specific humidity rather than mass mixing ratios of air and water vapor.  

---

### Answer by username_1 on 2014-08-19. Score: 19

Here is an implementation that I wrote in R (with documentation in the header). In addition to laboriously working through a few textbooks and online references, I have compared the results to a [psychrometric chart](https://www.google.com/#q=psychrometric+chart).

As you have likely noticed, it is a challenge to keep these terms and units straight - I wish I had @username_4`s answer then!

```
##' Convert specific humidity to relative humidity
##'
##' converting specific humidity into relative humidity
##' NCEP surface flux data does not have RH
##' from Bolton 1980 The computation of Equivalent Potential Temperature 
##' \url{http://www.eol.ucar.edu/projects/ceop/dm/documents/refdata_report/eqns.html}
##' @title qair2rh
##' @param qair specific humidity, dimensionless (e.g. kg/kg) ratio of water mass / total air mass
##' @param temp degrees C
##' @param press pressure in mb
##' @return rh relative humidity, ratio of actual water mixing ratio to saturation mixing ratio
##' @export
##' @author username_1 username_1
qair2rh <- function(qair, temp, press = 1013.25){
    es <-  6.112 * exp((17.67 * temp)/(temp + 243.5))
    e <- qair * press / (0.378 * qair + 0.622)
    rh <- e / es
    rh[rh > 1] <- 1
    rh[rh < 0] <- 0
    return(rh)
}

```

Similar variable conversion functions can be found in the [`metutils.R`](https://github.com/PecanProject/pecan/blob/master/modules/data.atmosphere/R/metutils.R) file in the PEcAn data.atmosphere library.

> **Comments:**
> **username_2**: is this formula the same as the one by @username_4? Because I get slightly different results.  
> **username_1**: @user4050 rounding error: coefficient here is 6.112 vs 6.11 above  
> **username_2**: Thanks! And how exactly did you get e from 6.112*exp((17.67*Td)/(Td + 243.5)) that it's in the page you linked?  
> **username_1**: @user4050 I didn't; e = qair * press / (0.378 * qair + 0.622)  

---

### Answer by username_3 on 2016-01-26. Score: 3

I can't do, or won't do the math, but here is how I get around it.
Look up the saturation line at the temperature and pressure that I am concerned with on pseudo-adiabatic diagram. Then multiply the relative humidity times the saturation rate at that temperature. It's not precise, since there are many factors that vary, and you are approximating from a paper chart, but it's a good enough estimate for my work. Hope this is helpful for those of us at the simple end of the concept.


---

