sharppy / SHARPpy

Sounding/Hodograph Analysis and Research Program in Python
https://sharppy.github.io/SHARPpy/index.html
Other
220 stars 110 forks source link

[BUG] Inconsistency in layer averaging of thermodynamic quantities #214

Open robwarrenwx opened 3 years ago

robwarrenwx commented 3 years ago

I have noticed an inconsistency in the way layer averaging is performed for different variables when the interpolated sounding is used (exact=False). The layer-mean mixing ratio is computed without pressure weighting, whereas the layer-mean potential temperature and equivalent potential temperature are both computed with pressure weighting. Furthermore, when interpolation is not performed (exact=True) the layer means are computed as simple averages without accounting for variations in layer mass or thickness. I note that the exact=True option is used in the definition of the forecast parcel and the mixed-layer parcel, whereas the default exact=False options is used in the definition of the effective-layer parcel and in the calculation of DCAPE.

I think that, in general, the layer average of a quantity X should be computed as Xavg = sum(X * rho * dz) / sum(rho * dz) = sum(X * dp) / sum(dp) when using pressure weighting and as Xavg = sum(X * dz) / sum(dz) = sum(X * dp / rho) / sum( dp / rho) when not using pressure weighting. Here dz is the height increment, dp = -rho*g*dz is the pressure increment, rho is air density, and g is the acceleration due to gravity.