Solution (source code)

= Solution

For a hydrostatic, stably stratified atmosphere, define isentropic mass density $\sigma_\theta=-(1/g)\partial p/\partial\theta>0$ and relative vertical vorticity evaluated on an isentrope, $\zeta_\theta$. Then <isentropic potential vorticity> is
$$
\boxed{q_\theta=\frac{f+\zeta_\theta}{\sigma_\theta}=-g(f+\zeta_\theta)\frac{\partial\theta}{\partial p},\qquad f=2\Omega\sin\phi.}
$$
It is the hydrostatic isentropic form of dry <Ertel potential vorticity>, $q_E=\boldsymbol\omega_a\cdot\nabla\theta/\rho$. For inviscid, adiabatic motion with fixed composition and conservative body forces, $Dq_E/Dt=0$, so parcels carry their PV along isentropes. Stable stratification makes the coordinate transformation well defined.

Heating and friction spoil simple material conservation. More explicitly, with $\dot\theta=D\theta/Dt$ and nonconservative force per mass $\mathbf F$,
$$
\frac{Dq_E}{Dt}=\frac{\boldsymbol\omega_a\cdot\nabla\dot\theta+(\nabla\times\mathbf F)\cdot\nabla\theta}{\rho}.
$$
Thus the distribution is especially useful away from strongly diabatic clouds and frictional boundary layers. Explaining a velocity field by <potential-vorticity inversion> additionally requires an appropriate balanced-flow approximation and boundary information; a PV value alone does not specify the entire flow. <Fundamentals of Atmosphere-Ocean Dynamics by Michael Edgeworth McIntyre>[PartII§12, Ertel conservation, isentropic form and qualified invertibility]{ref}