small bug in climate selection for glaciers near 0 longitude #1825
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.
I found out that glaciers with a longitude of (-res/2,0) or converted a longitude of (360-res/2,360) get assigned the climate from the neighbouring gridpoint, i.e. lon=-res (or lon= 360-res) instead of correctly being assigned to lon=0 . (res = longitudinal resolution)
This happens only for climate datasets that have longitude gridpoints at "zero" (i.e., e.g. ERA5 / ERA5-Land). It is not relevant for W5E5, ISIMIP3b GCMs because they do not have longitude gridpoints at "zero".
This wrong assignment happens for both the gridded and the flattened climate datasets, however to my knowledge, only two glaciers are affected, and these ones are really small, luckily (see picture below):

I started to do some changes in the code, though much more lines would be affected, and we may need a helper function for that. I also updated the tests, but this behaviour can only be tested indirectly, as we don't have "test_gdirs" for these specific glaciers ...
Some more explanations are in the following test code of this picture

Tests added/passed (only for the flattened files)
TODO: find a clean code solution and update all climate selection functions (also those for the GCMs)
Maybe it is best to do this only for OGGM v1.7?