Skip to content
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

Ability to generate planar metric terms and addition of test_eta.py unit test #65

Merged
merged 21 commits into from
Sep 16, 2024

Conversation

fmalatino
Copy link
Contributor

@fmalatino fmalatino commented Aug 20, 2024

Description
A conditional statement has been added to the __init__ method of the MetricTerms class to allow for generating surface level metric terms (no hybrid pressure values). Initialization of such a MetricTerms object will now contain zero-valued hybrid pressures.

The unit test test_eta.py from pace/tests/main/grid has now been moved into ndsl/tests/grid along with a python module for generating the test eta level containing files.

This PR must be reviewed and merged after PR 92 is merged in pace

How Has This Been Tested?
Tested via the tests contained within the tests directory of NDSL, and in the tests of the dependent repositories

Pace tests will fail as the changes from PR 92 in Pace are necessary for passing.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included

…tion for surface level (no eta_file specified)
@fmalatino fmalatino marked this pull request as draft August 20, 2024 19:37
@fmalatino fmalatino marked this pull request as ready for review August 22, 2024 14:42
@fmalatino
Copy link
Contributor Author

Given that metric terms, and the grid generation methods as a whole are a part of NDSL, does it make sense to move the unit test tests/main/grid/test_eta.py in Pace to NDSL?

ndsl/grid/eta.py Outdated Show resolved Hide resolved
@FlorianDeconinck
Copy link
Collaborator

Given that metric terms, and the grid generation methods as a whole are a part of NDSL, does it make sense to move the unit test tests/main/grid/test_eta.py in Pace to NDSL?

Yes, please pull it down. We decided that the FV grid would come preset with NDSL, let's commit fully to it.

@fmalatino fmalatino changed the title Ability to generate surface level metric terms (no eta file specified) Ability to generate planar metric terms and addition of test_eta.py unit test Aug 27, 2024
Copy link
Collaborator

@oelbert oelbert left a comment

Choose a reason for hiding this comment

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

Minor documentation changes mostly, otherwise lgtm

ndsl/grid/eta.py Outdated Show resolved Hide resolved
Comment on lines 117 to 123
"""This test checks to see that the program
fails when (1) the eta_file is not specified in the yaml
configuration file; and (2), the computed eta values
increase non-monotonically. For the latter test, the eta_file
is specified in test_config_not_mono.yaml file and
the ak and bk values in the eta_file have been changed nonsensically
to result in erronenous eta values.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like this test only does the first of these two, so the docstring should reflect that

Copy link
Collaborator

Choose a reason for hiding this comment

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

This docstring still needs to be updated

Comment on lines 165 to 172
"""This test checks to see that the program
fails when (1) the eta_file is not specified in the yaml
configuration file; and (2), the computed eta values
increase non-monotonically. For the latter test, the eta_file
is specified in test_config_not_mono.yaml file and
the ak and bk values in the eta_file have been changed nonsensically
to result in erronenous eta values.
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above, please update the docstring to reflect the test

Copy link
Collaborator

Choose a reason for hiding this comment

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

same with this one

tests/grid/test_eta.py Outdated Show resolved Hide resolved
Comment on lines 117 to 123
"""This test checks to see that the program
fails when (1) the eta_file is not specified in the yaml
configuration file; and (2), the computed eta values
increase non-monotonically. For the latter test, the eta_file
is specified in test_config_not_mono.yaml file and
the ak and bk values in the eta_file have been changed nonsensically
to result in erronenous eta values.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This docstring still needs to be updated

Comment on lines 165 to 172
"""This test checks to see that the program
fails when (1) the eta_file is not specified in the yaml
configuration file; and (2), the computed eta values
increase non-monotonically. For the latter test, the eta_file
is specified in test_config_not_mono.yaml file and
the ak and bk values in the eta_file have been changed nonsensically
to result in erronenous eta values.
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

same with this one

ndsl/grid/generation.py Outdated Show resolved Hide resolved
self._ak,
self._bk,
) = self._set_hybrid_pressure_coefficients(eta_file, ak, bk)
else:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this the behavior we want? I thought we'd rather raise a ValueError or something here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A ValueError is raised deeper in when the file specified is either non-existent, and even lower if the values do not fit the size passed in the config. My thought was that we could still have hybrid pressure values; zero valued if no file passed, or specified when passed.

fmalatino and others added 2 commits September 4, 2024 21:23
… eta_file variable in generation.py to use an empty string in conditional statement for hybrid pressure generation
@fmalatino fmalatino requested a review from oelbert September 5, 2024 13:48
FlorianDeconinck

This comment was marked as outdated.

Copy link
Collaborator

@FlorianDeconinck FlorianDeconinck left a comment

Choose a reason for hiding this comment

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

Cleanup the default eta_file using the pythonic None

ndsl/grid/generation.py Outdated Show resolved Hide resolved
ndsl/grid/generation.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@FlorianDeconinck FlorianDeconinck left a comment

Choose a reason for hiding this comment

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

Fix a type hint and we are ready to go

ndsl/grid/generation.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@FlorianDeconinck FlorianDeconinck left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@oelbert oelbert left a comment

Choose a reason for hiding this comment

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

👍

@fmalatino fmalatino merged commit 4a4c0c8 into NOAA-GFDL:develop Sep 16, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants