-
Notifications
You must be signed in to change notification settings - Fork 16
Allow e3sm_to_cmip to use ilamb parameter names #672
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1cf4fa2
Allow e3sm_to_cmip to use ilamb parameter names
forsyth2 45dc2c6
Test unspecified ts_subsection
forsyth2 31e2f15
Check for empty component subsection names
forsyth2 3384fc4
add cmor supported 2d atm variables as default
chengzhuzhang 44992bb
Self-code review
forsyth2 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 |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| import pytest | ||
|
|
||
| from zppy.e3sm_to_cmip import check_and_define_parameters, check_parameters_for_bash | ||
| from zppy.utils import ParameterNotProvidedError | ||
|
|
||
|
|
||
| def test_check_parameters_for_bash(): | ||
|
|
||
| # 1. ts_grid is set explictily | ||
| c = {"ts_grid": "grid"} | ||
| check_parameters_for_bash(c) | ||
|
|
||
| # 2. ts_grid can't be set because an empty string is provided | ||
| c = {"ts_grid": ""} | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_parameters_for_bash(c) | ||
|
|
||
| # 3. ts_grid is set via ts_atm_grid | ||
| c = {"component": "atm", "ts_atm_grid": "atm_grid"} | ||
| check_parameters_for_bash(c) | ||
| # 4. ts_grid is set via ts_land_grid | ||
| c = {"component": "lnd", "ts_land_grid": "land_grid"} | ||
| check_parameters_for_bash(c) | ||
|
|
||
| # 5. ts_grid can't be set via ts_land_grid since component is atm | ||
| c = {"component": "atm", "ts_land_grid": "land_grid"} | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_parameters_for_bash(c) | ||
| # 6. ts_grid can't be set via ts_atm_grid since component is lnd | ||
| c = {"component": "lnd", "ts_atm_grid": "atm_grid"} | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_parameters_for_bash(c) | ||
|
|
||
| # 7. ts_grid can't be set via ts_atm_grid since component isn't specified | ||
| c = {"ts_atm_grid": "atm_grid"} | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_parameters_for_bash(c) | ||
| # 8. ts_grid can't be set via ts_land_grid since component isn't specified | ||
| c = {"ts_land_grid": "land_grid"} | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_parameters_for_bash(c) | ||
|
|
||
| # 9. ts_grid can't be set because ts_atm_grid is set to the empty string | ||
| c = {"component": "atm", "ts_atm_grid": ""} | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_parameters_for_bash(c) | ||
| # 10. ts_grid can't be set because ts_land_grid is set to the empty string | ||
| c = {"component": "lnd", "ts_land_grid": ""} | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_parameters_for_bash(c) | ||
|
|
||
|
|
||
| def test_check_and_define_parameters(): | ||
| sub = "name_of_this_subsection" | ||
|
|
||
| # Guess the subsection #################################################### | ||
| # 1. ts_subsection is set explictily | ||
| c = {"ts_subsection": "subsection", "guess_section_parameters": True} | ||
| check_and_define_parameters(c, sub) | ||
| assert c["ts_subsection"] == "subsection" | ||
|
|
||
| # 2. ts_subsection is set via sub because it is initially set to the empty string | ||
| c = {"ts_subsection": "", "guess_section_parameters": True} | ||
| check_and_define_parameters(c, sub) | ||
| assert c["ts_subsection"] == "name_of_this_subsection" | ||
|
|
||
| # 3. ts_subsection is set via ts_atm_subsection | ||
| c = { | ||
| "component": "atm", | ||
| "ts_atm_subsection": "atm_subsection", | ||
| "guess_section_parameters": True, | ||
| } | ||
| check_and_define_parameters(c, sub) | ||
| assert c["ts_subsection"] == "atm_subsection" | ||
| # 4. ts_subsection is set via ts_land_subsection | ||
| c = { | ||
| "component": "lnd", | ||
| "ts_land_subsection": "land_subsection", | ||
| "guess_section_parameters": True, | ||
| } | ||
| check_and_define_parameters(c, sub) | ||
| assert c["ts_subsection"] == "land_subsection" | ||
|
|
||
| # 5. ts_subsection can't be set via ts_land_subsection since component is atm | ||
| c = { | ||
| "component": "atm", | ||
| "ts_land_subsection": "land_subsection", | ||
| "guess_section_parameters": True, | ||
| } | ||
| check_and_define_parameters(c, sub) | ||
| assert c["ts_subsection"] == "name_of_this_subsection" | ||
| # 6. ts_subsection can't be set via ts_atm_subsection since component is lnd | ||
| c = { | ||
| "component": "lnd", | ||
| "ts_atm_subsection": "atm_subsection", | ||
| "guess_section_parameters": True, | ||
| } | ||
| check_and_define_parameters(c, sub) | ||
| assert c["ts_subsection"] == "name_of_this_subsection" | ||
|
|
||
| # 7. ts_subsection can't be set via ts_atm_subsection since component isn't specified | ||
| c = {"ts_atm_subsection": "atm_subsection", "guess_section_parameters": True} | ||
| check_and_define_parameters(c, sub) | ||
| assert c["ts_subsection"] == "name_of_this_subsection" | ||
| # 8. ts_subsection can't be set via ts_atm_subsection since component isn't specified | ||
| c = {"ts_land_subsection": "land_subsection", "guess_section_parameters": True} | ||
| check_and_define_parameters(c, sub) | ||
| assert c["ts_subsection"] == "name_of_this_subsection" | ||
|
|
||
| # 9. ts_subsection is set via sub because it is initially not provided | ||
| c = {"guess_section_parameters": True} | ||
| check_and_define_parameters(c, sub) | ||
| assert c["ts_subsection"] == "name_of_this_subsection" | ||
|
|
||
| # 10. ts_subsection is set via sub because it is initially not provided and component isn't specified (required to use ts_atm_subsection) | ||
| c = {"ts_atm_subsection": "", "guess_section_parameters": True} | ||
| check_and_define_parameters(c, sub) | ||
| assert c["ts_subsection"] == "name_of_this_subsection" | ||
|
|
||
| # 11. ts_subsection is set via sub because it is initially not provided and component isn't specified (required to use ts_land_subsection) | ||
| c = {"ts_land_subsection": "", "guess_section_parameters": True} | ||
| check_and_define_parameters(c, sub) | ||
| assert c["ts_subsection"] == "name_of_this_subsection" | ||
|
|
||
| # Don't guess the subsection ############################################## | ||
| # Repeat above cases, but with guess_section_parameters set to False | ||
|
|
||
| # 1 | ||
| c = {"ts_subsection": "subsection", "guess_section_parameters": False} | ||
| check_and_define_parameters(c, sub) | ||
| assert c["ts_subsection"] == "subsection" | ||
|
|
||
| # 2 | ||
| c = {"ts_subsection": "", "guess_section_parameters": False} | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_and_define_parameters(c, sub) | ||
|
|
||
| # 3 | ||
| c = { | ||
| "component": "atm", | ||
| "ts_atm_subsection": "atm_subsection", | ||
| "guess_section_parameters": False, | ||
| } | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_and_define_parameters(c, sub) | ||
| # 4 | ||
| c = { | ||
| "component": "lnd", | ||
| "ts_land_subsection": "land_subsection", | ||
| "guess_section_parameters": False, | ||
| } | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_and_define_parameters(c, sub) | ||
|
|
||
| # 5 | ||
| c = { | ||
| "component": "atm", | ||
| "ts_land_subsection": "land_subsection", | ||
| "guess_section_parameters": False, | ||
| } | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_and_define_parameters(c, sub) | ||
| # 6 | ||
| c = { | ||
| "component": "lnd", | ||
| "ts_atm_subsection": "atm_subsection", | ||
| "guess_section_parameters": False, | ||
| } | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_and_define_parameters(c, sub) | ||
|
|
||
| # 7 | ||
| c = {"ts_atm_subsection": "atm_subsection", "guess_section_parameters": False} | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_and_define_parameters(c, sub) | ||
| # 8 | ||
| c = {"ts_land_subsection": "land_subsection", "guess_section_parameters": False} | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_and_define_parameters(c, sub) | ||
|
|
||
| # 9 | ||
| c = {"guess_section_parameters": False} | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_and_define_parameters(c, sub) | ||
|
|
||
| # 10 | ||
| c = {"ts_atm_subsection": "", "guess_section_parameters": False} | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_and_define_parameters(c, sub) | ||
|
|
||
| # 11 | ||
| c = {"ts_land_subsection": "", "guess_section_parameters": False} | ||
| with pytest.raises(ParameterNotProvidedError): | ||
| check_and_define_parameters(c, sub) |
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.
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.
From what I understand, you're moving these parameters up a level in the configuration hierarchy so that they can be reused across each
e3sm_to_cmipsubtask, rather than configuringts_griddifferently for each subtask. The intention is to eliminate redundant code/configuration.Is this correct? If so, it sounds reasonable to me.