squeeze length-1 dimension awi-esm-1-1-lr sea ice variables - #3178
Conversation
valeriupredoi
left a comment
There was a problem hiding this comment.
LGTM and with many thanks! I also checked iris.utils.squeeze is a lazy op - @schlunma mind a merge here pls? 🍻
|
Thanks for you contribution @brittaGrusdt! Could you please add a tiny test for it? For some reason, the test coverage is not tested in this pull request, otherwise this would complain about missing tests. If I understand correctly, if cube.coords("nodes"):
idx = [slice(None)] * cube.ndim
idx[cube.coord_dims("nodes")[0]] = 0 # assumes the "nodes" coordinate is 1D
cube = cube[tuple(idx)] # removes "nodes" coordinate by demoting it to a scalar coordinate |
c0ab37c to
5cf8234
Compare
|
Thank you @valeriupredoi, @schlunma. Right, squeeze would remove all length 1 dimensions, I updated the fix so that now only the length-1 dimension 'nodes' is removed as you suggested. And I added a small test for the fix. Doing that, I saw that the two tests for allvariables are identical, i.e. the one for testing when the metadata should be fixed and the one where it doesn't need to be fixed. Shall I update this too, as part of this pr? It's just a copy paste error where the metadata for the sample data is set.. |
|
I just realized that the new fix does not work (not speaking for my test, which did pass). I'll update it |
…t mapped coordinate
|
The problem was that the data in the original file had a dimension of length 1 without a coordinate. The error showed that it is the nodes dimension, but apparently it had been removed in some previous step, I guess. So now the fix removes a dimension of length 1 if it does not have a mapped coordinate or if its of length 1 and is nameed 'nodes'. In the test, I test both cases now. |
schlunma
left a comment
There was a problem hiding this comment.
Great, thanks so much @brittaGrusdt! Just a tiny comment about type hints, apart from that I think this is ready to go!
|
Ah, forgot one thing: If you'd like, you can add yourself to our I will briefly close and re-open the PR to check if that fixes the cla check. |
a646f46 to
c944dfa
Compare
Description
Removes length-1 dimension 'nodes' for model awi_esm_1_1_lr for sea ice variables (sea ice extent north + south and sea ice area north + south) which is expected to have only a time dimension.
Closes #issue_number
Link to documentation:
Before you get started
Checklist
It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.
To help with the number pull requests: