Skip to content

Add reusable remap weight support#1483

Open
rajeeja wants to merge 9 commits into
mainfrom
rajeeja/apply_precomputed_weights
Open

Add reusable remap weight support#1483
rajeeja wants to merge 9 commits into
mainfrom
rajeeja/apply_precomputed_weights

Conversation

@rajeeja
Copy link
Copy Markdown
Contributor

@rajeeja rajeeja commented Apr 1, 2026

Adds support for loading and applying reusable offline remap weights through a generic RemapWeights API, including focused tests and docs for external ESMF and TempestRemap map files. Closes #172.

@rajeeja rajeeja self-assigned this Apr 1, 2026
@rajeeja rajeeja requested review from erogluorhan April 1, 2026 19:16
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

Adds a reusable “offline remap weights” workflow to UXarray so users can load precomputed sparse remapping operators (e.g., ESMF/TempestRemap map files) once and apply them repeatedly to UXarray objects.

Changes:

  • Introduces a RemapWeights dataclass plus load_remap_weights() with a path-based cache for weight files.
  • Adds UxDataArray.remap.apply_weights() / UxDataset.remap.apply_weights() to apply the sparse operator to the matching spatial dimension.
  • Adds focused tests and new documentation/user-guide material for applying external offline map files.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
uxarray/remap/weights.py New loader + cached RemapWeights sparse operator implementation.
uxarray/remap/apply_weights.py New implementation to apply a loaded operator to UXarray data variables.
uxarray/remap/accessor.py Exposes apply_weights() on the .remap accessor and documents it in __repr__.
uxarray/remap/init.py Exports new weights APIs (and _apply_weights).
uxarray/init.py Re-exports RemapWeights and load_remap_weights at the top level.
test/precomputed_weights_test.py New tests for loading, applying, and cache reuse.
docs/userguide.rst Adds the new remap-weights guide to the user guide index / toctree.
docs/user-guide/remap-weights.rst New user guide page describing external weight application workflow and file expectations.
docs/api.rst Adds load_remap_weights, RemapWeights, and accessor methods to the public API docs.

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

Comment thread uxarray/remap/weights.py Outdated
Comment thread uxarray/remap/weights.py
Comment thread uxarray/remap/weights.py Outdated
Comment thread uxarray/remap/apply_weights.py
Comment thread uxarray/remap/apply_weights.py Outdated
Comment thread uxarray/remap/apply_weights.py
- prefer start_index attr; treat as 1-based only when max==size
- reject non-spatial source_dim
- preserve aux coords whose dims are subset of other_dims
- document eager dask materialization
- LRU-bound weights cache; add clear_remap_weights_cache()
- use _open_dataset_with_fallback in RemapWeights.from_file
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.

Applying remap weights from other packages (e.g., ESMF, TempestRemap?)

3 participants