Skip to content

πŸƒβš‘ Aero: Robust Backend-Agnostic Spatial Slicing - #92

Merged
bbakernoaa merged 4 commits into
mainfrom
aero-robust-spatial-slice-4660603204785869656
May 2, 2026
Merged

πŸƒβš‘ Aero: Robust Backend-Agnostic Spatial Slicing#92
bbakernoaa merged 4 commits into
mainfrom
aero-robust-spatial-slice-4660603204785869656

Conversation

@bbakernoaa

Copy link
Copy Markdown
Collaborator

This PR refactors the spatial_slice utility in src/xregrid/utils.py to extend support beyond rectilinear grids to curvilinear and unstructured datasets (e.g., MPAS, MUSICA).

Key architectural improvements:

  1. Dual-Path Dispatch: Automatically detects if spatial coordinates are dimension coordinates (rectilinear) or auxiliary coordinates (unstructured/curvilinear) to select the optimal slicing strategy.
  2. Pure Laziness: Eliminated all hidden computes (.compute(), .values, .min()) to ensure the function remains non-blocking for Dask users.
  3. Lazy Wrapping: Replaced index-based longitude wrapping with a modulo-based masking logic that works across any longitude convention (0-360 or -180 to 180) without triggering data loading.
  4. Scientific Provenance: Automatically updates the history attribute with detailed slicing and wrapping metadata.
  5. Aero Validation: Added tests/test_aero_spatial_slice.py providing "Double-Check" verification for both NumPy and Dask backends across different grid topologies.

PR created automatically by Jules for task 4660603204785869656 started by @bbakernoaa

- Implement backend-agnostic dual-path for spatial slicing.
- Use fast path (.sel) for rectilinear grids.
- Implement robust path (.where) for curvilinear and unstructured grids.
- Ensure strict Aero Protocol compliance: NEVER call .compute() or .values.
- Implement strictly lazy longitude wrapping via modulo arithmetic.
- Maintain laziness for Dask-backed objects by enforcing drop=False during masking.
- Add comprehensive Double-Check tests (Eager/Lazy) with NumPy docstrings.
@google-labs-jules

Copy link
Copy Markdown
Contributor

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

bbakernoaa added 3 commits May 2, 2026 03:23
- Implement backend-agnostic dual-path for spatial slicing.
- Use fast path (.sel) for rectilinear grids.
- Implement robust path (.where) for curvilinear and unstructured grids.
- Ensure strict Aero Protocol compliance: NEVER call .compute() or .values.
- Implement strictly lazy longitude wrapping via modulo arithmetic.
- Maintain laziness for Dask-backed objects by enforcing drop=False during masking.
- Add comprehensive Double-Check tests (Eager/Lazy) with NumPy docstrings.
- Apply linting and formatting fixes via pre-commit.
- Implement backend-agnostic dual-path for spatial slicing.
- Use fast path (.sel) for rectilinear grids.
- Implement robust path (.where) for curvilinear and unstructured grids.
- Ensure strict Aero Protocol compliance: avoid hidden computes (.compute, .values).
- Implement strictly lazy longitude wrapping via modulo arithmetic.
- Maintain laziness for Dask-backed objects by enforcing drop=False during masking.
- Fix cubed backend regression by pinning zarr<3 in pyproject.toml.
- Apply linting and formatting fixes.
- Add comprehensive Double-Check tests (Eager/Lazy) with NumPy docstrings.
- Implement backend-agnostic dual-path for spatial slicing.
- Use fast path (.sel) for rectilinear grids.
- Implement robust path (.where) for curvilinear and unstructured grids.
- Ensure strict Aero Protocol compliance: avoid hidden computes.
- Implement strictly lazy longitude wrapping via modulo arithmetic.
- Maintain laziness for Dask-backed objects by enforcing drop=False.
- Fix cubed backend regression by pinning zarr<3 in pyproject.toml and environment.yml.
- Apply linting and formatting fixes.
- Add comprehensive Double-Check tests (Eager/Lazy) with NumPy docstrings.
@bbakernoaa
bbakernoaa marked this pull request as ready for review May 2, 2026 09:06
@bbakernoaa
bbakernoaa merged commit 1eb2acf into main May 2, 2026
3 checks passed
@zmoon
zmoon deleted the aero-robust-spatial-slice-4660603204785869656 branch July 16, 2026 17:28
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.

1 participant