<p>The specific humidity is the ratio of the mass of water vapor to the total mass of the air parcel. The absolute humidity is the mass of the water vapor by the volume of the air parcel. To connect both, you simply need the density of air, which you can estimate from the height above ground by assuming some standard atmosphere.</p>
<p>So, you can not, without further assumptions calculate the specific humidity by using absolute humidity and height above ground, but you can get a fair estimate using some standard assumption.</p>

CC BY-SA 4.0
2023-02-22T10:51:01.513Z
Okay, I assume that air consists of a mixture of dry air and water vapor. At the same time this mixture is evenly mixed. I also use a standard ISO atmosphere. Can I calculate the specific humidity based on these assumptions?
w.ilia.m
CC BY-SA 4.0
2023-02-22T16:01:09.713Z
Yes. From the standard atmosphere assumption, you can get the pressure depending on height p(H) and, hence, also the density.
hschoell
CC BY-SA 4.0
2023-02-21T09:09:35.597Z
2023-02-21T09:59:45.423Z
2023-02-21T09:59:45.423Z
hschoell
<p>I'm trying to make a weather simulator using the article <em>Interactive Meso-scale Simulation of Skyscapes</em>. It gives the formula for calculating the mean static energy:</p>
<p><span class="math-container">$$MSE_i = C_p \cdot T_i + g \cdot \Theta_i + L_v \cdot Q_i$$</span></p>
<p>But I don't understand how to calculate specific humidity, the article says that it can be calculated using absolute humidity (<span class="math-container">$H_i$</span>) and height above the ground (<span class="math-container">$\Theta_i$</span>) (quote: <span class="math-container">$Q_i$</span> is the specific humidity of the air layer (and can be derived from <span class="math-container">$H_i$</span> and <span class="math-container">$\Theta_i$</span>)). Is there any specific formula for calculating specific humidity or am I missing something?</p>
<p>Update 1.</p>
<p>So I have implemented a function to calculate specific humidity in python. Here <strong>AH</strong> is the absolute humidity in <span class="math-container">$g/m^3$</span>, <strong>p</strong> is the pressure in pascals at the calculation point and <strong>t</strong> is temperature in Celsius.</p>
<pre><code>def get_specific_humidity(AH, t, p):
    e = (AH / 1000) * 461.5 * (t + 273.15)
    r =  (0.622 * e) / (p - e)
    return r / (1 + r)
</code></pre>
<p>First I calculated the vapor pressure <strong>e</strong> using the formula:
<span class="math-container">$$\frac{m}{V} = \frac{e}{R_vT}$$</span>
The calculation assumes that the dry air is evenly mixed with water. Also <span class="math-container">$R_v=461.5$</span> is specific gas constant for water vapor. Next, I calculated the mixing ratio using this equation:</p>
<p><span class="math-container">$$r=\frac{0.622e}{p-e}$$</span></p>
<p>And finally using the mixing ratio it is possible to calculate the specific humidity:
<span class="math-container">$$q=\frac{r}{1+r}$$</span></p>
<p>Did I do everything right?</p>

<humidity>
How to get specific humidity through absolute humidity and height above ground
w.ilia.m
# How to get specific humidity through absolute humidity and height above ground

(Asked by: username_0 on 2023-02-12)

I'm trying to make a weather simulator using the article *Interactive Meso-scale Simulation of Skyscapes*. It gives the formula for calculating the mean static energy:

$$MSE\_i = C\_p \cdot T\_i + g \cdot \Theta\_i + L\_v \cdot Q\_i$$

But I don't understand how to calculate specific humidity, the article says that it can be calculated using absolute humidity ($H\_i$) and height above the ground ($\Theta\_i$) (quote: $Q\_i$ is the specific humidity of the air layer (and can be derived from $H\_i$ and $\Theta\_i$)). Is there any specific formula for calculating specific humidity or am I missing something?

Update 1.

So I have implemented a function to calculate specific humidity in python. Here **AH** is the absolute humidity in $g/m^3$, **p** is the pressure in pascals at the calculation point and **t** is temperature in Celsius.

```
def get_specific_humidity(AH, t, p):
    e = (AH / 1000) * 461.5 * (t + 273.15)
    r =  (0.622 * e) / (p - e)
    return r / (1 + r)

```

First I calculated the vapor pressure **e** using the formula:
$$\frac{m}{V} = \frac{e}{R\_vT}$$
The calculation assumes that the dry air is evenly mixed with water. Also $R\_v=461.5$ is specific gas constant for water vapor. Next, I calculated the mixing ratio using this equation:

$$r=\frac{0.622e}{p-e}$$

And finally using the mixing ratio it is possible to calculate the specific humidity:
$$q=\frac{r}{1+r}$$

Did I do everything right?

**Tags:** humidity


---

## 1 answers

### Answer by username_1 on 2023-02-21. Score: 1

The specific humidity is the ratio of the mass of water vapor to the total mass of the air parcel. The absolute humidity is the mass of the water vapor by the volume of the air parcel. To connect both, you simply need the density of air, which you can estimate from the height above ground by assuming some standard atmosphere.

So, you can not, without further assumptions calculate the specific humidity by using absolute humidity and height above ground, but you can get a fair estimate using some standard assumption.

> **Comments:**
> **username_0**: Okay, I assume that air consists of a mixture of dry air and water vapor. At the same time this mixture is evenly mixed. I also use a standard ISO atmosphere. Can I calculate the specific humidity based on these assumptions?  
> **username_1**: Yes. From the standard atmosphere assumption, you can get the pressure depending on height p(H) and, hence, also the density.  

---

