ks905383 / xagg

Aggregating gridded data (xarray) to polygons
https://xagg.readthedocs.io/
GNU General Public License v3.0
83 stars 15 forks source link

importing the package #47

Closed masawdah closed 9 months ago

masawdah commented 1 year ago

image I encountered an error when trying to import xagg. Despite installing the ESMF package and following the installation instructions described in the readme file, I still faced difficulties. I also created an environment using the associated environment.yml file, but the issue persisted.

ks905383 commented 1 year ago

Thanks for raising this issue. It appears the issue is in xesmf, with import ESMF / esmpy (as it's been renamed to recently).

For now, I found a fix here, to basically run:

export ESMFMKFILE=/path/to/anaconda3/envs/[envname]/lib/esmf.mk

before opening python. This works for me in a new environment.

xesmf is only used for a small part of the xagg functionality (regridding weights files to the input raster grid), so in the next version I'm going to limit loading xesmf to the part of the code that does that. If nothing else, it'll make sure the rest of the package isn't dragged down by the dependency issue...

masawdah commented 1 year ago

Thank you so much. This worked great. Just to make sure that the ESMFMKFILE environment variable is available to the Jupyter Notebook session, run the following: import os os.environ['ESMFMKFILE'] = '/path/to/anaconda3/envs/[envname]/lib/esmf.mk'

mjbludwig commented 1 year ago

Not sure who maintains the conda forge stack but the default pulls down the old xagg 0.2.5 but the post module name changed and current version of esmpy 8.4.2. Meaning any xagg installs via conda-forge are broken out of the box. Looks like this may only be the case when using python 3.12 in your env though.

I was able to get a working conda env by specifically downgrading to python 3.11 and then specifying xagg==0.3.1

ks905383 commented 9 months ago

Should be closed by #62 and implemented in v0.3.2.0