Skip to content
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

Usage of xarray ufuncs is deprecated #183

Closed
mattijn opened this issue Aug 16, 2022 · 9 comments
Closed

Usage of xarray ufuncs is deprecated #183

mattijn opened this issue Aug 16, 2022 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@mattijn
Copy link

mattijn commented Aug 16, 2022

Xarray has removed support for the deprecated xarray.ufuncs functions since version v2022.06.rc0: https://docs.xarray.dev/en/stable/whats-new.html#breaking-changes.

Now I receive the following error:

import geowombat as gw
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 import geowombat as gw

File /opt/tljh/user/envs/stable/lib/python3.8/site-packages/geowombat/__init__.py:5, in <module>
      2 __version__ = '1.11.3'
      4 from . import config
----> 5 from .core.api import open
      6 from .core.api import load
      7 from .core.api import series

File /opt/tljh/user/envs/stable/lib/python3.8/site-packages/geowombat/core/__init__.py:1, in <module>
----> 1 from ..backends import transform_crs
      2 from .io import apply
      3 from .io import to_raster

File /opt/tljh/user/envs/stable/lib/python3.8/site-packages/geowombat/backends/__init__.py:2, in <module>
      1 from .dask_ import Cluster
----> 2 from .xarray_ import concat, mosaic
      3 from .xarray_ import warp_open
      4 from .xarray_ import transform_crs

File /opt/tljh/user/envs/stable/lib/python3.8/site-packages/geowombat/backends/xarray_.py:26, in <module>
     24 import dask.array as da
     25 import xarray as xr
---> 26 from xarray.ufuncs import maximum as xr_maximum
     27 from xarray.ufuncs import minimum as xr_mininum
     30 logger = logging.getLogger(__name__)

ModuleNotFoundError: No module named 'xarray.ufuncs'

Searching the repo: https://github.com/jgrss/geowombat/search?q=xarray.ufuncs&type=code
Reveals at least one file needs updating:

from xarray.ufuncs import maximum as xr_maximum
from xarray.ufuncs import minimum as xr_mininum

Linked issue: #42

@37310N
Copy link

37310N commented Aug 23, 2022

@jgrss is it possible to downgrade geowombat and/or xarray to solve the issue?

@mattijn
Copy link
Author

mattijn commented Aug 23, 2022

Yes, you can use current version of geowombat with:

pip install xarray==2022.3.0

@37310N
Copy link

37310N commented Aug 23, 2022

The following workaround solved the problem for me, but maybe this is not a really good solution.
Only tested on calculating Band Math & Vegetation Indices following this guide.

Searching the repo: https://github.com/jgrss/geowombat/search?q=xarray.ufuncs&type=code Reveals at least one file needs updating:

from xarray.ufuncs import maximum as xr_maximum
from xarray.ufuncs import minimum as xr_mininum

In the given file I commented the lines 26 & 27 out (see above) and changed the xarray min/max function to numpy.minimum() and numpy.maximum() as follows:

if overlap == 'min':
ds = np.minimum(ds, dsb)
elif overlap == 'max':
ds = np.maximum(ds, dsb)
elif overlap == 'mean':
ds = (ds + dsb) / 2.0

@37310N
Copy link

37310N commented Aug 23, 2022

Yes, you can use current version of geowombat with:

pip install xarray==2022.3.0

Finally, after a bit of back and forth, I was able to freshly install geowombat and than downgrade xarray to the suggested version with conda. This works fine for me.

Thank you @mattijn

@mmann1123 mmann1123 self-assigned this Aug 24, 2022
@mmann1123 mmann1123 added the bug Something isn't working label Aug 24, 2022
@mmann1123
Copy link
Collaborator

@jgrss just opened a pull request to resolve this.

@mmann1123 mmann1123 linked a pull request Aug 24, 2022 that will close this issue
@jgrss
Copy link
Owner

jgrss commented Aug 30, 2022

@mmann1123 What is the status of PR #186? Was it closed because we had discussed using the fixes in jgrss/store?

@jgrss
Copy link
Owner

jgrss commented Aug 30, 2022

Yes, you can use current version of geowombat with:

pip install xarray==2022.3.0

Thanks for comfirming this, @mattijn -- a branch in the waiting that should push geowombat to v2.0.0 has xarray>=2022.6.0.

@mmann1123
Copy link
Collaborator

@jgrss I intended PR #186 to resolve the ufunc issues but then some tests were failing in ML and another elsewhere, I was worried I had inadvertently pushed some old ML code, so closed it. But I think we need to push the jgrss/store. I will try to test it today, but its first day of classes so things are busy. Might be a few days. But I figure jgrss/store can't make things worse - since people can't write out files - and would likely fix things. But I defer to you on that.

@jgrss jgrss mentioned this issue Aug 30, 2022
@jgrss
Copy link
Owner

jgrss commented Sep 1, 2022

Should be addressed with #189.

@jgrss jgrss closed this as completed Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants