pangeo-data / xESMF

Universal Regridder for Geospatial Data
http://xesmf.readthedocs.io/
MIT License
189 stars 34 forks source link

Issues when Regridding masked data + dump to netCDF #192

Closed lemieuxbenedicte closed 8 months ago

lemieuxbenedicte commented 2 years ago

Quick description

Issues connected to the handling of the regridding weights as a sparse.COO array and/or an xarray.DataArray backed by a sparse.COO array.

  1. Issue 1 :

    AttributeError: 'numpy.ndarray' object has no attribute
    'to_scipy_sparse'

    Arises when the regriding involves source/destination grids with masked data (extrapolation).

  2. Issue 2 :

    AttributeError: 'numpy.ndarray' object has no attribute 'coords'

    Arises when writing the regridding weights to a netCDF file with the dedicated Class BaseRegridder method.

Full description

Demonstration with jupyter-notebook : package versions, raised error, proposed fix and tests...

huard commented 1 year ago

Thanks for the PR. The fix seems to create test failures. Could you address those and add a unit test exposing the issue you're fixing?

aulemahal commented 8 months ago

Same comment as on the other PR: With xESMF 0.8.3, xarray 2023.12 and sparse 0.14, I haven't been able to reproduce the issue. My guess is that some incompability between xarray and sparse has now been fixed and the issue of weights being transformed to a numpy array unexpectedly is now gone.

I'll close this PR/issue for now. Hopefully, the fix is simply a question of upgrading the environment.