Repository navigation
Conversation
The per-latitude face weights depend only on the grid, so assemble them once into a sparse (n_lat, n_face) CSR operator and apply it to the data in a single xr.apply_ufunc call, as remap/apply_weights.py does. This replaces the per-latitude loop that added one dask __setitem__ layer per latitude: the graph no longer grows with the number of latitudes, and time/lev chunks become the parallel axes. Row 1.5 of UXARRAY#1789. - _build_zonal_line_operator: geometry only. Drops the redundant re-normalization (weights already sum to 1). Keeps explicit zero weights so a NaN in a face that only touches a latitude still makes that latitude NaN, as before. - _apply_face_operator: generic n_face contraction, reusable by the conservative mean, zonal_anomaly and azimuthal_mean. - Tests: match the old per-latitude loop to rtol=1e-12 across numpy, time-chunked, grid-chunked and n_face-first layouts and both weight methods; float32 preserved; NaN locality; graph size independent of latitude count. - Benchmark ZonalAverageDask: at 480km, lat=(-45, 45, 1), 12 time steps, time-chunked 433 ms -> 14 ms (8,009 -> 48 tasks), grid-chunked 633 ms -> 16 ms (16,953 -> 108 tasks). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ASV BenchmarkingBenchmark Comparison ResultsBenchmarks that have improved:
Benchmarks that have stayed the same:
Benchmarks that have got worse:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #XXX
Overview
The per-latitude face weights depend only on the grid, so assemble them once into a sparse (n_lat, n_face) CSR operator and apply it to the data in a single xr.apply_ufunc call, as remap/apply_weights.py does. This replaces the per-latitude loop that added one dask setitem layer per latitude: the graph no longer grows with the number of latitudes, and time/lev chunks become the parallel axes. Row 1.5 of #1789.
Expected Usage
PR Checklist
General
Testing & Benchmarking
Documentation and Examples
docs/api.rst; internal (private) function names start with an underscore (_)AI Disclosure
AI Usage: