Skip to content

feat: implement DifferenceFilter to compute the difference between two variables#232

Open
nicrie wants to merge 2 commits intoecmwf:mainfrom
nicrie:difference
Open

feat: implement DifferenceFilter to compute the difference between two variables#232
nicrie wants to merge 2 commits intoecmwf:mainfrom
nicrie:difference

Conversation

@nicrie
Copy link

@nicrie nicrie commented Feb 18, 2026

Description

Add a difference filter that computes $X-Y$ between two matched variables and registers it in the filter registry.

What problem does this change solve?

New feature: enables simple variable differencing in transform pipelines.

What issue or task does this change relate to?

None.

Additional notes

Is the list of available filters auto-generated? Let me know where to update the source docs if necessary and I can add the difference filter there.

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.

Copy link
Contributor

@aaron-hopkinson aaron-hopkinson left a comment

Choose a reason for hiding this comment

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

Thanks for this. The filter looks good to me.

Would it also be possible to add a test, please? 🙂

@@ -0,0 +1,74 @@
# (C) Copyright 2024 Anemoi contributors.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# (C) Copyright 2024 Anemoi contributors.
# (C) Copyright 2026- Anemoi contributors.

*,
x: str,
y: str,
diff: str,
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it's worth having an abs: bool = False argument as well (which optionally takes the absolute value of the difference)? I can imagine that there may cases where the absolute difference is useful (and prevents people having to think about which is X and which is Y)

@github-project-automation github-project-automation bot moved this from To be triaged to Under Review in Anemoi-dev Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Under Review

Development

Successfully merging this pull request may close these issues.

2 participants