Skip to content

squeeze length-1 dimension awi-esm-1-1-lr sea ice variables - #3178

Merged
schlunma merged 4 commits into
ESMValGroup:mainfrom
brittaGrusdt:fix-fesom-siextent
Jul 28, 2026
Merged

squeeze length-1 dimension awi-esm-1-1-lr sea ice variables#3178
schlunma merged 4 commits into
ESMValGroup:mainfrom
brittaGrusdt:fix-fesom-siextent

Conversation

@brittaGrusdt

@brittaGrusdt brittaGrusdt commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

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:

@CLAassistant

CLAassistant commented Jul 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@valeriupredoi valeriupredoi added the fix for dataset Related to dataset-specific fix files label Jul 23, 2026

@valeriupredoi valeriupredoi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM and with many thanks! I also checked iris.utils.squeeze is a lazy op - @schlunma mind a merge here pls? 🍻

@schlunma

Copy link
Copy Markdown
Contributor

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, iris.util.squeeze removes all dimensions with length 1, which might potentially remove other (wanted) dimensions. It might be safer to actually remove the nodes dimension manually, e.g. with

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

@brittaGrusdt

Copy link
Copy Markdown
Contributor Author

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..

@brittaGrusdt

Copy link
Copy Markdown
Contributor Author

I just realized that the new fix does not work (not speaking for my test, which did pass). I'll update it

@brittaGrusdt

Copy link
Copy Markdown
Contributor Author

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 schlunma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great, thanks so much @brittaGrusdt! Just a tiny comment about type hints, apart from that I think this is ready to go!

Comment thread esmvalcore/cmor/_fixes/cmip6/awi_esm_1_1_lr.py Outdated
@schlunma

Copy link
Copy Markdown
Contributor

Ah, forgot one thing: If you'd like, you can add yourself to our .zenodo.json and CITATION.cff files to get acknowledgement for you contributions 👍

I will briefly close and re-open the PR to check if that fixes the cla check.

@schlunma schlunma closed this Jul 28, 2026
@schlunma schlunma reopened this Jul 28, 2026
@schlunma schlunma added this to the v2.16.0 milestone Jul 28, 2026
@schlunma
schlunma merged commit 620151a into ESMValGroup:main Jul 28, 2026
4 checks passed
@brittaGrusdt
brittaGrusdt deleted the fix-fesom-siextent branch July 29, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix for dataset Related to dataset-specific fix files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants