Skip to content

add zonal_anomaly with shared face-band weight kernel#1508

Open
rajeeja wants to merge 3 commits into
mainfrom
rajeeja/fix-zonal-anomaly
Open

add zonal_anomaly with shared face-band weight kernel#1508
rajeeja wants to merge 3 commits into
mainfrom
rajeeja/fix-zonal-anomaly

Conversation

@rajeeja

@rajeeja rajeeja commented May 13, 2026

Copy link
Copy Markdown
Contributor

Adds UxDataArray.zonal_anomaly() returning a same-dimension array where each face value has its latitude-band mean subtracted.

To avoid duplicating the expensive geometric intersection work already done by zonal_mean, the face-band overlap areas are extracted into a shared kernel _compute_face_band_weights(uxgrid, bands) that both zonal_mean and zonal_anomaly call. The conservative path blends band means across straddling faces using the same weight matrix; the default (non-conservative) path assigns each face to a band by centroid latitude.

Fixes #1247

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

Pull request overview

This PR adds a new UxDataArray.zonal_anomaly() API to compute per-face zonal anomalies (subtracting each face’s latitude-band mean) and refactors conservative zonal-mean geometry into a shared face–band overlap kernel.

Changes:

  • Added UxDataArray.zonal_anomaly() public method to return an anomaly field on the original unstructured grid.
  • Introduced _compute_face_band_weights() to share conservative face–latitude-band overlap calculations.
  • Refactored conservative zonal-mean implementation to use the shared weight kernel.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
uxarray/core/zonal.py Adds shared face–band weight computation and implements zonal anomaly backend logic.
uxarray/core/dataarray.py Exposes zonal_anomaly() as a new UxDataArray method.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread uxarray/core/zonal.py Outdated
Comment thread uxarray/core/zonal.py Outdated
Comment thread uxarray/core/zonal.py Outdated
Comment thread uxarray/core/zonal.py
Comment thread uxarray/core/zonal.py Outdated
Comment thread uxarray/core/dataarray.py
Comment thread uxarray/core/zonal.py Outdated

@erogluorhan erogluorhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is looking great; it only lacks documentation (user guide addition) I think

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@rajeeja rajeeja requested a review from erogluorhan May 22, 2026 13:20
@rajeeja rajeeja force-pushed the rajeeja/fix-zonal-anomaly branch from f748225 to 61e61a8 Compare June 8, 2026 20:44
@rajeeja rajeeja force-pushed the rajeeja/fix-zonal-anomaly branch from 61e61a8 to 815889c Compare June 8, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Zonal Anomaly

3 participants