Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ What's new
------------------
* Fix ESMpy memory issues by explictly freeing the Grid memory upon garbage collection of ``Regridder`` objects. By `Pascal Bourgault <https://github.com/aulemahal>`_.
* Address deprecation for xarray 2024.10 in the parallel weight generation. By `Pascal Bourgault <https://github.com/aulemahal>`_.
* Address an upcoming change in sparse 0.16 where COO fill values will distinguish between 0.0 and -0.0. This issue would affect spatial averaging over polygons with holes. By `Pascal Bourgault <https://github.com/aulemahal>`_.

0.8.7 (2024-07-16)
------------------
Expand Down
15 changes: 10 additions & 5 deletions xesmf/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,8 +1112,9 @@ def _format_xroutput(self, out, new_dims=None):
def __del__(self):
# Memory leak issue when regridding over a large number of datasets with xESMF
# https://github.com/JiaweiZhuang/xESMF/issues/53
self.grid_in.destroy()
self.grid_out.destroy()
if hasattr(self, 'grid_in'): # If the init has failed, grid_in isn't there
self.grid_in.destroy()
self.grid_out.destroy()


class SpatialAverager(BaseRegridder):
Expand Down Expand Up @@ -1324,7 +1325,10 @@ def _compute_weights(self):
w_int, area_int = self._compute_weights_and_area(mesh_int)

# Append weights from holes as negative weights
w = xr.concat((w, -w_int), 'out_dim')
# In sparse >= 0.16, a fill_value of -0.0 is different from 0.0 and the concat would fail
inv_w_int = -w_int
inv_w_int.data.fill_value = 0.0
w = xr.concat((w, inv_w_int), 'out_dim')

# Append areas
area = np.concatenate([area, area_int])
Expand Down Expand Up @@ -1382,5 +1386,6 @@ def _format_xroutput(self, out, new_dims=None):
def __del__(self):
# Memory leak issue when regridding over a large number of datasets with xESMF
# https://github.com/JiaweiZhuang/xESMF/issues/53
self.grid_in.destroy()
self.grid_out.destroy()
if hasattr(self, 'grid_in'): # If the init has failed, grid_in isn't there
self.grid_in.destroy()
self.grid_out.destroy()
Loading