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

fix check_levels_exist decorator #265

Merged
merged 1 commit into from
Dec 14, 2022
Merged

fix check_levels_exist decorator #265

merged 1 commit into from
Dec 14, 2022

Conversation

cehbrecht
Copy link
Collaborator

Pull Request Checklist:

  • This PR addresses an already opened issue (for bug fixes / features)
    • This PR fixes issue #xyz
  • Tests for the changes have been added (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • HISTORY.rst has been updated (with summary of main changes)
  • I have added my relevant user information to AUTHORS.md
  • What kind of change does this PR introduce?:
    bug fix

  • Does this PR introduce a breaking change?:
    no

  • Other information:
    This PR is a follow up fix for PR fix subset level by values with method=nearest #262. It fixes the check_levels_exist decorator to handle level values like 1000.00000001. It rounds them to precision 4 to match them with the correct value 1000.0.

@@ -286,7 +286,8 @@ def func_checker(*args, **kwargs):

req_levels = set(kwargs.get("level_values", set()))
da_levels = xu.get_coord_by_type(da, "level")
levels = {lev for lev in da_levels.values}
# round levels to precision 4. There might be level values like 1000.00000001 ... which would not match to 1000
levels = {round(lev, 4) for lev in da_levels.values}
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the remapping part we introduce in the roocs.ini

[clisops:coordinate_precision]
hor_coord_decimals = 6
vert_coord_decimals = 6

In the remapping PR I can then substitute levels = {round(lev, 4) for lev in da_levels.values} with levels = {round(lev, CONFIG["clisops:coordinate_precision"]["vert_coord_decimals"]) for lev in da_levels.values} (and set it to 4 in the roocs.ini). What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@sol1105 sounds good to use a config for the precision.

@sol1105 @Zeitsperre
Should we have a cleansing module to fix datasets when reading and writing?

@cehbrecht cehbrecht merged commit 0a367bd into master Dec 14, 2022
@cehbrecht cehbrecht deleted the fix-check-levels branch December 14, 2022 09:55
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.

None yet

2 participants