-
Notifications
You must be signed in to change notification settings - Fork 19
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
Tile server: ensure timezone-naive time selector #602
Conversation
Fixes #555. In tile._get_var_2d_array (used by new_color_mapped_image), check for the possibility that the array uses datetime64 and the indexer is timezone-aware. In this case, covert to a timezone-naive indexer before performing the selection.
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.
Tested locally and works well :) Thanks for fixing!
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.
- The natural home of this fix should be
xcube.core.tile.parse_non_spatial_labels()
- I assume, the nature of the problem requires a more general solution. Hence, we need an understanding of the root cause and a general function that fixes the issue before timstamps are passed into
xarray.Dataset/DataArray.sel()
.
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.
I really would like a test for this. Also, I'd expect this issue to arise in more places than this. Did you check the other places?
OK, added. |
There seem to be fewer of them than I feared. I found time selection used in three other places in the xcube codebase:
The last of these will be made safe by Norman's suggestion of moving the check to |
Move the call to xcube.core.tile._ensure_time_compatible from _get_var_2d_array to parse_non_spatial_labels.
OK, moved. |
Then let's just fix the server and enhance the issue #555 by your findings or create a new one. |
Fixes #555.
In tile._get_var_2d_array (used by new_color_mapped_image),
check for the possibility that the array uses datetime64 and the
indexer is timezone-aware. In this case, convert to a timezone-naive
indexer before performing the selection.
[Description of PR]
Checklist:
[ ] Add unit tests and/or doctests in docstrings(not needed)[ ] Add docstrings and API docs for any new/modified user-facing classes and functionsN/A[ ] New/modified features documented inN/Adocs/source/*
[ ] Changes documented inN/ACHANGES.md
Remember to close associated issues after merge!