Skip to content

Commit

Permalink
Fix parallel regridder regression and version 0.8.4 (#344)
Browse files Browse the repository at this point in the history
* Fix 343 - add tests - upd changes

* Fix changes
  • Loading branch information
aulemahal committed Feb 23, 2024
1 parent d32b5f4 commit 6d65d2f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
9 changes: 4 additions & 5 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
What's new
==========

0.8.4 (2024-02-26)
------------------
* Fix regression from :pull:`332` that made ``Regridder`` fail with rectilinear datasets and ``parallel=True``. (:issue:`343`, :pull:`344`).

0.8.3 (2024-02-20)
------------------
* Remove usage of private method of xarray that was removed in its 2024.02.0 version (:issue:`338`, :issue:`340`) By `Pascal Bourgault <https://github.com/aulemahal>`_.
Expand All @@ -9,7 +13,6 @@ Internal changes
----------------
* Test against ESMF 8.6


0.8.2 (2023-09-18)
------------------

Expand All @@ -18,10 +21,6 @@ Bug fixes
* Raise a meaningful error messages when the output grid has no chunks with `parallel=True` (:issue:`299`, :pull:`304`). By `Pascal Bourgault <https://github.com/aulemahal>`_.
* Correct guess of output chunks for ``SpatialAverager``.

Internal changes
----------------
* Test against ESMF 8.6

0.8.1 (2023-09-05)
------------------

Expand Down
4 changes: 3 additions & 1 deletion xesmf/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,9 @@ def _init_para_regrid(self, ds_in, ds_out, kwargs):

# Rename coords to avoid issues in xr.map_blocks
for coord in list(self.out_coords.keys()):
ds_out = ds_out.rename({coord: coord + '_out'})
# If coords and dims are the same, renaming has already been done.
if coord not in self.out_horiz_dims:
ds_out = ds_out.rename({coord: coord + '_out'})

weights_dims = ('y_out', 'x_out', 'y_in', 'x_in')
templ = sps.zeros((self.shape_out + self.shape_in))
Expand Down
15 changes: 15 additions & 0 deletions xesmf/tests/test_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,21 @@ def test_para_weight_gen():
# weights should be identical between serial and parallel
assert all(regridder.w.data.data == para_regridder.w.data.data)

# Should work with a rectilinear version too (where dims == coords)
ds_in_cf = xe.util.cf_grid_2d(-90, 90, 20, -45, 45, 12)
ds_out_cf = xe.util.cf_grid_2d(-90, 90, 15, -45, 45, 9)
ds_in_cf['data'] = xe.data.wave_smooth(ds_in_cf['lon'], ds_in_cf['lat'])
ds_out_cf['data_ref'] = xe.data.wave_smooth(ds_out_cf['lon'], ds_out_cf['lat']).chunk(
{'lat': 5, 'lon': 5}
)

# Generating weights in serial and parallel
regridder = xe.Regridder(ds_in_cf, ds_out_cf, 'conservative')
para_regridder = xe.Regridder(ds_in_cf, ds_out_cf, 'conservative', parallel=True)

# weights should be identical between serial and parallel
assert all(regridder.w.data.data == para_regridder.w.data.data)

# Ensure para weight gen works with locstream_in as well
reggrider_locs = xe.Regridder(ds_locs, ds_out_chunked, 'nearest_s2d', locstream_in=True)
para_regridder_locs = xe.Regridder(
Expand Down

0 comments on commit 6d65d2f

Please sign in to comment.