-
Notifications
You must be signed in to change notification settings - Fork 100
EPPT-2510: Adding calculation of saturation vapour pressure derivative in air #2165
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
Merged
mo-philrelton
merged 4 commits into
metoppv:EPPT_2072_contrails_design
from
mo-robertneal:EPP_2510_svp_derivative_in_air_correction
Jul 30, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dea4804
Code changes to add the SVP derivative corrected for in air
mo-robertneal 583c96c
Adding a missing temperature term to the correction calculation
mo-robertneal c6ddfaf
Updating expected values in unit tests and changing one of the import…
mo-robertneal 47d9020
Updating one of the ecpected values within the unit tests
mo-robertneal 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
50 changes: 50 additions & 0 deletions
50
improver_tests/psychrometric_calculations/test_calculate_svp_derivative_in_air.py
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 |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # (C) Crown Copyright, Met Office. All rights reserved. | ||
| # | ||
| # This file is part of 'IMPROVER' and is released under the BSD 3-Clause license. | ||
| # See LICENSE in the root of the repository for full licensing details. | ||
| """Unit tests for psychrometric_calculations calculate_svp_derivative_in_air""" | ||
|
|
||
| import unittest | ||
|
|
||
| import numpy as np | ||
| from iris.tests import IrisTest | ||
|
|
||
| from improver.psychrometric_calculations.psychrometric_calculations import ( | ||
| _svp_derivative_from_lookup, | ||
| calculate_svp_derivative_in_air, | ||
| ) | ||
|
|
||
|
|
||
| class Test_calculate_svp_derivative_in_air(IrisTest): | ||
| """Test the calculate_svp_derivative_in_air function""" | ||
|
|
||
| def setUp(self): | ||
| """Set up test data""" | ||
| self.temperature = np.array([[185.0, 260.65, 338.15]], dtype=np.float32) | ||
| self.pressure = np.array([[1.0e5, 9.9e4, 9.8e4]], dtype=np.float32) | ||
|
|
||
| def test_calculate_svp_derivative_in_air(self): | ||
| """Test pressure-corrected SVP derivative values""" | ||
| expected = np.array([[5.89845229e-06, 3.54367486e02, 1.26270031e06]]) | ||
| result = calculate_svp_derivative_in_air(self.temperature, self.pressure) | ||
| np.testing.assert_allclose(result, expected, rtol=1e-5, atol=1e-5) | ||
|
|
||
| def test_values(self): | ||
| """Basic extraction of SVP derivative values from lookup table""" | ||
| self.temperature[0, 1] = 260.56833 | ||
| expected = [[2.41833058e-03, 1.86569996e01, 1.11889656e03]] | ||
| result = _svp_derivative_from_lookup(self.temperature) | ||
| np.testing.assert_allclose(result, expected, rtol=1e-5, atol=1e-5) | ||
|
|
||
| def test_beyond_table_bounds(self): | ||
| """Extracting SVP derivative values from the table with temperatures beyond | ||
| its valid range. Should return the nearest end of the table.""" | ||
| self.temperature[0, 0] = 150.0 | ||
| self.temperature[0, 2] = 400.0 | ||
| expected = [[1.76528667e-03, 1.87835245e01, 1.11889656e03]] | ||
| result = _svp_derivative_from_lookup(self.temperature) | ||
| np.testing.assert_allclose(result, expected, rtol=1e-5, atol=1e-5) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
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.
Typically when we add new tests we do it in pytest (the old tests all use iris test). This doesn't actually afffect anything functionally so I don't think it's worth changing anything