-
Notifications
You must be signed in to change notification settings - Fork 6
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
Added sortby to target grid #29
Conversation
Thanks for submitting this PR! It's good to fix this bug, but I feel like it might be best to return the grid in the original order. This is how the interp based methods currently work. The extra steps for this would be to compute the sorted grid, regrid using the sorted grid, and then sort by the original target_grid again: for coord in target_grid.coords:
data = data.sortby(target_grid[coord]) Could you also add tests for these cases (the monotonic increasing and monotonic decreasing coordinates)? |
Good call! Yes, I'd be happy to make this adjustment and add some test to confirm it is working as intended. |
@BSchilperoort, I made an update to return the regridded data in the original order of the target grid. |
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.
Thanks for making the changes! I looked in xarray's documentation and code, and found the reindex_like
method which seems to work very well and is just a single line.
I also reordered the tests a bit with more parameterization to make them more compact :)
The test suite has become a bit slow though, which is because we use a full ERA5 file for the tests. This is good for some of the bigger tests, but for things like the attributes and coordinates it is probably better to use a smaller file.
Great thanks! |
When regridding using the
conservative
andmost_common
methods, the plane coordinates (i.e., latitude and longitude) needed to be in increasing order in the target grid. This adds sorting of the target grid.Fixes the issue in #28.