-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Clarify rh_from_tdew variable naming, comments and references #2782
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
Open
gaoflow
wants to merge
2
commits into
pvlib:main
Choose a base branch
from
gaoflow:fix-2734-rh-from-tdew-naming
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+46
−13
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -363,19 +363,34 @@ def rh_from_tdew(temp_air, temp_dew, coeff=(6.112, 17.62, 243.12)): | |||||||||
| numeric | ||||||||||
| Relative humidity (0.0-100.0). [%] | ||||||||||
|
|
||||||||||
| Notes | ||||||||||
| ----- | ||||||||||
| Relative humidity is computed as ``100 * e / es``, where the actual vapor | ||||||||||
| pressure ``e`` is the saturation vapor pressure at the dew point and the | ||||||||||
|
Comment on lines
+368
to
+369
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| saturation vapor pressure ``es`` is evaluated at the air temperature, both | ||||||||||
| from the Magnus equation ``A * exp(B * T / (C + T))``. The default | ||||||||||
|
Comment on lines
+370
to
+371
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| coefficients ``(A, B, C) = (6.112, 17.62, 243.12)`` are the WMO-recommended | ||||||||||
| Magnus form for saturation over liquid water, valid for temperatures from | ||||||||||
| -45 to +60 °C [1]_; see [2]_ for the approximation and its accuracy. | ||||||||||
|
|
||||||||||
| References | ||||||||||
| ---------- | ||||||||||
| .. [1] "Guide to Instruments and Methods of Observation", | ||||||||||
| World Meteorological Organization, WMO-No. 8, 2023. | ||||||||||
| https://library.wmo.int/idurl/4/68695 | ||||||||||
| .. [2] O. A. Alduchov and R. E. Eskridge, "Improved Magnus Form | ||||||||||
| Approximation of Saturation Vapor Pressure", Journal of Applied | ||||||||||
| Meteorology, 35(4), pp. 601-609, 1996. | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| # Calculate vapor pressure (e) and saturation vapor pressure (es) | ||||||||||
| e = coeff[0] * np.exp((coeff[1] * temp_air) / (coeff[2] + temp_air)) | ||||||||||
| es = coeff[0] * np.exp((coeff[1] * temp_dew) / (coeff[2] + temp_dew)) | ||||||||||
| # Actual vapor pressure ``e`` is the saturation vapor pressure at the dew | ||||||||||
| # point; the saturation vapor pressure ``es`` is taken at the air | ||||||||||
| # temperature. Both come from the Magnus equation. | ||||||||||
| e = coeff[0] * np.exp((coeff[1] * temp_dew) / (coeff[2] + temp_dew)) | ||||||||||
| es = coeff[0] * np.exp((coeff[1] * temp_air) / (coeff[2] + temp_air)) | ||||||||||
|
|
||||||||||
| # Calculate relative humidity as percentage | ||||||||||
| relative_humidity = 100 * (es / e) | ||||||||||
| # Relative humidity is their ratio, as a percentage. | ||||||||||
| relative_humidity = 100 * (e / es) | ||||||||||
|
|
||||||||||
| return relative_humidity | ||||||||||
|
|
||||||||||
|
|
@@ -406,17 +421,14 @@ def tdew_from_rh(temp_air, relative_humidity, coeff=(6.112, 17.62, 243.12)): | |||||||||
| World Meteorological Organization, WMO-No. 8, 2023. | ||||||||||
| https://library.wmo.int/idurl/4/68695 | ||||||||||
| """ | ||||||||||
| # Calculate the term inside the log | ||||||||||
| # From RH = 100 * (es/e), we get es = (RH/100) * e | ||||||||||
| # Substituting the Magnus equation and solving for dewpoint | ||||||||||
|
|
||||||||||
| # First calculate ln(es/A) | ||||||||||
| # Invert RH = 100 * (e / es): the actual vapor pressure is | ||||||||||
| # e = (RH / 100) * es, and the dew point is the temperature at which the | ||||||||||
| # saturation vapor pressure equals e. Substituting the Magnus equation for | ||||||||||
| # both and solving for the dew point gives the expression below. | ||||||||||
| ln_term = ( | ||||||||||
| (coeff[1] * temp_air) / (coeff[2] + temp_air) | ||||||||||
| + np.log(relative_humidity/100) | ||||||||||
| + np.log(relative_humidity / 100) | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| # Then solve for dewpoint | ||||||||||
| dewpoint = coeff[2] * ln_term / (coeff[1] - ln_term) | ||||||||||
|
|
||||||||||
| return dewpoint | ||||||||||
|
|
||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.