-
Notifications
You must be signed in to change notification settings - Fork 46
add effective saturation wrt ice/liquid from Jouzel&Merlivat 1984 #1668
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
AgnieszkaZaba
wants to merge
30
commits into
open-atmos:main
Choose a base branch
from
AgnieszkaZaba:eff-S
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
30 commits
Select commit
Hold shift + click to select a range
428e796
add Bolot 2013 formula for kinetic fract. factor
AgnieszkaZaba 3de2ebc
Merge branch 'main' into bolot
AgnieszkaZaba 41e3acf
clean up functions; add test checking n
AgnieszkaZaba f81c961
remove Bolot formula as it is defined in Jouzel & Merlivat
AgnieszkaZaba b0590ca
update signatures
AgnieszkaZaba f66f3cf
add units tests
AgnieszkaZaba 1bf0b8c
after @slayoo review :)
AgnieszkaZaba daf4096
Merge branch 'open-atmos:main' into bolot
AgnieszkaZaba ec889b8
refactor
AgnieszkaZaba 2ec2426
rerun notebook
AgnieszkaZaba 106f8db
revert adding effective saturation as not used here
AgnieszkaZaba b50b618
remove unused variables
AgnieszkaZaba b98187d
refactor variable name
AgnieszkaZaba 4026720
remove unused function as will be addressed in new PR
AgnieszkaZaba b443915
add effective saturation
AgnieszkaZaba 0620222
create alphas comparison and temperatures
AgnieszkaZaba c4ea180
work with Elise
AgnieszkaZaba 5679ecb
add comparison notebook
AgnieszkaZaba 9d9c443
add simple smoke test
AgnieszkaZaba 1d050e7
Merge branch 'main' into eff-S
AgnieszkaZaba 0df3c00
Merge branch 'main' into eff-S
AgnieszkaZaba b1682d3
rename file to proper fig number from paper; add test for values on t…
AgnieszkaZaba 2549a34
compress fig8 with fig9
AgnieszkaZaba c065381
change import order
AgnieszkaZaba 1ba210e
some changes to naming and plot styles
AgnieszkaZaba 6efd7bf
update formula for transfer coeff to match J&M 1984
AgnieszkaZaba dbe2f4b
add test for effective saturation
AgnieszkaZaba 06beac7
fix test after refactor
AgnieszkaZaba 8bf5a49
fix test after refactor vol2
AgnieszkaZaba 7d555df
use class in test instead Formulae
AgnieszkaZaba 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
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
304 changes: 265 additions & 39 deletions
304
examples/PySDM_examples/Jouzel_and_Merlivat_1984/fig_8_9.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
96 changes: 96 additions & 0 deletions
96
tests/smoke_tests/no_env/jouzel_and_merlivat_1984/test_fig_8.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,96 @@ | ||
""" | ||
tests for fig. 8 from [Jouzel & Merlivat 1984 (J. Geophys. Res. Atmos. 89)](https://doi.org/10.1029/JD089iD07p11749) | ||
""" # pylint: disable=line-too-long | ||
|
||
from pathlib import Path | ||
import pytest | ||
import numpy as np | ||
from open_atmos_jupyter_utils import notebook_vars | ||
|
||
from PySDM_examples import Jouzel_and_Merlivat_1984 | ||
from PySDM.physics.constants import T0 | ||
|
||
PLOT = False | ||
|
||
|
||
@pytest.fixture(scope="session", name="notebook_variables") | ||
def notebook_variables_fixture(): | ||
return notebook_vars( | ||
file=Path(Jouzel_and_Merlivat_1984.__file__).parent / "fig_8_9.ipynb", | ||
plot=PLOT, | ||
) | ||
|
||
|
||
class TestFig8: | ||
@staticmethod | ||
@pytest.mark.parametrize( | ||
"if_effective, temp_C, value", | ||
( | ||
(False, 0, 1), | ||
(False, -10, 1.1), | ||
(False, -20, 1.22), | ||
(False, -30, 1.34), | ||
(False, -45, 1.54), | ||
(True, 0, 1), | ||
(True, -10, 1.08), | ||
(True, -20, 1.18), | ||
(True, -30, 1.30), | ||
(True, -45, 1.52), | ||
), | ||
) | ||
def test_fig8_values_against_the_paper( | ||
notebook_variables, if_effective, temp_C, value | ||
): | ||
# arrange | ||
temperature_C = notebook_variables["T_0_50"] - T0 | ||
if if_effective: | ||
Si = notebook_variables["eff_saturation_wrt_ice_at_RH100"] | ||
else: | ||
Si = notebook_variables["saturation_wrt_ice_at_RH100"] | ||
|
||
# act | ||
sut = Si[np.argmin(np.abs(temperature_C - temp_C))] | ||
|
||
# assert | ||
np.testing.assert_approx_equal(sut, value, significant=1) | ||
|
||
@staticmethod | ||
@pytest.mark.parametrize("temperature_C, expected", ((-20, 0.05),)) | ||
def test_fig_8_max_difference(notebook_variables, temperature_C, expected): | ||
""" | ||
Test maximum difference between saturation and effective saturation over ice. | ||
Based on comment the on eq. (13) | ||
in [Jouzel & Merlivat 1984 (J. Geophys. Res. Atmos. 89)](https://doi.org/10.1029/JD089iD07p11749) | ||
""" # pylint: disable=line-too-long | ||
# arrange | ||
saturation_difference = notebook_variables["saturation_difference"] | ||
temp = notebook_variables["T_0_50"] | ||
temp_C = temp - T0 | ||
temp_C_tolerance = 0.01 | ||
|
||
# act | ||
max_difference = np.max(saturation_difference) | ||
temp_C_range_max = temp_C[ | ||
np.isclose(saturation_difference, max_difference, rtol=0.1) | ||
] | ||
|
||
# assert | ||
assert max_difference <= expected | ||
assert ( | ||
np.min(temp_C_range_max) - temp_C_tolerance | ||
<= temperature_C | ||
<= np.max(temp_C_range_max) + temp_C_tolerance | ||
) | ||
|
||
@staticmethod | ||
def test_alpha_less_then_eff_alpha(notebook_variables): | ||
# arrange | ||
alpha_eff = notebook_variables["eff_alpha_kinetic"] | ||
alpha = notebook_variables["alpha_kinetic"] | ||
|
||
# act | ||
sut = alpha_eff | ||
|
||
# assert | ||
np.testing.assert_array_less(sut, 1) | ||
np.testing.assert_array_less(alpha, alpha_eff) |
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.
suggest renaming
saturation_wrt_ice = p_vs_water(T) / p_vs_ice(T)
tosaturation_wrt_ice_at_RH100 = ...
or alike