Skip to content
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

Standardize RH calcs on WMO8 #3242

Merged
merged 10 commits into from
Nov 3, 2023
Merged

Conversation

dcamron
Copy link
Member

@dcamron dcamron commented Oct 25, 2023

Standardize RH calculations on WMO8 definition of relative humidity as

$$ RH = \frac{e}{e_s} $$

(eq 4.A.15)

such that any RH calculation with input of mixing ratio is made consistent with above as

$$ RH = \frac{w}{w_s} \frac{\epsilon + w_s}{\epsilon + w} $$

(eq 4.A.16)

As part of this process, we can also simplify dewpoint_from_specific_humidity to not require a temperature input. I've tried to do this in a way that allows arg and/or kwarg specification in a backwards compatible way. @dopplershift let me know your thoughts on the verbage here and how to best document this change and alert to an eventual deprecation. This does break our "check for versionchanged 1.0 and provide helpful error" handling in _check_units_inner_helper. I'm glad to change/remove that test or look into changing that handling. Handling slightly generalized and now issue a relatively quiet PendingDeprecationWarning.

I've yet to update the test values so folks can see how much changed. A few existing tests pass within tolerance but do have slightly changed values.

Checklist

@dcamron dcamron added Type: Maintenance Updates and clean ups (but not wrong) Area: Calc Pertains to calculations Type: API Change Changes to how existing functionality works Subarea: Thermo Pertains to thermodynamic calculations and their physical correctness labels Oct 25, 2023
@dcamron dcamron requested a review from a team as a code owner October 25, 2023 17:02
@dcamron dcamron requested review from dopplershift and removed request for a team October 25, 2023 17:02
@dcamron dcamron force-pushed the rh-vapor-pressure branch 2 times, most recently from ce93311 to 1fb9905 Compare October 25, 2023 18:20
@dcamron dcamron added this to the October 2023 milestone Oct 25, 2023
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.
Beyond standardizing this calc on WMO8, dewpoint_from_specific_humidity
can be simplified to not require temperature as an argument. Add an
internal implementation to support this and preserve API compatibility.
Also, config ruff to support "preview" includes, or E226 check will not
run on future versions.
Nothing fancy. Offer double-check suggestion for all number of
versionchanged in docstring, and present them all.
Copy link
Member

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one subtle problem with the dynamic argument handling.

src/metpy/calc/thermo.py Outdated Show resolved Hide resolved
Test dewpoint_from_specific_humidity handling with 1 arg, 1 kwarg.
Update dewpoint_from_specific_humidity backwards compatibility layer to
more completely handle mixed parameters in old function signature. Fixes
 array inputs and ordering of signature.
and test xarray inputs.
@dopplershift dopplershift merged commit 68baead into Unidata:main Nov 3, 2023
28 checks passed
@dcamron dcamron deleted the rh-vapor-pressure branch November 3, 2023 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Calc Pertains to calculations Subarea: Thermo Pertains to thermodynamic calculations and their physical correctness Type: API Change Changes to how existing functionality works Type: Maintenance Updates and clean ups (but not wrong)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Relative Humidity Inconsistency
2 participants