# Modeling ground-level density at baseball stadiums using weather data In order to accurately predict the flightpath of a baseball, one must accurately account for the density, $\rho$, and viscosity, $\mu$ of the air in the ballpark. In aeronautics, the primary considerations for these factors come from variation with altitude and with the strange conditions that are experienced in aeronautics- inside turbines and at high speeds. For baseball, we- generally speaking- are interested in translating between common and accessible weather measurements:

• temperature
• barometric pressure
• ''percent humidity''

to the density and viscosity we need to accurately predict a baseball's flightpath.

The first step is to rigorously define the terms in the weather data. The temperature will be given in terms of a relative dry-bulb temperature in Fahrenheit or Celsius and pressure in terms of barometer readings in $\textrm{inHg}$. We will want to convert the temperatures into absolute units of Kelvin, and pressures into metric Pascals. Once the appropriate conversions are made, we will describe the temperature with the variable $T$, and the pressure with a variable $p_\mathrm{air, m}$; we'll refer to the unit version (zero to one, instead of zero to 100) of the percent humidity as $H$.

To complete this task, we now need to interpret the percent humidity that is represented in weather data. Percent humidity is equivalent to the percent ratio of the present partial pressure of water vapor saturation partial pressure of water vapor in air at the current temperature. In terms of $H$:
$$H= \frac{p_\mathrm{vapor}}{p_\mathrm{sat.}}$$
where $p_\mathrm{sat.}= p_\mathrm{sat.}(T)$ is the saturation partial pressure of water vapor. This can be given as a function of temperature, by, for instance, Tetens equation:
$$p_\mathrm{sat.}(T)= 610.78 \exp \left( \frac{17.27 (T - 273.15)}{T - 35.85} \right)$$
Rearranging, we can write:
$$p_\mathrm{vapor}= p_\mathrm{vapor}(T, H)= H p_\mathrm{sat.}(T)$$

Humidity ratio $x$ is the ratio of water vapor to dry air per unit mass:
\begin{aligned} x &= \frac{m_\mathrm{vapor}}{m_\mathrm{air,d}}= \frac{\rho_\mathrm{vapor}}{\rho_\mathrm{air,d}} \\ &= \frac{p_\mathrm{vapor} R_\mathrm{air,d} T_\mathrm{air,d}}{p_\mathrm{air,d} R_\mathrm{vapor} T_\mathrm{vapor}} \\ &= \frac{p_\mathrm{vapor} R_\mathrm{air,d}}{p_\mathrm{air,d} R_\mathrm{vapor}} \\ x(T, p_\mathrm{air, m}, H) &= \frac{R_\mathrm{air, d}}{R_\mathrm{vapor}} \frac{p_\mathrm{vapor}(T, H)}{p_\mathrm{air, m} - p_\mathrm{vapor}(T, H)} \end{aligned}
where, here, we've assumed the ideal gas law applies to all gasses involved in the mixture and that the temperature is equilibriated between the parts. The subscript $(\cdot)_\mathrm{air, d}$ refers to a quantity for dry air and $(\cdot)_\mathrm{air, m}$ refers to a quantity for the moist air mixture.

Finally, we can apply the ideal gas law again to the mixture. Starting with mass on a unit volume, and again making equilibriated temperature and ideal gas assumptions:
\begin{aligned} m_\mathrm{air, m} &= m_\mathrm{air, d} + m_\mathrm{vapor} \\ \rho_\mathrm{air, m} &= \rho_\mathrm{air, d} + \rho_\mathrm{vapor} \\ &= \frac{1}{T} \left( \frac{p_\mathrm{air, d}}{R_\mathrm{air, d}} + \frac{p_\mathrm{vapor}}{R_\mathrm{vapor}} \right) \\ &= \frac{1}{R_\mathrm{air, d} T} \left( p_\mathrm{air, d} + p_\mathrm{vapor} \frac{R_\mathrm{air, d}}{R_\mathrm{vapor}} \right) \\ \rho_\mathrm{air, m} (T, p_\mathrm{air, m}, H) &= \frac{ (p_\mathrm{air, m} - p_\mathrm{vapor}(T, H))}{R_\mathrm{air, d} T} \left(1 + x(T, p_\mathrm{air, m}, H) \right) \end{aligned}
Thus, we now can calculate the density of moist air with easily accessible public weather data!

Oh, I almost forgot. There are constants:

symbol name value units
$R_\mathrm{air, d}$ specific gas constant of dry air $287.1$ $\frac{\mathrm{J}}{\mathrm{kg~K}}$
$R_\mathrm{vapor}$ specific gas constant of water vapor $461.5$ $\frac{\mathrm{J}}{\mathrm{kg~K}}$

1. much of this is cribbed or at least inspired by the Engineering ToolBox pages on moist air calculations, with some more detail on derivations.