-
Notifications
You must be signed in to change notification settings - Fork 418
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
Analytic Saturation Vapor Pressure #3726
Open
dcamron
wants to merge
3
commits into
Unidata:main
Choose a base branch
from
dcamron:analytic-satvap
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.
Open
Changes from all commits
Commits
Show all changes
3 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 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 |
---|---|---|
|
@@ -1545,7 +1545,7 @@ def saturation_vapor_pressure(temperature): | |
>>> from metpy.calc import saturation_vapor_pressure | ||
>>> from metpy.units import units | ||
>>> saturation_vapor_pressure(25 * units.degC).to('hPa') | ||
<Quantity(31.6742944, 'hectopascal')> | ||
<Quantity(31.623456, 'hectopascal')> | ||
|
||
See Also | ||
-------- | ||
|
@@ -1556,14 +1556,66 @@ def saturation_vapor_pressure(temperature): | |
Instead of temperature, dewpoint may be used in order to calculate | ||
the actual (ambient) water vapor (partial) pressure. | ||
|
||
The formula used is that from [Bolton1980]_ for T in degrees Celsius: | ||
Implemented solution from [Ambaum2020]_, Eq. 13, | ||
.. math:: e = e_{s0} \frac{T_0}{T}^{(c_{pl} - c_{pv}) / R_v} \exp{ | ||
\frac{L_0}{R_v T_0} - \frac{L}{R_v T}} | ||
|
||
.. math:: 6.112 e^\frac{17.67T}{T + 243.5} | ||
""" | ||
latent_heat = water_latent_heat_vaporization._nounit(temperature) | ||
heat_power = (mpconsts.nounit.Cp_l - mpconsts.nounit.Cp_v) / mpconsts.nounit.Rv | ||
exp_term = ((mpconsts.nounit.Lv / mpconsts.nounit.T0 - latent_heat / temperature) | ||
/ mpconsts.nounit.Rv) | ||
|
||
return ( | ||
mpconsts.nounit.sat_pressure_0c | ||
* (mpconsts.nounit.T0 / temperature) ** heat_power | ||
* np.exp(exp_term) | ||
) | ||
Comment on lines
+1564
to
+1573
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. This looks like it matches the paper and I don't see any better ways to approach the array math, so I'd say we're good to go here. |
||
|
||
|
||
@exporter.export | ||
@preprocess_and_wrap(wrap_like='temperature') | ||
@process_units({'temperature': '[temperature]'}, '[pressure]') | ||
def saturation_vapor_pressure_ice(temperature): | ||
r"""Calculate the saturation water vapor (partial) pressure over ice. | ||
|
||
Parameters | ||
---------- | ||
temperature : `pint.Quantity` | ||
Air temperature | ||
|
||
Returns | ||
------- | ||
`pint.Quantity` | ||
Saturation water vapor (partial) pressure | ||
|
||
Examples | ||
-------- | ||
>>> from metpy.calc import saturation_vapor_pressure_ice | ||
>>> from metpy.units import units | ||
>>> saturation_vapor_pressure_ice(-25 * units.degC).to('hPa') | ||
<Quantity(0.632434749, 'hectopascal')> | ||
|
||
See Also | ||
-------- | ||
saturation_vapor_pressure, vapor_pressure | ||
|
||
Notes | ||
----- | ||
Implemented solution from [Ambaum2020]_, Eq. 17, | ||
.. math:: e = e_{i0} \frac{T_0}{T}^{(c_{pi} - c_{pv}) / R_v} \exp{ | ||
\frac{L_{s0}}{R_v T_0} - \frac{L_s}{R_v T}} | ||
|
||
""" | ||
# Converted from original in terms of C to use kelvin. | ||
return mpconsts.nounit.sat_pressure_0c * np.exp( | ||
17.67 * (temperature - 273.15) / (temperature - 29.65) | ||
latent_heat = water_latent_heat_sublimation._nounit(temperature) | ||
heat_power = (mpconsts.nounit.Cp_i - mpconsts.nounit.Cp_v) / mpconsts.nounit.Rv | ||
exp_term = ((mpconsts.nounit.Ls / mpconsts.nounit.T0 - latent_heat / temperature) | ||
/ mpconsts.nounit.Rv) | ||
|
||
return ( | ||
mpconsts.nounit.sat_pressure_0c | ||
* (mpconsts.nounit.T0 / temperature) ** heat_power | ||
* np.exp(exp_term) | ||
) | ||
|
||
|
||
|
This file contains 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.
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.
After reading through section 5, I don't think we should rely on our constants here, but use the tuned value for$C_{pl} - C_{pv}$ that's used in the paper, 2180 J / kg / K (eq. 14). Our values are essentially assuming an ideal gas for water vapor, and nominally for the triple point; the discussion in Ambaum 2020 explains how their value minimizes errors against empirical data from IAPWS95 in the 0-100 degC range.
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.
I'm open to the idea that we allow users to override this value.