# pressure derivations

1. pressure from bounds

   symbol | description | unit | variable name
   --- | --- | --- | ---
   \(p\) | pressure | \(Pa\) | pressure {:}
   \(p^{B}(l)\) | pressure boundaries (\(l \in \{1,2\}\)) | \(Pa\) | pressure_bounds {:,2}

   The pattern : for the dimensions can represent {vertical}, or {time,vertical}.

   \[p = e^{\frac{ln(z^{B}(2)) + ln(z^{B}(1))}{2}}\]

2. pressure from altitude

   symbol | description | unit | variable name
   --- | --- | --- | ---
   \(a\) | WGS84 semi-major axis | \(m\) |
   \(b\) | WGS84 semi-minor axis | \(m\) |
   \(f\) | WGS84 flattening | \(m\) |
   \(g\) | normal gravity at sea level | \(\frac{m}{s^2}\) |
   \(g_{0}\) | mean earth gravity | \(\frac{m}{s^2}\) |
   \(g_{h}\) | gravity at specific height | \(\frac{m}{s^2}\) |
   \(GM\) | WGS84 earth’s gravitational constant | \(\frac{m^3}{s^2}\) |
   \(M_{air}(i)\) | molar mass of total air | \(\frac{g}{mol}\) | molar_mass {:,vertical}
   \(p(i)\) | pressure | \(Pa\) | pressure {:,vertical}
   \(p_{surf}\) | surface pressure | \(Pa\) | surface_pressure {:}
   \(R\) | universal gas constant | \(\frac{kg m^2}{K mol s^2}\) |
   \(T(i)\) | temperature | \(K\) | temperature {:,vertical}
   \(z(i)\) | altitude | \(m\) | altitude {:,vertical}
   \(z_{surf}\) | surface height | \(m\) | surface_altitude {:}
   \(\phi\) | latitude | \(degN\) | latitude {:}
   \(\omega\) | WGS84 earth angular velocity | \(rad/s\) |

   The pattern : for the dimensions can represent {latitude,longitude}, {time}, {time,latitude,longitude}, or no dimensions at all.

   The surface pressure \(p_{surf}\) and surface height \(z_{surf}\) need to use the same definition of ‘surface’.

   The altitudes \(z(i)\) are expected to be above the surface height. This should normally be the case since even for altitude grids that start at the surface, \(z_{surf}\) should equal the lower altitude boundary \(z^{B}(1,1)\), whereas \(z(1)\) should then be between \(z^{B}(1,1)\) and \(z^{B}(1,2)\) (which is generally not equal to \(z^{B}(1,1)\)).

   \begin{eqnarray} g & = & 9.7803253359 \frac{1 + 0.00193185265241{\sin}^2(\frac{\pi}{180}\phi)} {\sqrt{1 - 0.00669437999013 {\sin}^2(\frac{\pi}{180}\phi)}} \\ m & = & \frac{\omega^2a^2b}{GM} \\ g(1) & = & g \left(1 - \frac{2}{a}\left(1+f+m-2f{\sin}^2(\frac{\pi}{180}\phi)\right)\frac{z_{surf}+z(1)}{2} + \frac{3}{a^2}\left(\frac{z_{surf}+z(1)}{2}\right)^2\right) \\ g(i) & = & g \left(1 - \frac{2}{a}\left(1+f+m-2f{\sin}^2(\frac{\pi}{180}\phi)\right)\frac{z(i-1)+z(i)}{2} + \frac{3}{a^2}\left(\frac{z(i-1)+z(i)}{2}\right)^2\right), 1 < i \leq N \\ p(1) & = & p_{surf}e^{-10^{-3}\frac{M_{air}(1)}{T(1)}\frac{g_{h}(1)}{R}\left(z(i)-z_{surf}\right)} \\ p(i) & = & p(i-1)e^{-10^{-3}\frac{M_{air}(i-1)+M_{air}(i)}{T(i-1)+T(i)}\frac{g_{h}(i)}{R}\left(z(i)-z(i-1)\right)}, 1 < i \leq N \end{eqnarray}

