Skip to content

Conversation

@dcamron
Copy link
Member

@dcamron dcamron commented Dec 25, 2024

Dependent on #3725.

In a Christmas Eve sprint, I implemented the analytic saturation vapor pressure from Ambaum 2020, per recommendations from #626. Lots of updated test values, and these may change further, but I wanted to get the changes out there quickly so we could evaluate their impacts, as well as get the changes into the full test matrix.

All departures are small in relative magnitude, but some callouts for potential scrutiny:

  • test_lfc_ml
  • test_el and its extensions
  • any test involving cape_cin (mentioned in issue above as impacted, and needs LCL changes to see full picture.)
  • test_dewpoint_specific_humidity_xarray (I reduced the precision instead of redefining the test data)

test_equivalent_potential_temperature_masked worked before. The calculations work on the individual masked array elements but for some reason it blows up on the full array. numpy.ma.exp offered no help. If anyone has any insight here it had me pulling my hair out a bit. Marked this test, not the first time we've run into it in other contexts.

I'm not touching image tests until the other PR goes in and we tackle a review here, and maybe not even until LCL. Done.

To support LCL validation and future support of automatic LCL/LDL/LFL handling, I've built on (and credited) some previous work to enhance certain moisture calcs to support phase handling. In this case, saturation_vapor_pressure now supports water vapor equilibrium partial pressure over liquid and ice, and can automatically do so across the triple point temperature. I've plumbed this into moisture quantity calculations that depend on saturation vapor pressure as well.

I plan to follow up these changes with some tutorial and cookbook content in late Spring or early Summer.

Happy holidays! 🎅

@dcamron dcamron added Type: Maintenance Updates and clean ups (but not wrong) Area: Calc Pertains to calculations Subarea: Thermo Pertains to thermodynamic calculations and their physical correctness labels Dec 25, 2024
@dcamron dcamron requested a review from a team as a code owner December 25, 2024 00:21
@dcamron dcamron requested review from dopplershift and removed request for a team December 25, 2024 00:21
@dcamron dcamron changed the title Analytic satvap Analytic Saturation Vapor Pressure Dec 25, 2024
@dcamron dcamron force-pushed the analytic-satvap branch 3 times, most recently from 1a9b663 to 2e3383f Compare December 26, 2024 18:04
@dcamron dcamron mentioned this pull request Dec 30, 2024
3 tasks
@dopplershift dopplershift added this to the 1.7.0 milestone Jan 2, 2025
@dcamron dcamron force-pushed the analytic-satvap branch 2 times, most recently from 4ff23a1 to 6b436fe Compare January 6, 2025 23:28
@dopplershift
Copy link
Member

dopplershift commented Jan 7, 2025

I think it makes sense to do this by itself. I don't understand why the test is failing with overflow in exp(). I can get the test suite to fail, but I can't get it to warn when running in a notebook.

EDIT: It's definitely overflowing, and we can just ignore in the test like we do on some others. In a notebook, it appears once and is then suppressed.

.. 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
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will attach a figure summary of constant differences here later to justify neglecting this.

@dcamron dcamron changed the title Analytic Saturation Vapor Pressure Ambaum 2020 saturation vapor pressure + phase handling Apr 22, 2025
@dcamron dcamron force-pushed the analytic-satvap branch 2 times, most recently from 9913aa0 to 448b5d9 Compare April 22, 2025 21:01
@dcamron dcamron force-pushed the analytic-satvap branch 2 times, most recently from 11f85b0 to bfc19be Compare April 22, 2025 21:30
@dcamron
Copy link
Member Author

dcamron commented Apr 23, 2025

At this point we arrive at green, though I'm adding a few tests for dependent calcs now.

@dopplershift it looks like behavior tested in test_moist_lapse_failure no longer fails. Would you prefer I leave some version of that test in for consistency through time? Or just remove it?

@dopplershift
Copy link
Member

Ooof, that test looks like it's completely flaky given how many warning filters/xfails we have there. I think that was just checking that we enable some error catching/whatnot. Let's just go ahead and kill it.

isilber and others added 4 commits April 28, 2025 12:28
Particularly improving usefullness of RH at low temperatures

See Unidata#2320
Update saturation vapor pressure to use simplified analytic expressions from Ambaum 2020. Allows for consistent assumptions across liquid and ice regimes and consistency for many modern downstream calculations: notably, incoming Romps LCL enhancement.
dcamron added 6 commits April 28, 2025 18:45
Build off drafted phase handling from community to calculate saturation vapor pressure over liquid, ice, or automatically across arrays based on freezing line. Add and test arbitrary kwarg validator for new phase kwarg. Add phase kwarg to calcs dependent on satvap, excluding dewpoint_from* calcs.
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.

🎉

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: Maintenance Updates and clean ups (but not wrong)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update saturation_vapor_pressure

4 participants