Closed kjdoore closed 9 months ago
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. sortby
did not quite work as you proposed, but I was able to create a solution. Feel free to give it a review and let me know what you think.
Great thanks! reindex_like
seems like the way to go. I looked for something like that, but didn't find it on my pass through the xarray docs. I'm glad you did.
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.