Skip to content

Conversation

@aaronzedwick
Copy link
Member

@aaronzedwick aaronzedwick commented Oct 14, 2024

Closes #678

Overview

Adds bilinear remapping functionality to UXarray.

Expected Usage

import uxarray as ux

source = "/path"
destination = "/path"
source_uxds = ux.open_dataset(destination, destination)
destination = ux.open_dataset(destination, destination)

bilinear_remap = source_uxds.remap.bilinear(destination.uxgrid, remap_to='face centers')

PR Checklist

General

  • An issue is linked created and linked
  • Add appropriate labels
  • Filled out Overview and Expected Usage (if applicable) sections

Testing

  • Adequate tests are created if there is new functionality
  • Tests cover all possible logical paths in your function
  • Tests are not too basic (such as simply calling a function and nothing else)

Documentation

  • Docstrings have been added to all new functions
  • Docstrings have updated with any function changes
  • Internal functions have a preceding underscore (_) and have been added to docs/internal_api/index.rst
  • User functions have been added to docs/user_api/index.rst

@philipc2
Copy link
Member

philipc2 commented May 16, 2025

With the latest changes, doing the following remapping:

Source Cells: 655,362 (MPAS)
Destination Cells: 196,608 (HEALPix)
image

Much better performance, but still not really usable for any of our higher resolution grids.

Is it possible to write the entire weight computation in Numba?

We can do a single query for the points in face outside of Numba and pass those values in.

@aaronzedwick
Copy link
Member Author

With the latest changes, doing the following remapping:

Source Cells: 655,362 (MPAS)
Destination Cells: 196,608 (HEALPix)
image Much better performance, but still not really usable for any of our higher resolution grids.

Is it possible to write the entire weight computation in Numba?

We can do a single query for the points in face outside of Numba and pass those values in.

Yeah, that was the plan once the point in face query was able to be done in one query. I wanted to make sure my implementation was accurate before worrying about numba, since it wasn’t wanting to work with my first implementation. I’ll start working on performance now that the point in face bottleneck is fixed. I see you made the newton quadrilateral function use numba already, thanks! I’m still learning how to write everything to be compatible with numba. Not always easy!

@aaronzedwick aaronzedwick added the run-benchmark Run ASV benchmark workflow label May 16, 2025
@aaronzedwick aaronzedwick added run-benchmark Run ASV benchmark workflow and removed run-benchmark Run ASV benchmark workflow labels May 19, 2025
@aaronzedwick aaronzedwick added run-benchmark Run ASV benchmark workflow and removed run-benchmark Run ASV benchmark workflow labels May 19, 2025
@philipc2 philipc2 removed the run-benchmark Run ASV benchmark workflow label May 21, 2025
Copy link
Member

@philipc2 philipc2 left a comment

Choose a reason for hiding this comment

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

Fantastic work @aaronzedwick

The results look excellent and the performance is really good. Takes about 30s to go from a 15km MPAS grid to a HEALPix zoom of 8 on my laptop.

There may be some opportunities for some smaller optimizations later, and to expose the weights to the user to allow them to store and reuse them, but for now this is looking great.

@philipc2 philipc2 requested a review from Copilot May 21, 2025 03:42
Copy link
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 implements bilinear remapping in UXarray, integrating it into the .remap accessor, adding supporting geometry routines, updating tests, docs, and benchmarks.

  • Core bilinear remap logic added (_bilinear, barycentric weight routines)
  • .remap.bilinear accessor method introduced
  • Tests, documentation, API reference, and benchmarks updated for bilinear

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
uxarray/remap/bilinear.py Added _bilinear function and supporting barycentric routines
uxarray/remap/accessor.py Exposed .remap.bilinear method
uxarray/plot/utils.py Removed stray debug print
uxarray/grid/grid.py Extended get_dual signature with optional duplicate check
uxarray/grid/geometry.py Introduced barycentric_coordinates_cartesian and helpers
uxarray/grid/neighbors.py Trimmed extraneous whitespace
test/test_remap.py Added bilinear remap tests
docs/user-guide/remapping.ipynb Updated notebook to include bilinear examples
docs/api.rst Registered remap.bilinear in API docs
benchmarks/mpas_ocean.py Added benchmarking for bilinear remapping

@philipc2 philipc2 merged commit dca56ac into main May 21, 2025
20 checks passed
@erogluorhan erogluorhan deleted the zedwick/bilinear-remapping branch September 26, 2025 17:48
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.

Bilinear Remapping

5 participants