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
Copy link
Copy Markdown
Contributor

@rajeeja rajeeja commented May 13, 2026

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

@rajeeja rajeeja requested a review from erogluorhan May 13, 2026 16:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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

2 participants