-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relative Humidity Inconsistency #2951
Comments
Example: from metpy.units import units
import metpy.calc as mpcalc
from metpy.constants import epsilon
T = 25 * units.degC
RH = .5
p = 975 * units.hPa
es = mpcalc.saturation_vapor_pressure(T)
ws = mpcalc.saturation_mixing_ratio(p, T)
# AMS Calculations
e_ams = RH * es
w_ams = mpcalc.mixing_ratio(e_ams, p)
Td_ams = mpcalc.dewpoint_from_relative_humidity(T, RH)
# WMO Calculations
w_wmo = RH * ws
w_wmo2 = mpcalc.mixing_ratio_from_relative_humidity(p, T, RH)
assert(w_wmo == w_wmo2)
e_wmo = mpcalc.vapor_pressure(p, w_wmo)
Td_wmo = mpcalc.dewpoint(e_wmo)
print(' Quantity AMS WMO ')
print('-'*32)
print(f'Dewpoint(C) {Td_ams.m_as("degC"):7.2f} {Td_wmo.m_as("degC"):7.2f}')
print(f'Vap. Pres. (mb) {e_ams.m_as("hPa"):7.2f} {e_wmo.m_as("hPa"):7.2f}')
print(f'Mix Ratio (g/kg) {w_ams.m_as("g/kg"):7.2f} {w_wmo.m_as("g/kg"):7.2f}') Output:
So the feature request is a suggestion, for instance, that there should be a version of |
As far as I can tell, GEMPAK exclusively uses the AMS definition. |
Definite 👍 to making everything consistent around the AMS definition. I'm not sure what to do about the WMO definition. I don't want even more ugly-named functions laying around, but I'm not sure how to elegantly swap. I think my lean would be to wait until an actual compelling use case beyond "completeness" arose. |
Proposal: To use the nomenclature of Which is shown in detail at the following link: Create new functions:
|
@kgoebber So to be clear, you are proposing that the MetPy functions (at least by default) should all be consistent with the WMO definition of RH as opposed to the AMS definition of RH? |
Yes. But I am very open to other suggestions. The challenge of course is that relative humidity has the multiple definitions and we have typically shied away from boolean arguments to alter behavior (e.g., Maybe another possibility on naming would be:
We have also typically shied away from using abbreviations in our functions, although we do have a few (e.g., lcl, lfc, cape, etc.). Then at the 2.0 mark, when it would be appropriate more holistically review our relative humidity naming convention throughout the calculations. |
Given that GEMPAK uses the e/e_s definition, do we have any idea what's being used by NOAA/NCEP products (e.g. NBM, GFS, NARR, etc.)? What about WRF (I assume that's at least somewhere in some pre-/post-processing code). I think that would be illuminating to the discussion. |
Here is some ancient-looking code from WRF-VAR that uses the WMO definition. Similarly, this particular shallow convection scheme is using the WMO definition. (I think q tends to be used for mixing ratio in WRF-world even though I associate specific humidtiy with that letter.) But I can't find the right place in the WRF preprocessor code to see what they do there. |
On the dev call today, we reviewed a few more sources from the literature and I wanted to memorialize that discussion here.
In my own estimation, the NIST and cloud physics communities have a greater commitment to formal thermodynamic consistency (a sort of heritage from chemistry), which would have me favor WMO. |
It does seem like going with WMO is consistent with what more of the community is doing. I take it that at version 2.0 the problematic functions (the RH/dewpoint conversions) can be changed to match WMO, but if I want to calculate the dewpoint (given T, RH, and p) now, it isn't clear to me how the functions Kevin proposed are any better than the current workaround of calling the three functions I used in my example ( On the flip side, if at some point |
One way or another we're going to swap something so that we're internally consistent, and I'm happy to do that without worrying about 2.0. We've only every promised that you won't have to update code to remain working. (Yes everyone's definition of bug vs. "working" is different but satisfying everyone in that is the path to madness). Once we pick one (I lean WMO), there will be no way to get the other behavior in the short term. I'm open to allowing that at some point, but it's MUCH bigger lift, and would have to be considered with things like #142. For this particular issue, though, it's not like you'd be switching out some base calculation. You'd have to swap out a bunch of calculations and how they work--instead of going f1(x) -> f2(x), you're going f1(e, e_s) -> f2(r, r_s). That's a lot of complexity that would personally require an impressive use case to really want to embark upon it. |
After realizing that we'd take on a pressure dependency in
This should satisfy both use-cases in a physically meaningful way. @sgdecker would you be willing to contribute a modified version of your comparison above as an example explaining the difference? Or allow us to use it with credit in the PR to address this? |
@dcamron Sure, I could contribute something! When you say example, you mean a new entry in the Calculations section of the Example Gallery, correct? |
Yes! I envision your comparison above with a bit of explanation of the e/e_s simplification. This would need to go in after the actual code changes go in, showing how to perform either calculation by using the new optional pressure kwarg. |
So, after @dcamron did some digging, we've found this in the WMO No. 8 Vol 1; the NIST citation above which uses the "WMO definition" cites this Metrologia article, which cites WMO No. 8: I'll note the Metrologia paper also says 😆:
So does anyone actually have a heavy weight citation for the mixing ratio-based definition? |
I haven't had a chance to read through everything, but I get that the gist is that the NIST citation claims something that isn't true. Fun! Yes, I see that the conclusion of the Metrologia article is that using mixing ratio and calling that the "WMO definition" is a mistake, for instance, footnote 18: "For example, the on-line ‘Glossary of Meteorology’ of the American Meteorological Society (AMS) incorrectly states that relative humidity ‘is alternatively defined by the World Meteorological Organization as the ratio of the mixing ratio to the saturation mixing ratio’" |
Well, the gist is that it was asserted at the start of the issue that:
And the only documentation we can find from WMO says:
So right now there's a definite inconsistency in MetPy that needs fixing, but there's no evidence so that we should be giving any weight to the idea that w/ws is a desirable relation to use and support. |
Importantly, that BIPM document refers to RH as the "ratio of some non-negative humidity quantity, z, to the same quantity at saturation, zsat, at the same temperature", and does discuss a variety of quantities to plug in, including true vapor pressure It then goes on to refer to the definition from WMO No. 8, the isobaric ratio of partial pressure of vapor I'm going to keep this branch I've been working on, create a new branch getting these standardized on pressure ratios, and we'll eventually figure out where this should end up! |
I would consider Pruppacher and Klett (p. 107) a heavyweight, but favor implementing the community consensus and standard practice that is emerging based on the recent scholarship you've described above. |
Base all RH calculations on WMO8 standard using vapor partial pressure ratio. This includes calculations previously "directly" calculating from ratio of mixing ratios. Corrections cited. See Unidata#2951 for more info.
Base all RH calculations on WMO8 standard using vapor partial pressure ratio. This includes calculations previously "directly" calculating from ratio of mixing ratios. Corrections cited. See Unidata#2951 for more info.
Base all RH calculations on WMO8 standard using vapor partial pressure ratio. This includes calculations previously "directly" calculating from ratio of mixing ratios. Corrections cited. See Unidata#2951 for more info.
Base all RH calculations on WMO8 standard using vapor partial pressure ratio. This includes calculations previously "directly" calculating from ratio of mixing ratios. Corrections cited. See Unidata#2951 for more info.
What should we add?
MetPy is inconsistent in its definition of relative humidity. For review, there are two definitions:
Although the differences between these definitions are small, it would be good to be consistent, and perhaps give the user the power to decide which definition to use (perhaps with an rcparams-like option or by giving each existing RH-related function a twin?).
As examples,
relative_humidity_from_dewpoint
anddewpoint_from_relative_humidity
use the AMS definition, butrelative_humidity_from_mixing_ratio
andrelative_humidity_from_specific_humidity
use the WMO definition. In general, it appears the current code picks the definition by expediency (i.e., functions easier to write with the WMO definition use that definition, and functions easier to write with the AMS definition use that definition).Reference
No response
The text was updated successfully, but these errors were encountered: