-
Notifications
You must be signed in to change notification settings - Fork 36
Bilinear Remapping #1016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Bilinear Remapping #1016
Conversation
…into zedwick/dual_mesh
…into zedwick/dual_mesh
That wasn't the comparison; that was showcasing our remapping on a grid that was slightly larger. However, I think he used the same file for the comparison. Rajeev mentioned that he was going to get actual grid data to load for the comparison, not sure if he ended up doing that @rajeeja. The issue is getting ESMPy and UXarray to both load the same files. I think Rajeev was having struggles with getting UXarray to load the files inside the ESMPy docs. @rajeeja, if you did end up getting the comparison, can you post a photo here? If not, I can look into finding something that would work if you want me to. I would have to install ESMPy on my machine, however. |
would it be good to shorten the test case in the notebook? |
We could, but it doesn't seem that much longer than what other PR's are taking for tests. It is only a few minutes longer. And when RTree is implemented, that should give a significant boost to performance, which should solve the extra few minutes it takes. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tempestremap comparison looks good. code for comparison here: https://github.com/rajeeja/uxarray_squadgen/tree/main/tempestremap_uxarray
This looks great, thanks for doing this! |
Thank you for putting this report together! Do we know where the differences are coming from? A max difference of Looking at the UXarray and TempestRemap plots, the UXarray one has a noticeable jitter For example Compared to Can you generate a plot of the following
|
The differences could be that tempest remap splits bigger polygons into triangles and finds the sub triangle that holds the point. It then does the barycentric calculation with that triangle. I tried to emulate the current barycentric implementation that spatial hashing uses, by just getting the weights of the entire polygon without finding the sub triangle the point is in, thus eliminating the extra check to point in polygon. In my mind the performance at the time was worth it. However now that I have done some benchmarks, point in polygon is actually very lightweight. I don’t think it would have a massive impact if we changed to check the sub triangles. However, it would cause more calls to point in polygon. For example, a mesh with any given polygon would have (n_edges-2) * n_face calls to point in polygon. Like I said though, I believe the function takes a very small amount of time even with the current calls (n_face best case). Let me know what you think @philipc2 |
o Add healpix bilinear remapping
@aaronzedwick can you push the latest changes that make it same as tempestremap? |
I already have. |
There was a problem hiding this 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 bilinear remapping functionality to UXarray by introducing new bilinear methods on both the UxDataset and UxDataArray remap accessors along with a dedicated bilinear remapping module. Key changes include the implementation of the bilinear interpolation algorithm in uxarray/remap/bilinear.py, updates to the accessor methods in dataset_accessor.py and dataarray_accessor.py to support bilinear remapping (including destination grid checks), and corresponding updates to tests, benchmarks, and documentation.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
uxarray/remap/dataset_accessor.py | Added bilinear remap method with None-check for destination grid |
uxarray/remap/dataarray_accessor.py | Introduced bilinear remap method for data arrays |
uxarray/remap/bilinear.py | New module implementing bilinear remapping logic |
uxarray/grid/neighbors.py | Minor cleanup by removing extra newline |
uxarray/grid/grid.py | Added explicit conversion of point coordinates to np.asarray |
test/test_remap.py | Added tests to verify bilinear remapping behavior |
docs/user-guide/remapping.ipynb | Updated user guide to document the bilinear remapping option |
docs/api.rst | Updated API docs to include the new bilinear remapping methods |
benchmarks/mpas_ocean.py | Added performance benchmarks for bilinear remapping |
Co-authored-by: Copilot <[email protected]>
Closes #678
Overview
Adds bilinear remapping functionality to UXarray.
Expected Usage
PR Checklist
General
Testing
Documentation
_
) and have been added todocs/internal_api/index.rst
docs/user_api/index.rst