3. pressure from geopotential height

   symbol | description | unit | variable name
   --- | --- | --- | ---
   \(g_{0}\) | mean earth gravity | \(\frac{m}{s^2}\) |
   \(M_{air}(i)\) | molar mass of total air | \(\frac{g}{mol}\) | molar_mass {:,vertical}
   \(p(i)\) | pressure | \(Pa\) | pressure {:,vertical}
   \(p_{surf}\) | surface pressure | \(Pa\) | surface_pressure {:}
   \(R\) | universal gas constant | \(\frac{kg m^2}{K mol s^2}\) |
   \(T(i)\) | temperature | \(K\) | temperature {:,vertical}
   \(z_{g}(i)\) | geopotential height | \(m\) | geopotential_height {:,vertical}
   \(z_{g,surf}\) | surface geopotential height | \(m\) | surface_geopotential_height {:}

   The pattern : for the dimensions can represent {latitude,longitude}, {time}, {time,latitude,longitude}, or no dimensions at all.

   The surface pressure \(p_{surf}\) and surface height \(z_{g,surf}\) need to use the same definition of ‘surface’.

   The geopotential heights \(z_{g}(i)\) are expected to be above the surface geopotential height. This should normally be the case since even for geopotential height grids that start at the surface, \(z_{g,surf}\) should equal the lower altitude boundary \(z^{B}_{g}(1,1)\), whereas \(z_{g}(1)\) should then be between \(z^{B}_{g}(1,1)\) and \(z^{B}_{g}(1,2)\) (which is generally not equal to \(z^{B}_{g}(1,1)\)).

   \begin{eqnarray} p(1) & = & p_{surf}e^{-10^{-3}\frac{M_{air}(1)}{T(1)}\frac{g_{0}}{R}\left(z_{g}(i)-z_{g,surf}\right)} \\ p(i) & = & p(i-1)e^{-10^{-3}\frac{M_{air}(i-1)+M_{air}(i)}{T(i-1)+T(i)}\frac{g_{0}}{R}\left(z_{g}(i)-z_{g}(i-1)\right)}, 1 < i \leq N \end{eqnarray}

4. pressure from number density and temperature

   symbol | description | unit | variable name
   --- | --- | --- | ---
   \(k\) | Boltzmann constant | \(\frac{kg m^2}{K s^2}\) |
   \(n\) | number density | \(\frac{molec}{m^3}\) | number_density {:}
   \(p\) | pressure | \(Pa\) | pressure {:}
   \(T\) | temperature | \(K\) | temperature {:}

   The pattern : for the dimensions can represent {vertical}, {latitude,longitude}, {latitude,longitude,vertical}, {time}, {time,vertical}, {time,latitude,longitude}, {time,latitude,longitude,vertical}, or no dimensions at all.

   \[p = nkT\]

5. surface pressure from surface number density and surface temperature

   symbol | description | unit | variable name
   --- | --- | --- | ---
   \(k\) | Boltzmann constant | \(\frac{kg m^2}{K s^2}\) |
   \(n_{surf}\) | surface number density | \(\frac{molec}{m^3}\) | surface_number_density {:}
   \(p_{surf}\) | surface pressure | \(Pa\) | surface_pressure {:}
   \(T_{surf}\) | surface temperature | \(K\) | surface_temperature {:}

   The pattern : for the dimensions can represent {vertical}, {latitude,longitude}, {latitude,longitude,vertical}, {time}, {time,vertical}, {time,latitude,longitude}, {time,latitude,longitude,vertical}, or no dimensions at all.

   \[p_{surf} = n_{surf}kT_{surf}\]

6. tropopause pressure from temperature and altitude/pressure

   symbol | description | unit | variable name
   --- | --- | --- | ---
   \(p(i)\) | pressure | \(Pa\) | pressure {:,vertical}
   \(p_{TP}\) | tropopause pressure | \(Pa\) | tropopause_pressure {:}
   \(T(i)\) | temperature | \(K\) | temperature {:,vertical}
   \(z(i)\) | altitude | \(m\) | altitude {:,vertical}

   The pattern : for the dimensions can represent {latitude,longitude}, {time}, {time,latitude,longitude}, or no dimensions at all.

   The tropopause pressure \(p_{TP}\) equals the pressure \(p(i)\) where \(i\) is the minimum level that satisfies:

   \begin{eqnarray} & 1 < i < N & \wedge \\ & 5000 <= p(i) <= 50000 & \wedge \\ & \frac{T(i-1)-T(i)}{z(i)-z(i-1)} > 0.002 \wedge \frac{T(i)-T(i+1)}{z(i+1)-z(i)} <= 0.002 & \wedge \\ & \frac{\sum_{j, i < j < N \wedge z(j+1)-z(i) <= 2000} \frac{T(j)-T(j+1)}{z(j+1)-z(j)}}{\sum_{j, i < j < N \wedge z(j+1)-z(i) <= 2000}{1}} <= 0.002 & \end{eqnarray}

   If no such \(i\) can be found then \(p_{TP}\) is set to NaN.