Air Mass
The air mass calculation described in [7] is implemented in SolarFarmer as follows:
The relative air mass \(\AM_\text{r}\) is
$$\AM_\text{r}\left( \theta_\text{z} \right) = \frac{1.002432 \cos^2 \theta_\text{z} + 0.148386 \cos \theta_\text{z} + 0.0096467} {\cos^3 \theta_\text{z} + 0.149864 \cos^2 \theta_{z} + 0.0102963 \cos \theta_\text{z} + 0.000303978}$$
We use Horner's Rule to avoid taking powers for numerical stability (and computational load) reasons:
$$\AM_\text{r} \left( c_\text{z} \right) = \frac{ \left( 1.002432 c_\text{z} + 0.148386 \right) c_\text{z} + 0.0096467} { \left( \left( c_\text{z} + 0.149864 \right) c_\text{z} + 0.0102963 \right) c_\text{z} + 0.000303978}$$
Where
$$c_\text{z} = \cos\theta_\text{z}$$
The relative air mass is then corrected to the actual air mass according to [17] as follows, assuming surface air pressure, \(P\), in Pascals:
$$\AM_\text{a} \left( \theta_\text{z} \right) = \AM_\text{r} \left( \theta_\text{z} \right) \frac{P \text{[Pa]}}{101325\text{[Pa]}}$$
If surface air pressure is not available in the input data, it can be estimated from the site elevation, \(z\) (in meters) using [18]:
$$P = 100\text{[Pa]} \left( \frac{44331.514\text{[m]} - z\text{[m]}}{11880.516\text{[m]}} \right)^{\frac{1}{0.1902632}}$$