Skip to content

feat(graphs): add custom area weightings#926

Merged
JPXKQX merged 14 commits intoecmwf:mainfrom
efare04:feat/anemoi-dataset-variable-weights
Feb 24, 2026
Merged

feat(graphs): add custom area weightings#926
JPXKQX merged 14 commits intoecmwf:mainfrom
efare04:feat/anemoi-dataset-variable-weights

Conversation

@efare04
Copy link
Contributor

@efare04 efare04 commented Feb 23, 2026

Description

This PR adds a class which allows users to load custom area weightings from a variable in an Anemoi dataset. The behaviour of AnemoiDatasetVariableWeights is based on that of BaseAnemoiDatasetVariable, but isn't inherited directly from that class as that would set dtype = bool.

What problem does this change solve?

None of the existing classes to calculate area weightings are suitable for the tripolar ORCA025 grid, but we already have a file containing the cell areas. This information could be read directly from a variable in an Anemoi dataset into a node attribute, rather than calculating the area weightings within anemoi-graphs.

What issue or task does this change relate to?

#925

Additional notes

I've put this in area_weights.py, as we're intending to use it for area weightings, but this class could be used to create a custom node attribute for other purposes. Perhaps it would be worth renaming it (e.g. to AnemoiDatasetVariableAttribute) and moving it elsewhere, as its application isn't limited to area weights?

As a contributor to the Anemoi framework, please ensure that your changes include unit tests, updates to any affected dependencies and documentation, and have been tested in a parallel setting (i.e., with multiple GPUs). As a reviewer, you are also responsible for verifying these aspects and requesting changes if they are not adequately addressed. For guidelines about those please refer to https://anemoi.readthedocs.io/en/latest/

By opening this pull request, I affirm that all authors agree to the Contributor License Agreement.


📚 Documentation preview 📚: https://anemoi-training--926.org.readthedocs.build/en/926/


📚 Documentation preview 📚: https://anemoi-graphs--926.org.readthedocs.build/en/926/


📚 Documentation preview 📚: https://anemoi-models--926.org.readthedocs.build/en/926/

@JPXKQX
Copy link
Member

JPXKQX commented Feb 24, 2026

Hi @efare04, this PR looks self-contained and provides some new functionality. Thanks for your contribution! I made a minor comment, but I'm happy to approve!

@JPXKQX JPXKQX added the ATS Approval Not Needed No approval needed by ATS label Feb 24, 2026
@JPXKQX JPXKQX linked an issue Feb 24, 2026 that may be closed by this pull request
@efare04
Copy link
Contributor Author

efare04 commented Feb 24, 2026

Hi @JPXKQX, thanks for the review! I've updated the docstring to remove the private method.

Just to quickly follow up on my original comment, I'm happy to rename and relocate AnemoiDatasetVariableWeights if you think a generic name would be more appropriate, given that it could be used for more than just area weights. No problem if you'd prefer to keep it as-is - just wanted to double-check before this gets merged.

@JPXKQX
Copy link
Member

JPXKQX commented Feb 24, 2026

I think it's fine for now. If we identify any new use cases that reuse this functionality, we could consider abstracting it.

@JPXKQX JPXKQX merged commit 5c43509 into ecmwf:main Feb 24, 2026
14 checks passed
@github-project-automation github-project-automation bot moved this from To be triaged to Done in Anemoi-dev Feb 24, 2026
@DeployDuck DeployDuck mentioned this pull request Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Custom area weightings in node attributes

2 participants