[go: nahoru, domu]

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

Unit conversion warning #795

Merged
merged 4 commits into from
Jan 31, 2024
Merged

Conversation

kenkehoe
Copy link
Contributor

This adds keywords to the convert_units method to notify user when the conversion fail. Because of how the method can loop through all the variables in the Dataset we don't want to print or raise exceptions when a conversion fails. This adds options the user can implement. I tried to use warnings but they didn't work so it's a print statement.

  • [ X] Closes Add warning to change units when fails #793
  • [X ] Tests added
  • [ X] Documentation reflects changes
  • [ X] PEP8 Standards or use of linter
  • [X ] Xarray Dataset or DataArray variable naming follows 'ds' or 'da' naming

verbose : boolean
Option to print statement when an attempted conversion fails. Set to False
as default because many units strings are not udunits complient and when
trying to convert all varialbes of a type of units (eg temperature) the code
Copy link
Collaborator

Choose a reason for hiding this comment

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

complient to compliant and varialbes to variables

@@ -93,10 +95,13 @@ def test_convert_units():
data = act.utils.data_utils.convert_units(r_data, 'K', 'C')
assert np.ceil(data[0]) == 12

try:
# try:
# ds.utils.change_units()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we remove the commented out code?

@zssherman
Copy link
Collaborator

@kenkehoe Thanks for the PR! I added a few comments

@kenkehoe
Copy link
Contributor Author

@zssherman I removed the old code and submitted a job to run. I assume you can make the failing part of this process more better? I don't think it's something on my end.

@zssherman
Copy link
Collaborator

@kenkehoe Thanks for the changes! Yeah it was a stalled test. Should be rerunning now

@zssherman zssherman merged commit b0a5232 into ARM-DOE:main Jan 31, 2024
16 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.

Add warning to change units when fails
3 participants